Skip to main content

Section 7.2 PreTeXt Cheat Sheet

202606012315 | pretext xml authoring
A comprehensive guide to PreTeXt XML elements and structure for authoring mathematical content.

Subsection 7.2.1 Document Structure

PreTeXt documents follow a strict hierarchical organization.
<pretext>
  <docinfo> ... </docinfo>
  <book xml:id="my-book">
    <title>Book Title</title>
    <chapter xml:id="ch-demo">
      <title>Chapter</title>
      <section xml:id="sec-demo">
        <title>Section Title</title>
        <introduction>
          <p>
            <tag>202606012315</tag> |
            <tag>topic</tag>
          </p>
        </introduction>
        <subsection xml:id="sub-demo">
          <title>Subsection</title>
          <p>Content with <m>E=mc^2</m> and <xref ref="ch-demo"/>.</p>
        </subsection>
        <conclusion>
          <p>πŸ–‡οΈ <alert>Linked Notes:</alert> <xref ref="other-note"/></p>
        </conclusion>
      </section>
    </chapter>
  </book>
</pretext>

Subsection 7.2.2 Inline Elements and Tags

Inline elements are used within paragraphs (p) to style text or add semantics.
Table 7.2.1. Common Inline Elements
Element Usage Example
m Inline Math (LaTeX) \(E = mc^2\)
tag Semantic Tags (Metadata) quantum mechanics
c Inline Code/Verbatim git status
em Emphasis (Cooler Blue/Italic) Nuance
term Defining a term (Orange Gradient) Bivector
strong Strong emphasis (Prominent Cyan) Key Term
alert Metadata labels (Glassmorphic Pill) Warning!
em class="alert" Critical Emphasis (Blue Gradient) Important!
xref Cross-reference See SectionΒ 7.2
url Hyperlink PreTeXt
Note: In this project, tag elements are styled as glassmorphic pills.

Subsection 7.2.3 Mathematics

PreTeXt supports various math environments using standard LaTeX notation.
  • Inline Math.
    Use m>...</m for inline expressions.
  • Single Line Equations.
    Use md for equations. Single-line equations no longer use me or men (deprecated). Use @number="yes" on md for numbering.
                            <md number="yes">
        <mrow xml:id="eq-schrodinger">i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi</mrow>
    </md>
    
    Output:
    \begin{gather} i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi\tag{7.2.1} \end{gather}
  • Aligned Equations.
    Use md with mrow for multiple lines. Use \amp for alignment.
    <md>
      <mrow> \nabla \cdot \mathbf{E} \amp = \frac{\rho}{\epsilon_0} </mrow>
      <mrow> \nabla \cdot \mathbf{B} \amp = 0 </mrow>
    </md>
    
    Output:
    \begin{align*} \nabla \cdot \mathbf{E} \amp = \frac{\rho}{\epsilon_0} \\ \nabla \cdot \mathbf{B} \amp = 0 \end{align*}

Subsection 7.2.4 Common Blocks

Structural blocks organize content into logical units with specific styling.
<definition xml:id="def-unitary">
  <title>Unitary Operator</title>
  <statement>
    <p>An operator <m>U</m> is unitary if <m>U^\dagger U = I</m>.</p>
  </statement>
</definition>
Output:

Definition 7.2.2. Unitary Operator.

An operator \(U\) is unitary if \(U^\dagger U = I\text{.}\)
<theorem xml:id="thm-noether">
  <title>Noether's Theorem</title>
  <statement>
    <p>Every differentiable symmetry ... has a corresponding conservation law.</p>
  </statement>
</theorem>
Output:
<assemblage>
  <title>Key Concept</title>
  <p>Assemblages are used for boxed summaries (Glassmorphic in this theme).</p>
</assemblage>
Output:

Key Concept.

Assemblages are used for boxed summaries (Glassmorphic in this theme).

Subsection 7.2.5 Comprehensive Element Table

Table 7.2.4. PreTeXt Element Categories
Category Elements Description
Structure book, part, chapter, section High-level document organization
Blocks definition, theorem, example Semantic mathematical environments
Admonitions note, warning, insight, remark Side-bars or callout boxes
Technical program, image, table, figure Non-textual data, code, and graphics
Lists ul, ol, dl Unordered, ordered, and description lists
Backmatter idx, biblio, glossary, colophon Indices, references, and metadata

Subsection 7.2.6 Project Conventions

Custom styles and standards used in this Zettelkasten.
  • Note Metadata: Every note should include a metadata block (Note ID, Tags, etc.). This block can be placed in introduction, blockquote, aside, or paragraphs.
    <!-- Traditional Introduction -->
    <introduction>
      <p>
        <tag>202606012315</tag> |
        <tag>topic1</tag> <tag>topic2</tag>
      </p>
    </introduction>
    
    <!-- Alternative using Blockquote (Always visible, no title) -->
    <blockquote>
      <p>
        <tag>202606012315</tag> |
        <tag>topic1</tag>
      </p>
    </blockquote>
    
    Output (approximate):
    202606012315 | topic1, topic2 | PreFigure Demo:πŸ”— Interactive
  • Note IDs: Use YYYYMMDDNNNN or HHMM format. The first tag in a supported metadata block (Introduction, Blockquote, etc.) is automatically styled as a purple glassmorphic Note ID.
  • Conclusion Metadata: Conclusions use alert tags for metadata labels (e.g., Linked Notes, References), which are automatically styled as blue glassmorphic pills.
    <conclusion>
      <p>
        πŸ–‡οΈ <alert>Linked Notes:</alert> <xref ref="sec-topic" />
      </p>
      <p>
        πŸ”– <alert>References:</alert> <xref ref="biblio-item" />
      </p>
    </conclusion>
    
  • List Titles: Headings inside list items (e.g. li><title>...</title></li or li class="li"><title>...</title></li) are styled in prominent cyan with the heading font.
  • Assemblages: Use for primary takeaways or "atomic" notes within a section.