Skip to main content
\( \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \)


An exercise can appear in the narrative as an inline exercise or in a special <exercises> division and is then known as a divisional exercise. The syntax is the same in both cases, there are just some minor differences in their use and treatment. The <exercises> division can be used at any level. In other words, it can be a peer of any other division.

An <exercise> is a mandatory <statement> followed by possibly several optional <hint>, <answer> and/or <solution>. Conceptually, an <answer> is a short final result, while a <solution> provides details about the route to the answer. Each of these four components is structured further, with paragraph-like elements, and the exercise itself may have a <title>.

You need (and want) to have the hints, answers and solutions grouped with the statement, but there is a lot of flexibility on making these available at the location of the exercise, or in the back matter. See Section 6.9 for more.

An inline exercise typically gets a fully qualified unique number and is rendered similar to an <example> or a <remark>. A divisional exercise only gets a sequential number, though this can be overridden with the @number attribute if you want to maintain stable numbering in response to edits. (Be careful, once you override the sequential numbering, you probably need to manually specify every subsequent number, so save overrides for when your project matures.)

Within a run of divisional exercises a subgroup can be delimited as an <exercisegroup>, which allows an <introduction> and/or <conclusion> to explain some commonality. An <exercisegroup> should be rendered in some way that makes it clear to the reader that they are a group.