Skip to main content

Chapter 17 Example-Like Elements

PreTeXt provides three closely-related tags for things that are examples or similar. They are <example>, <problem>, and <question>. They all have the same syntax. The <title> element is optional. You may either use a freeform example, as shown in Listing 17.0.1, or an example structured with a <statement> and zero or more <hint>s, <answer>s, and <solution>s (in that order). This is illustrated in Listing 17.0.3. Note that for HTML output, if your <example> has a <solution>, the solution will be hidden in a knowl, and the publisher does not (as of August 2019) have the option of not knowling the solution.

<example>
  <title>Differentiating a polynomial</title>
  <p>
    The derivative of the function
    <m>f(x) = 3x^5-7x+5</m> is <m>f'(x) = 15x^4-7</m>.
  </p>
</example>
Listing 17.0.1. A simple example

The code in Listing 17.0.1 produces the following output:

The derivative of the function \(f(x) = 3x^5-7x+5\) is \(f'(x) = 15x^4-7\text{.}\)

<example>
  <title>Differentiating a polynomial</title>
  <statement>
    <p>
      Differentiate the function <m>f(x) = 3x^5-7x+5</m>.
    </p>
  </statement>
  <answer>
    <p>
      <m>f'(x) = 15x^4-7</m>
    </p>
  </answer>
  <solution>
    <p>
      We use the power, sum,
      and constant multiple rules and find that the derivative is <m>f'(x) = 15x^4-7</m>.
    </p>
  </solution>
</example>
Listing 17.0.3. A structured example

The code in Listing 17.0.3 produces the following output:

Differentiate the function \(f(x) = 3x^5-7x+5\text{.}\)

Answer.

\(f'(x) = 15x^4-7\)

Solution.

We use the power, sum, and constant multiple rules and find that the derivative is \(f'(x) = 15x^4-7\text{.}\)