Structure of a mathpad document
Every mathpad document follows a simple, semantic hierarchy: a <mp-course> root, a <mp-meta> header block, then chapters and sections. This page describes each structure tag and its attributes — the common skeleton of all your documents.
Anatomy of a document
Here is the typical hierarchy of a mathpad document — simplified. Mandatory items are in bold, optional ones in normal weight:
<mp-definition>, <mp-exercise>…) directly in <body> without wrapping it in <mp-course> / <mp-chapter>, mathpad.js wraps it automatically so it inherits theme, navigation, and numbering systems. You can start with very few tags. <mp-course> — the root
Wraps the entire document. Enables auto-numbering (Definition 1, Theorem 2…), theme system, bottom navigation bar and theme picker.
Key attributes
| Attribute | Values | Description |
|---|---|---|
| lang | fr | en | de | es | Language of auto labels (Definition / Theorem / Example…) |
| theme | ocean · foret · lavande · corail · rose · ardoise · sepia · nuit · minuit · original · classique | Initial color palette (default ocean) |
| theme-picker | on | off | Show or hide the floating theme-switch button |
| navigation | auto | on | off | Bottom navigation bar (default auto = on if there's at least one <mp-blank>) |
| credit | visible | hidden | «Built with sarmate.net» link (default visible — hideable in paid plans) |
| vartable-scale | numerisch (0.2 – 3) oder compact | normal | large | Default size for all child <mp-vartable> (overridable per table) |
| exercise-heading | stacked | inline | «Exercise 1 : Title» on one line (inline) or stacked (default stacked) |
<mp-course lang="en" theme="ocean" exercise-heading="inline" vartable-scale="0.85">
...
</mp-course>
<mp-meta> — document header
Generates a large title block with gradient (equivalent to \maketitle in LaTeX). Accepts <mp-doc-title>, optional <mp-author>, optional <mp-date>.
<mp-meta>
<mp-doc-title>Linear functions</mp-doc-title>
<mp-author>Firstname Lastname</mp-author>
<mp-date>31-05-2026</mp-date>
</mp-meta>
<mp-chapter>, <mp-section>, <mp-subsection>
Three hierarchy levels with automatic numbering:
<mp-chapter>— top level, roman numbering (I, II, III…)<mp-section>— arabic-numbered per chapter (1, 2, 3…)<mp-subsection>— numbered chap.sec.sub (1.1.1, 1.1.2…)
Each level takes an <mp-title> as its first child. Important: <mp-section> must be a direct child of an <mp-chapter> (not a sibling), otherwise it won't appear in the table of contents.
<mp-chapter><mp-title>Function analysis</mp-title>
<mp-section><mp-title>Domain of definition</mp-title>
<!-- content -->
</mp-section>
<mp-section><mp-title>Variations</mp-title>
<mp-subsection><mp-title>Derivative computation</mp-title>
<!-- ... -->
</mp-subsection>
</mp-section>
</mp-chapter>
<mp-toc> — automatic table of contents
Generates a navigable table of contents from the existing <mp-chapter> / <mp-section> / <mp-subsection>. Works with KaTeX formulas in titles.
| Attribute | Values | Description |
|---|---|---|
| depth | 1 | 2 | 3 | 1 = chapters only · 2 = + sections · 3 = + subsections (default 3) |
| title | Free text | Replaces the default «Table of contents» label |
| layout | sidebar | Anchors the TOC as a sidebar (active-section highlight on scroll) |
<mp-toc depth="3"></mp-toc>
Complete example
Here's a minimal structure: header + TOC + one chapter with two sections.
<mp-course lang="en" theme="ocean">
<mp-meta>
<mp-doc-title>Probability distributions</mp-doc-title>
<mp-author>Firstname Lastname</mp-author>
<mp-date>31-05-2026</mp-date>
</mp-meta>
<mp-toc depth="2"></mp-toc>
<mp-chapter><mp-title>Discrete distributions</mp-title>
<mp-section><mp-title>Binomial distribution</mp-title>
<!-- definitions, theorems, exercises… -->
</mp-section>
<mp-section><mp-title>Poisson distribution</mp-title>
<!-- ... -->
</mp-section>
</mp-chapter>
</mp-course>
Ready to try mathpad?
Create your first interactive scientific HTML document in the online editor, or import your existing LaTeX course in one click.