Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up
Practical 10 min

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

  1. Import the file If your file is not in your online drive, click + Import file and pick your .tex (plus, if applicable, the .bib and image folders — select all at once).
  2. 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).
  3. 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.html in the same folder.
  4. 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

LaTeXmathpad HTMLNote
\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> + PNGServer compile to PNG, embedded in mp-figure
\begin{pspicture}<mp-figure> + PNGidem 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
Custom commands The converter recognizes classic patterns from a wide range of French school templates (APMEP, MPSI, Terminale spé, ST2S, with their variants of exercise packages, theorem themes, etc.). If a \newcommand looks exotic, let us know the patterns you use — the converter hardens project by project.

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.

When to rewrite a tikz as JSXGraph? If the figure is simple (function curve, two points, a circle), rewriting it as mp-jsxgraph gives an even lighter result, sharp at any zoom, editable later. For a complex figure (multiple layers of tikz decorations, hatchings, markers), the PNG produced by the converter remains the most solid solution.

Known limits

If conversion fails The modal shows an error message with an expandable debug block (server paths, offending package, error line). Common cause: an unrecognized package in the preamble — remove it from the .tex and retry, or send us the pattern so the converter can learn it.

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:

Configure MCP for Sarmate A dedicated guide walks you through plugging Claude, ChatGPT, Gemini, Mistral or Cursor into your Sarmate drive: full MCP documentation for Sarmate (Bearer token, per-client setup, compatible tools).
  1. 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.
  2. 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.
  3. 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.
Which mode to choose? The AI should offer you the three modes before launching the conversion, with the order of magnitude of its own token cost (depends on the model: Claude, GPT, Le Chat…). You decide based on your budget. When in doubt: hybrid gives the best cost/quality ratio.

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.