Skip to main content
Contents
Embed
Dark Mode Prev Up Next
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section PreTeXt Cheatsheet
The tags you will reach for most often. Copy, paste, adapt. See
pretextbook.org for the official documentation.
Document Structure.
Divisional levels
<part> <!-- Level 0 -->
<chapter> <!-- Level 1 -->
<section> <!-- Level 2 -->
<subsection> <!-- Level 3 -->
<subsubsection> <!-- Level 4 -->
</subsubsection>
</subsection>
</section>
</chapter>
</part>
A section, front to back
<section>
<title>Section Title</title>
<introduction>...</introduction>
<subsection>...</subsection>
<subsection>...</subsection>
<conclusion>...</conclusion>
<exercises>...</exercises>
</section>
Paragraphs.
Paragraph
<p>
Text in a paragraph.
</p>
Paragraphs (grouped with title)
<paragraphs>
<title>Group Title</title>
<p>paragraph 1</p>
<p>paragraph 2</p>
</paragraphs>
Inline Formatting.
Lists.
Unordered list
<ul>
<li><p>item</p></li>
<li><p>item</p></li>
</ul>
The
<p> tags inside
<li> are optional when the item is a single paragraph.
Ordered list
<ol>
<li>item</li>
<li>item</li>
<li>item</li>
</ol>
Add
cols="2" or
cols="3" on the
<ol> to lay items out in columns.
Description list
<dl>
<li>
<title>Term</title>
<p>Description.</p>
</li>
<li>
<title>Term</title>
<p>Description.</p>
</li>
</dl>
Optional attribute:
width="narrow|medium|wide" to adjust title vs. description width.
Math.
Inline
Display, single-line
<md>\sum_{i=1}^n x_i^2</md>
Numbered display equation
<md number="yes">e^{i\pi} + 1 = 0</md>
Give the equation an
xml:id to reference it with
<xref>.
Aligned, multi-line
<md>
<mrow>a^2 + b^2 \amp = c^2</mrow>
<mrow>y \amp = mx + b</mrow>
<mrow>m \amp = \frac{y-b}{x}</mrow>
<mrow> \amp = \frac{14}{3}</mrow>
</md>
The
\amp character is the alignment anchor (
& in
La Te X ).
Definitions, Theorems, Examples.
Definition
<definition xml:id="def-x">
<statement>...</statement>
</definition>
The
xml:id is optional, but add one if you want to cross-reference the definition later with
<xref>.
Theorem with proof
<theorem>
<statement>...</statement>
<proof>...</proof>
</theorem>
Example
<example xml:id="ex-x">
<title>..</title>
<statement>...</statement>
<solution>...</solution>
</example>
The
<solution> is optional. If you include it, it renders as a knowl the reader can expand.
<remark>
<p>A note.</p>
</remark>
Aside
<aside>
<p>A short aside.</p>
</aside>
An
<aside> renders in the margin (on wide screens) or inline (on narrow ones), visually distinct from a
<remark>.
Exercises.
Simple exercise
<exercise>
<statement>...</statement>
</exercise>
Exercise with tasks
<exercise xml:id="exr-x">
<introduction>...</introduction>
<task>
<statement>...</statement>
<answer>...</answer>
</task>
<task>
<statement>...</statement>
<answer>...</answer>
</task>
</exercise>
Use
<task> for multi-part exercises. Each part gets its own answer knowl.
Hint, answer, solution
<exercise xml:id="exr-y">
<statement>...</statement>
<hint>...</hint>
<answer>...</answer>
<solution>...</solution>
</exercise>
All three are optional. Order matters:
<statement> first, then any combination of
<hint>,
<answer>,
<solution>.
Worksheets.
Worksheet
<worksheet xml:id="ws-x">
<title>..</title>
<objectives>...</objectives>
<page>...</page>
<page>...</page>
</worksheet>
A
<worksheet> is a special environment that behaves like a
<section>, but is styled differently and supports printing.
<worksheet> can be split across
<page> elements to help control the layout.
While
<title>,
<objectives>, and
<page> elements are common child elements of worksheets, they are optional.
Objectives
<objectives>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</objectives>
Place at the top of a worksheet or chapter.
Exercise with workspace
<exercise workspace="2.5in">
<statement>...</statement>
</exercise>
Add
workspace="2.5in" to an exercise inside a worksheet to leave blank space for student work when the worksheet is printed. Adjust the measurement to suit the problem.
Interactive Questions.
True / False
<exercise xml:id="ex-tf">
<title> Exercise Title </title>
<statement correct="no">
<p> A statement that might be true or false. </p>
</statement>
<feedback>
<p> Why the statement is true or false. </p>
</feedback>
</exercise>
The true and false indicators are
correct="yes" and
correct="no", respectively goes directly inside the
<statement> tag.
Multiple-Choice & Multiple-Answer
<exercise xml:id="ex-mc">
<title> Exercise Title </title>
<statement> Problem Statement </statement>
<choices randomize="yes">
<choice>
<statement> Distractor. </statement>
<feedback> Why this is wrong. </feedback>
</choice>
<choice correct="yes">
<statement> Correct answer. </statement>
<feedback> Why this is right. </feedback>
</choice>
<choice>
<statement> Distractor. </statement>
<feedback> Why this is wrong. </feedback>
</choice>
</choices>
</exercise>
When exactly one
<choice> has
correct="yes", it is a multiple-choice question. When more than one
<choice> has
correct="yes", it is a multiple-answer question. Optional
randomize="yes" on
<choices> shuffles the order.
Cardsort-Matching
<exercise label="chkpt-matching">
<title> Exercise Title </title>
<statement> Problem Statement </statement>
<feedback> General Feedback </feedback>
<cardsort>
<match>
<premise> Item 1 </premise>
<response> Target 1 </response>
</match>
<match>
<premise> Item 2 </premise>
<response> Target 2 </response>
</match>
<match>
<premise> Item 3a </premise>
<premise> Item 3b </premise>
<premise> Item 3c </premise>
<response> Target 3 </response>
</match>
<match>
<premise> Distractor Item </premise>
</match>
<match>
<response> Distractor Target </response>
</match>
</cardsort>
</exercise>
Clickable Area
<exercise label="chkpt-fill-in-the-blank">
<title> Exercise Title </title>
<statement> Problem Statement </statement>
<areas>
<p>
Non-Clickable Text *
<area> Correct Clickable Item 1 </area> *
<area> Correct Clickable Item 2 </area> *
<area correct="no"> Incorrect Clickable </area> *
<area> Correct Clickable Item 3 </area> *
<area correct="no"> Incorrect Clickable </area> *
</p>
</areas>
<feedback> General Feedback </feedback>
</exercise>
Links & Cross-references.
External link
<url href="https://abc.com">
click here
</url>
Internal cross-reference
<xref ref="def-x"/>
<xref ref="def-x" text="title"/>
<xref ref="def-x" text="custom">see here</xref>
The target must have an
xml:id. Default link text is auto-generated (e.g., βDefinition 3.1β);
text="title" uses the targetβs title;
text="custom" lets you write your own link text between the opening and closing tags.
Figures.
Tables.
Minimal table
<tabular>
<row>
<cell>A</cell>
<cell>B</cell>
</row>
<row>
<cell>C</cell>
<cell>D</cell>
</row>
</tabular>
<tabular>
<row header="yes">
<cell>Name</cell>
<cell>Value</cell>
</row>
<row>
<cell>...</cell>
<cell>...</cell>
</row>
</tabular>
Table with borders and column widths
<tabular top="minor" bottom="minor"
left="minor" right="minor">
<col width="30%" halign="center"/>
<col width="70%"/>
<row header="yes">
<cell>Name</cell>
<cell>Description</cell>
</row>
<row>
<cell>...</cell>
<cell>...</cell>
</row>
</tabular>
Border options:
none,
minor,
medium,
major. Alignment options:
left,
center,
right.