Skip to main content

Section 21.1 Inline exercises

You can put an <exercise> in the middle of a division, intermixed between theorems and paragraphs and figures. In this case, it is labeled as a “Checkpoint”. 1  You can also put a bunch of <exercise>s inside an <exercises> tag within a division, which is the typical way for creating a bunch of exercises togther at the end of a section.

See Chapter 22 for information on how to use something different than “Checkpoint” as the name for these.
<exercise>
  <statement>
    <p>
      The <c>statement</c> is mandatory.
    </p>
  </statement>
  <hint>
    <p>
      Optional.
      Just an suggestion of what to try.
    </p>
  </hint>
  <answer>
    <p>
      Optional.
      Just the <q>final answer</q>.
    </p>
  </answer>
  <solution>
    <p>
      Optional.
      All the gory details.
    </p>
  </solution>
</exercise>
Listing 21.1.1. An exercise

The code in Listing 21.1.1 produces the following output:

The statement is mandatory.

Hint.

Optional. Just an suggestion of what to try.

Answer.

Optional. Just the “final answer”.

Solution.

Optional. All the gory details.

Note that you can have multiple <hint>, <answer>, and <solution> elements. But you must put all the <hint>s first, then all the <answer>s, and then all the <solution>s. There are a variety of options for determining where hints, answers, and solutions appear (at all). Check the PreTeXt documentation for information about stringparams.