Skip to content

Equations

MergDown2TeX converts Obsidian equations to LaTeX.


Syntax

Inline equation

Input:

The equation $E = mc^2$ is famous.

Output:

The equation $E = mc^2$ is famous.

Display equation

Input:

$$E = mc^2$$

Output:

\begin{equation}
E = mc^2
\end{equation}

Aligned equations

Input:

$$
\begin{aligned}
a &= b + c \\
d &= e + f
\end{aligned}
$$

Output:

\begin{equation}
\begin{aligned}
a &= b + c \\
d &= e + f
\end{aligned}
\end{equation}


Math packages

MergDown2TeX automatically includes:

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}

Examples

Example 1: Simple equation

Input:

The area of a circle is $A = \pi r^2$.

Output:

The area of a circle is $A = \pi r^2$.

Example 2: Numbered equation

Input:

$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

Output:

\begin{equation}
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
\end{equation}

Example 3: Matrix

Input:

$$
\begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}
$$

Output:

\begin{equation}
\begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}
\end{equation}


Equation numbering

Automatic numbering

\begin{equation}
E = mc^2
\end{equation}

Unnumbered equation

Input:

$$
E = mc^2
$$

Output:

\[
E = mc^2
\]

Custom numbering

Input:

$$
\begin{equation}
\label{eq:einstein}
E = mc^2
\end{equation}
$$

Output:

\begin{equation}
\label{eq:einstein}
E = mc^2
\end{equation}


Troubleshooting

Equation not rendering

Error:

Missing $ inserted

Solution: - Check for unmatched $ - Escape special characters: \$, \%, \# - Verify LaTeX syntax

Undefined control sequence

Error:

Undefined control sequence

Solution: - Check package is loaded - Verify command spelling - Add package to custom preamble


Next steps