Convert a .tex into mathpad
If you already have LaTeX courses, no need to rewrite everything: Sarmate reads your .tex and produces a complete mathpad HTML document — structure, definitions, theorems, exercises, bibliography, figures (compiled as PNG images). You get the responsive rendering, KaTeX, mp-vartable, Python in the browser, all without rewriting the course.
Run the conversion in 4 steps
- Import the file
If your file is not in your online drive, click + Import file and pick your
.tex(plus, if applicable, the.biband image folders — select all at once). - Open in the LaTeX editor
Click the file name — it opens in
mathpad_tex_edit.php. First click Compile to check the file compiles cleanly (otherwise the converter will also stumble). - Run the converter
In the compiler selector at the top, pick sarmateWeb (HTML), then click Compile. Sarmate reads the file, compiles tikz/pstricks/pgfplots figures, generates a new file
basename_sarmateweb.htmlin the same folder. - Open in the mathpad editor
A small notification appears with a link Open in the editor which loads the generated file in
mathpad_php_edit.php. There you polish what needs polishing, add a quiz, a scaled variation table, an interactive graph, a Python block.
What is converted automatically
| LaTeX | mathpad HTML | Note |
|---|---|---|
| \chapter{} | <mp-chapter> | with title in <mp-title> |
| \section{} / \subsection{} | <mp-section> / <mp-subsection> | Auto-numbered |
| \begin{definition} … \end | <mp-definition> | idem theorem, property, lemma, remark, method |
| \begin{exercise|exo|exercice} | <mp-exercise> + <mp-statement> | Corrections also captured (\corrige, \correction) |
| \begin{itemize|enumerate} | <ul> / <ol> | Standard HTML |
| \begin{tabular} | <table class="tp-table"> | Columns and rules kept |
| \begin{tikzpicture} | <mp-figure> + PNG | Server compile to PNG, embedded in mp-figure |
| \begin{pspicture} | <mp-figure> + PNG | idem pstricks |
| \begin{align*} / $...$ / $$...$$ | <mp-align> / $...$ / $$...$$ | Rendered by KaTeX in the browser |
| \footnote{} | <mp-footnote> | Gathered at the end of the chapter |
| \bibliography{ref} + .bib | <mp-bibliography> | Each entry → <mp-cite-entry> |
| \ref{} / \cite{} | <mp-ref target="..."> / <mp-cite ref="..."> | Internal and external references preserved |
Figures: PNG pipeline
A tikz/pstricks/pgfplots figure is isolated on the server inside a minimal LaTeX document, compiled to PDF, converted to PNG (200 DPI), and embedded in a <mp-figure> in the generated HTML. You get a sharp PNG image that matches pixel-for-pixel what your PDF shows, with the same font and colors.
Known limits
- Very exotic packages (e.g. self-modifying macros, hyperref PDF bookmarks) are bypassed — the converter skips them and leaves a
<!-- TODO -->comment. - Images with path (\includegraphics) must be uploaded next to the .tex, otherwise blank image.
- Very long file (> 5000 lines): PNG compilation can take several minutes.
- JSXGraph conversion tikz → mp-jsxgraph is not done automatically yet (manual).
Conversion via an AI (MCP)
You can trigger the same conversion from your AI assistant (Claude, ChatGPT, Mistral, Gemini, Cursor, Le Chat…) connected to your account through the Sarmate MCP server. Three modes available, with increasing token cost:
- Converter only — the AI calls the conversion and that's it, like the sarmateWeb (HTML) button described above. Almost no tokens consumed (just the tool call), fast, deterministic. Handles the majority of standard school math documents perfectly.
- Hybrid — the AI calls the converter first, then reads the generated HTML and improves it: it fixes KaTeX residuals, completes undetected patterns, adapts a section to your requirements. Token cost scales with polish depth — light for clean docs, heavier for docs with unusual environments. Best balance for most tricky cases.
- 100% AI — the AI does NOT call the converter — it reads the .tex source and produces the mathpad HTML entirely on its own. It first loads the
<mp-*>tag specification, then rewrites the full skeleton from scratch. Highest token cost (full HTML output) but useful for very exotic documents the converter likely won't handle.
Edit and enrich through the AI
Once you have the HTML file, you can ask your AI for any further task in free form: «Add a quiz after the intermediate value theorem», «Convert the first tikz into mp-jsxgraph», «Rewrite this remark as <mp-box style="info">», «Translate the course into English». The AI modifies the file directly in your Sarmate drive through MCP.
Run your first conversion
Upload your .tex into your Sarmate drive and click → HTML mathpad. In a few minutes, your course is in a responsive, interactive, phone-readable format.