Convert markdown to LaTeX
Paste markdown or open an .md file, and the LaTeX appears as you type. Math in dollar signs is kept exactly as written, and the file loads only the packages it uses.
How to use it#
- Paste or type your markdown into the box, or open an .md file with Open .md file or by dropping it on the box.
- Choose a whole file that compiles as it is, or the body alone to paste into a document of your own.
- Pick the margins, what a # heading becomes, how code blocks are written, whether display math is numbered, and whether headings are numbered.
- Read the notes for anything LaTeX cannot take as written, then copy the LaTeX or download the .tex file.
What each piece of markdown becomes#
Headings become sections, one level apart: # is \section, ## is \subsection, and so on down to \subparagraph. Bold and italic become \textbf and \emph, inline code becomes \texttt, and strikethrough becomes \sout. Lists become itemize and enumerate, nested as deep as you wrote them, and a numbered list that starts at 3 still starts at 3. Task lists get a crossed or empty box.
Tables become a tabular with the booktabs rules, keeping the left, centre, and right alignment from the divider row. Links become \href, bare addresses become \url, a picture alone in its paragraph becomes a centred figure with its alt text as the caption, and a block quote becomes a quote environment. Footnotes written as [^1] go in where they are referred to.
Every character LaTeX treats as a command, such as %, &, $, #, and _, is escaped in running text, so "50% of $5" prints as written instead of starting a comment. Straight quotes become the opening and closing quotes LaTeX expects.
Tables and code that fit the page#
A tabular never wraps, so a table of sentences pasted from notes or a chat runs off the right edge of the PDF. A table too wide for the page goes in tabularx instead, where the columns of long text wrap, each given room by how much it holds, and short columns keep to one line. A table of many short numbers steps down to \small, and when even that is too wide it splits into tabulars of whole columns, stacked, with a short first column repeated in each so every row keeps its name. Shrinking it with \resizebox would fit the width but leave the numbers too small to read. A table longer than most of a page goes in longtable, or xltabular when it also wraps, so it breaks across pages with its header repeated.
verbatim never breaks a line either, so a code line wider than the page goes in fvextra's Verbatim, which wraps it with a mark where it carries on. A long path, address, or hash in the text gets places to break after its slashes and dots, \url breaks anywhere through xurl, and a picture alone in its paragraph is held to the page's height as well as its width. Each of these is used only where the markdown needs it, so a short note loads none of them.
Math is passed through untouched#
Anything between single dollar signs is inline math and anything between double dollar signs is display math, the same rule most markdown editors and note apps use. Both are copied into the LaTeX character for character, so subscripts, \frac, and \begin{aligned} inside them arrive as you typed them. \( \) and \[ \] work too, and so does a code block marked math. The brackets are how an answer copied from an AI chat usually writes its math.
Prices are not mistaken for math. A dollar sign followed by a space, or a closing one followed by a digit, is left as text, so "$5 and $10" comes out as two prices. To write a dollar sign that would otherwise open math, put a backslash before it.
Display math is unnumbered by default, set in \[ \]. Choose Numbered and each display becomes an equation environment, numbered (1), (2), and so on down the right margin, ready for a \label inside it. Several lines split by \\ go in gather instead, one line each, and math already written in an environment such as align is left as it is.
LaTeX written into the markdown#
Markdown written for LaTeX often has LaTeX in it already: a citation, a cross-reference, a page break. A command followed by its arguments, such as \cite{smith2020}, \ref{fig:results}, or \underline{this}, goes into the LaTeX as you wrote it, and so does a common command that takes none, such as \newpage or \tableofcontents on a line of its own. A \begin{…} block, such as an align or a tabular, passes through whole.
A backslash that does not start a command stays text, so a path like "C:\Users\me" prints as written. Citations need a bibliography, which a converted file does not set up, so the notes say when the body cites anything.
A whole file, or the body for your own template#
Whole file gives a document that compiles as it is: a document class, the font setup, the packages the body needs and no others, and the body between \begin{document} and \end{document}. A note with no links does not load hyperref, and one with no tables does not load booktabs. Narrow margins, the default, set 2 cm on every side with geometry, about what a word processor leaves; Standard keeps the class's own, which are much wider. Text size goes to the class as well. article takes only 10, 11, or 12pt, so any other size, such as 14pt, sets the file in KOMA-Script's scrartcl, which takes any size, with its headings kept in the serif of the body text.
Body only gives what goes inside a document you already have, such as a thesis template or a journal class. The packages it needs are listed in a comment at the top, so you can check them against your preamble before pasting.
If the markdown starts with a front matter block between two --- lines, its title, author, and date become the title block. Otherwise, choosing Title for # headings turns the first one into the title and the ## headings under it into sections. Chapter switches the file to the report class, which is the one that has chapters.
What LaTeX cannot take as written#
Raw HTML has no LaTeX equivalent, so tags such as <div> or <kbd> are left out and the words inside them kept. A picture given as a web address cannot be fetched while compiling, and pdfLaTeX includes only PNG, JPG, and PDF pictures, so an SVG badge or a GIF has to be saved and converted first. Each of these is named in the notes beside the result.
Symbols typed as characters, such as "↔", "≤", or a Greek "α", are written as the commands that draw them, \leftrightarrow, \leq, and \alpha, since pdfLaTeX has no character for them. Box drawing, the lines of a folder tree in a code block, prints through the pmboxdraw package, in a listings block as well as a verbatim one. The notes name any character left that pdfLaTeX cannot print, such as an emoji or Chinese, which LaTeX to PDF shows as a boxed question mark rather than stopping. The file loads fontspec under XeLaTeX and LuaLaTeX, so compiling with either of those prints them, given a font that has them.
Frequently asked questions#
Is my writing uploaded anywhere?
#
No. The conversion runs in this tab and nothing is sent to a server, so a draft paper or private notes stay on your device.
Will the LaTeX compile?
#
Yes, with pdfLaTeX, XeLaTeX, or LuaLaTeX, in any LaTeX editor, online or installed, or straight away in LaTeX to PDF, which compiles it in your browser. Every package it loads is part of a standard TeX distribution. The notes beside the result name anything that would stop it compiling, such as a picture given as a web address or a character pdfLaTeX cannot print.
What should a # heading become?
#
Section suits notes and articles, where # is the largest heading inside a document. Chapter suits a book or thesis, and switches the file to the report class. Title suits a markdown file whose first # line is the name of the whole piece: that line becomes the title, and the ## headings become sections.
Verbatim or listings for code?
#
Verbatim prints the code in a typewriter font exactly as written and needs no package, unless a line is wider than the page, when it goes in fvextra's Verbatim, which wraps it. Listings adds a frame, wraps long lines, and highlights keywords for the languages it knows, such as Python, Java, C, C++, SQL, and Bash, taken from the language after the opening backticks. It has no JavaScript or TypeScript, so those come out framed but plain.
Does it keep my math as written?
#
Yes. Everything between $ signs, $$ signs, \( \), or \[ \] is copied over character for character. Only the text around it is escaped.
How do I convert an .md file to a .tex file?
#
Press Open .md file, or drop the file on the box, and its text goes in to convert. It opens .md, .markdown, and .txt files up to 5 MB. Download .tex then saves the LaTeX under the same name, so notes.md comes back as notes.tex. The file is read in this tab, not uploaded.
Can I convert just a markdown table to LaTeX?
#
Yes. Paste the table alone and choose Body only, and you get a tabular with booktabs rules, or a tabularx when its text is too wide for the page, ready to paste into your document, with the one package it needs named in a comment above it. The colons in the divider row set each column to left, centre, or right.
Can I put LaTeX commands in my markdown?
#
Yes. A command with its arguments, such as \cite{key} or \label{eq:one}, and a \begin{…} to \end{…} block go into the LaTeX as written. So do common commands with no argument, such as \newpage. Everything else is escaped, so a stray backslash prints rather than breaking the file.
Can the equations be numbered?
#
Yes. Set Display math to Numbered, and every display, written between $$ signs or \[ \], becomes a numbered equation. Put \label{eq:name} inside one and \eqref{eq:name} in the text to refer to it by number.
Does it read front matter?
#
Yes, the title, author, and date fields of a front matter block at the top of the file, which become the title block. Other fields are settings for other programs and are left out.
Can I see what the markdown looks like first?
#
The markdown to HTML converter shows a live preview of the same markdown, which is a quick way to check a table or a list before converting it here.