Skip to main content

Section 3.8 Exercises

Textbooks in many disciplines have exercises for the reader. In PreTeXt there are five places where you can set a question for the reader to pursue.


There is a special <exercises> division and an <exercise> placed there is then known as a divisional exercise. This division supports extra features designed for exercises, such as an <exercisegroup> for short exercises with common instructions. The <exercises> division can be used at any level. In other words, it can be a peer of any other division.


Immediately within any division, you can interrupt the narrative with an inline exercise. It will be rendered similar to a <theorem> or other block, with a number, and a optional <title>.

Reading Question

Another specialized division, <reading-questions>, can be used to house <exercise> designed to test or guide a reader's comprehension of the material in that division.


The main component of a <worksheet> is an <exercise> (Section 3.9). Notably the exercises in a worksheet may be arranged with a <sidebyside> element (Section 3.16).


A <project> is a bit different than the prior situations, since this element is structured with <task>. But it has many common features, such as allowing optional <hint>, <answer>, <solution>.

If an <exercise> is simply a statement of the question, then it may be authored with paragraphs (<p>) and similar elements. If an <exercise> has hints, answers, or solutions, then it must be structured with a <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>. A title is strongly encouraged for inline exercises, and nearly-mandatory if you plan to have inline exercises rendered in knowls in a conversion to HTML.

You need (and want) to have the hints, answers and solutions grouped with the statement as you author, 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.10 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 (including reading questions and worksheet exercises) 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.