Skip to main content

Subsection 6.3.1 PreTeXt Structure & Non-Block XML Elements

202606012315 | pretext xml authoring syntax
A quick-reference guide to PreTeXt document structure, inline styling tags, mathematics markup, category overviews, and project authoring conventions.

Document Structure.

PreTeXt documents follow a strict hierarchical organization: pretext contains docinfo and book (or article), which hierarchically nests part, chapter, section, subsection, and division blocks like introduction, paragraphs, and conclusion.
Preview:
<pretext>
  <docinfo> ... </docinfo>
  <book xml:id="my-book">
    <title>Book Title</title>
    <chapter xml:id="ch-demo">
      <title>Chapter Title</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>

Inline Elements and Tags.

Inline elements are used within paragraphs (p) to style text, emphasize notation, or attach metadata.
Table 6.3.1. Common Inline Elements
Element Usage Example Output
m Inline Math (LaTeX) \(E = mc^2\)
tag Semantic Tags (Metadata Pill) quantum mechanics
c Inline Code / Verbatim git status
em Emphasis (Cooler Blue / Italic) Nuance
term Defined 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Β 6.3
url Hyperlink PreTeXt Official Site
Preview:
In this passage we define a topological manifold with dimension \(n\text{,}\) noting that boundary conditions require careful analysis (see Key Principle). Metadata includes topology and geometry.
<p>
  In this passage we define a <term>topological manifold</term>
  with dimension <m>n</m>, noting that <strong>boundary conditions</strong>
  require careful analysis (see <alert>Key Principle</alert>).
  Metadata includes <tag>topology</tag> and <tag>geometry</tag>.
</p>

Mathematics & LaTeX Environments.

PreTeXt supports mathematical expressions and equations using standard LaTeX syntax parsed through MathJax.
  • Inline Math.
    Use m>...</m for inline LaTeX formulas such as \(\psi(x) = \langle x | \psi \rangle\) or \(e^{i\pi} + 1 = 0\text{.}\)
  • Single-Line Equations.
    Use md with mrow for single-line display equations (the standalone me and men tags are deprecated in recent PreTeXt releases). Add number="yes" on md or an xml:id on mrow to enable numbering.
    Preview:
    \begin{gather} i\hbar\frac{\partial}{\partial t}\Psi(\mathbf{r}, t) = \hat{H}\Psi(\mathbf{r}, t)\tag{6.3.1} \end{gather}
    <md number="yes">
      <mrow xml:id="eq-schrodinger">i\hbar\frac{\partial}{\partial t}\Psi(\mathbf{r}, t) = \hat{H}\Psi(\mathbf{r}, t)</mrow>
    </md>
    
  • Aligned Display Equations.
    Use md with multiple mrow lines and alignment tabs \amp (or &amp; in raw XML):
    Preview:
    \begin{align*} \nabla \cdot \mathbf{E} \amp = \frac{\rho}{\epsilon_0}\\ \nabla \times \mathbf{E} \amp = -\frac{\partial \mathbf{B}}{\partial t}\\ \nabla \cdot \mathbf{B} \amp = 0\\ \nabla \times \mathbf{B} \amp = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{align*}
    <md>
      <mrow>\nabla \cdot \mathbf{E} \amp = \frac{\rho}{\epsilon_0}</mrow>
      <mrow>\nabla \times \mathbf{E} \amp = -\frac{\partial \mathbf{B}}{\partial t}</mrow>
      <mrow>\nabla \cdot \mathbf{B} \amp = 0</mrow>
      <mrow>\nabla \times \mathbf{B} \amp = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}</mrow>
    </md>
    

Comprehensive Element Categories.

PreTeXt organizes document components into clear structural, mathematical, computational, and backmatter layers:
Table 6.3.2. PreTeXt Element Categories
Category Elements Description
Structure & Divisions pretext, book, part, chapter, section, subsection, appendix High-level hierarchical document organization and divisions.
Divisional Blocks introduction, conclusion, paragraphs Opening context, summaries, and unnumbered paragraphs groupings.
Semantic Blocks theorem, lemma, definition, example, axiom, remark, project Formal mathematical environments defined in Chapter 15 (see dedicated Blocks subsection).
Technical & Figures program, image, table, tabular, figure, sidebyside Code listings, data tables, images, PreFigure widgets, and side-by-side layouts.
Lists ul, ol, dl Unordered bulleted, ordered numbered, and description/definition lists.
Backmatter & Indexing idx, references, biblio, glossary, colophon Alphabetical index terms, citations, glossary items, and document metadata.

Project Conventions & Metadata.

Custom styles, metadata formats, and authoring standards used across this networked Zettelkasten:
  • Note Metadata Blocks.
    Every note includes a metadata block containing a timestamp Note ID and topic tags. This can be authored in an introduction, blockquote, or paragraphs.
    Preview:
    202606012315 | quantum mechanics, linear algebra | Interactive:πŸ”— Graph Node
    <!-- Introduction Metadata Block -->
    <introduction>
      <p>
        <tag>202606012315</tag> |
        <tag>quantum mechanics</tag> <tag>linear algebra</tag>
      </p>
    </introduction>
    
    <!-- Or using a Blockquote (always visible) -->
    <blockquote>
      <p>
        <tag>202606012315</tag> |
        <tag>quantum mechanics</tag>
      </p>
    </blockquote>
    
  • Note IDs & Glassmorphic Pills.
    Use YYYYMMDDHHMM or YYYYMMDDNNNN timestamps. The first tag in an introduction or blockquote is automatically styled as a glowing purple glassmorphic Note ID badge. Subsequent tags render as cyan topic pills.
  • Conclusion Metadata & Networked Links.
    Conclusions use alert tags for metadata labels (e.g. Linked Notes, References), which render as glassmorphic pills and populate the D3.js knowledge graph.
    Preview:
    πŸ–‡οΈ Linked Notes: SectionΒ 6.3
    πŸ”– References: ChapterΒ 6
    <conclusion>
      <p>
        πŸ–‡οΈ <alert>Linked Notes:</alert> <xref ref="sec-pretext" />
      </p>
      <p>
        πŸ”– <alert>References:</alert> <xref ref="ch-cheat-sheets" />
      </p>
    </conclusion>
    
  • List Headings & Assemblages.
    Titles within list items (li><title>...</title></li) are styled in prominent cyan heading typography. Use assemblage blocks for standalone concept takeaways and key formulas.