Markdown to LaTeX Converter
Paste Markdown or an AI answer and get a complete .tex file that compiles with pdfLaTeX, XeLaTeX or LuaLaTeX, or open it straight in Overleaf. Nothing is uploaded.
Markdown
722 characters32 lines
LaTeX
% !TEX program = pdflatex
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{fvextra}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue}
\title{Notes on linear regression}
\author{}
\date{}
\begin{document}
\maketitle
A linear model predicts $y$ from $x$ with a straight line, $\hat{y} = \beta_0 + \beta_1 x$.
\section*{Least squares}\label{sec:least-squares}
The coefficients minimise the sum of squared errors:\footnote{Gauss described the method in 1809.}
\[
\hat{\beta}_1 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^{n} (x_i - \bar{x})^2}
\]
\section*{Checking the fit}\label{sec:checking-the-fit}
\begin{enumerate}
\item Plot the residuals against $\hat{y}$
\item Look for curves or a funnel shape
\item Compare $R^2$ between models
\end{enumerate}
\begin{table}[htbp]
\centering
\begin{tabularx}{\linewidth}{>{\raggedright\arraybackslash}X >{\raggedleft\arraybackslash}X >{\raggedleft\arraybackslash}X}
\toprule
\textbf{Model} & \textbf{$R^2$} & \textbf{RMSE} \\
\midrule
Linear & 0.82 & 3.1 \\
Quadratic & 0.91 & 2.2 \\
\bottomrule
\end{tabularx}
\end{table}
\begin{Verbatim}[breaklines, breakanywhere, fontsize=\small, frame=single, framesep=2mm]
import numpy as np
slope, intercept = np.polyfit(x, y, 1)
\end{Verbatim}
\begin{quote}
A high $R^2$ does not prove that the line is the right shape.
\end{quote}
\end{document}
Compile with pdfLaTeX1,578 characters
What it handles
- Compiles as it is
- The preamble loads only the packages the document needs, and special characters such as
%,&and_are escaped. - Math left untouched
$…$and$$…$$formulas are copied into the document exactly as written.- Tables with booktabs
- Tables use
tabularxwith booktabs rules and keep the alignment of every column. - Code and footnotes
- Code blocks become line-wrapping
Verbatimblocks, and footnotes become\footnote. - Chinese and Japanese
- Chinese text gets XeLaTeX with ctex and Japanese gets LuaLaTeX with luatexja, chosen from the text itself.
- Title and sections
- A single top heading becomes the title; the other headings become sections, unnumbered unless you switch numbering on.
Writing LaTeX math in Markdown
Most Markdown apps read formulas between dollar signs: one $ on each side for a formula inside a sentence, two for a formula on its own lines.
The area of a circle is $A = \pi r^2$.
$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$
GitHub, Jupyter notebooks, Obsidian, Typora, the VS Code preview and R Markdown all show these formulas, and GitHub also accepts a math code block.
Converting with Pandoc
pandoc notes.md -s -o notes.tex
-s writes a complete document with a preamble; leave it out to get only the body.
Questions and answers
How do I convert Markdown to LaTeX?
Paste the Markdown above, then download the
.tex file or open it in Overleaf. The document compiles with the engine shown under the output.How do I write LaTeX math in Markdown?
Put a formula inside a sentence between single dollar signs, as in
$E = mc^2$, and a formula on its own line between double dollar signs. GitHub, Jupyter, Obsidian and Typora all render them.Which engine should I compile with?
pdfLaTeX for English and other Latin-script text, XeLaTeX for Chinese and LuaLaTeX for Japanese. The converter picks one from the text and writes a matching preamble.
What happens to images?
Images are included with
\includegraphics. Save each linked image next to the .tex file under the name in the comment above it, such as image-1.png.Why were emoji removed?
Standard LaTeX fonts have no emoji, and one emoji would stop the document from compiling, so they are removed and listed above the output.
Should I write in Markdown or LaTeX?
Markdown is quicker to write and read and suits notes, documentation and most reports. LaTeX gives exact control over typesetting, references and complex math, which matters for papers and theses. Many people draft in Markdown and convert at the end.
Is my document uploaded anywhere?
No. The conversion runs in your browser. Only Open in Overleaf sends the LaTeX to Overleaf, and only when you click it.
Related tools
- Markdown to PDFSave a PDF with selectable text, formulas, highlighted code and page numbers.
- Markdown to WordDownload an editable .docx with Word headings, tables and equations.
- Markdown to HTMLClean, safe HTML for a site or blog, or a complete styled page.
- Markdown to Rich TextCopy formatted text that pastes into Google Docs, Word and email.
- Markdown to Plain TextRemove #, ** and backticks and keep lists, links and tables readable.
- Markdown to SlackSlack's mrkdwn for messages, bots and webhooks.