Skip to main content

The PreTeXt Guide

Section 4.3 Exercises, Inline and Divisional

This section expands on Section 3.9, which describes the five places an <exercise> may appear: inline within a division, inside a divisional <exercises>, inside a <reading-questions> division, inside a <worksheet>, or as a <project> and its relatives. The markup of the <exercise> is nearly the same in all five, so we describe it once here and note the differences as they arise.
Two large companion topics are treated separately. The placement and collection of hints, answers, and solutions is the subject of Section 4.13, while the many interactive exercise types—multiple choice, Parson problems, matching, and more—are described in Section 4.12. Which of these components is displayed, and where, is a decision for the publisher (see Subsection 44.1.3).

Subsection 4.3.1 The Anatomy of an Exercise

In its simplest form an <exercise> is just a question, authored like any paragraph with <p> and the usual inline elements. As soon as you add a <hint>, an <answer>, or a <solution>, the question itself must be enclosed in a <statement>, so that the parts can be distinguished. When none of those three is present, the <statement> is optional and is usually omitted.
<exercise>
    <statement>
        <p>Compute the derivative of <m>f(x) = x^2</m>.</p>
    </statement>
    <hint>
        <p>Use the power rule.</p>
    </hint>
    <answer>
        <p><m>2x</m></p>
    </answer>
</exercise>
Conceptually an <answer> is a short final result, while a <solution> shows the route to it, and you may provide several of each. An <exercise> may also lead with a <title>. A title is good practice everywhere, and is strongly encouraged for an inline exercise, since a conversion to HTML may present such an exercise in a knowl whose clickable text is the title; see Best Practice 4.8.1.

Subsection 4.3.2 Multi-Part Exercises

A question with several parts is built from a sequence of <task>. Each <task> is structured just like an exercise—a bare paragraph, or a <statement> with its own <hint>, <answer>, and <solution>—and the enclosing <exercise> may frame the parts with an <introduction> and a <conclusion>.
<exercise>
    <title>A multi-part exercise</title>
    <introduction>
        <p>Background needed to begin.</p>
    </introduction>
    <task>
        <statement><p>The first step.</p></statement>
        <hint><p>A little hint.</p></hint>
    </task>
    <task>
        <statement><p>The second step.</p></statement>
    </task>
</exercise>
A <task> may itself contain tasks, nested up to three levels deep. The limit reflects the nested list labels available in output; deeper nesting is reported as an error.

Subsection 4.3.3 Inline, Divisional, and Other Contexts

An inline exercise sits directly among the paragraphs and blocks of a division. It interrupts the narrative and is numbered together with the theorems, examples, and remarks around it (see Section 3.20), so it carries a fully-qualified number like an <example>.
A divisional exercise lives inside an <exercises> division, one of the specialized divisions (Section 4.7). An <exercises> division may appear wherever an ordinary division could, so a section, a chapter, or the entire book may each have one. Its exercises are numbered sequentially within the division, apart from the block numbering. A run of related divisional exercises may be wrapped in an <exercisegroup>, which carries common instructions in a required <introduction>, allows a <conclusion>, and takes an optional <title>.
The remaining contexts are close variations on the same element. A <reading-questions> division holds exercises that check a reader’s comprehension of the surrounding material. A <worksheet> is a print-oriented division whose exercises gain some layout control (see Subsection 4.7.3). A <project>—along with <activity>, <exploration>, and <investigation>—behaves like an inline exercise but may run on its own counter. Section 3.9 tours all five at a glance.
A divisional exercise takes the next sequential number automatically. You may pin a number with the @number attribute to keep problem numbers stable as some may be deleted over time, but once you override one number you will usually have to set every number that follows, so this is best saved for a mature project.
You have attempted of activities on this page.