Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up
Scientific web 7 min

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-course> ├── <mp-meta> │ ├── <mp-doc-title> │ ├── <mp-author> │ └── <mp-date> ├── <mp-toc> ← optional, auto table of contents ├── <mp-chapter> │ ├── <mp-title> │ ├── <mp-section> │ │ ├── <mp-title> │ │ ├── <mp-definition> │ │ ├── <mp-theorem> │ │ ├── <mp-exercise> │ │ └── ... │ └── <mp-subsection> │ └── ... └── <mp-chapter> └── ...
Auto-wrapping If you place pedagogical content (<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

AttributeValuesDescription
langfr | en | de | esLanguage of auto labels (Definition / Theorem / Example…)
themeocean · foret · lavande · corail · rose · ardoise · sepia · nuit · minuit · original · classiqueInitial color palette (default ocean)
theme-pickeron | offShow or hide the floating theme-switch button
navigationauto | on | offBottom navigation bar (default auto = on if there's at least one <mp-blank>)
creditvisible | hidden«Built with sarmate.net» link (default visible — hideable in paid plans)
vartable-scalenumerisch (0.2 – 3) oder compact | normal | largeDefault size for all child <mp-vartable> (overridable per table)
exercise-headingstacked | inline«Exercise 1 : Title» on one line (inline) or stacked (default stacked)
HTML
<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>.

HTML
<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:

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.

HTML
<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>
Editor tip In the online editor, the Chapter / Section / Subsection button inserts a pre-filled skeleton with a helper comment «Insert your sections here (mp-section)» that reminds you to respect the hierarchy. Handy when coming from LaTeX where \section / \subsection are siblings.

<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.

AttributeValuesDescription
depth1 | 2 | 31 = chapters only · 2 = + sections · 3 = + subsections (default 3)
titleFree textReplaces the default «Table of contents» label
layoutsidebarAnchors the TOC as a sidebar (active-section highlight on scroll)
HTML
<mp-toc depth="3"></mp-toc>

Complete example

Here's a minimal structure: header + TOC + one chapter with two sections.

HTML
<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.