Hi @peterlewis,
Databricks notebooks support LaTeX mathematical notation inside %md (markdown) cells. The rendering engine uses MathJax, so standard LaTeX math syntax works. Here is a rundown of how to use it and some common patterns.
INLINE MATH
Wrap your expression with single dollar signs or backslash-parenthesis delimiters:
%md
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ and applies when $a \neq 0$.
Both $...$ and \(...\) work for inline expressions.
DISPLAY (BLOCK) MATH
For centered, standalone equations use double dollar signs or backslash-bracket delimiters:
%md
$$
E = mc^2
$$
Or equivalently:
%md
\[
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\]
COMMON LATEX COMMANDS THAT WORK IN %md CELLS
Here are frequently used commands:
Fractions: \frac{a}{b}
Square root: \sqrt{x} or \sqrt[n]{x}
Subscript: x_i or x_{ij}
Superscript: x^2 or x^{n+1}
Greek letters: \alpha, \beta, \gamma, \theta, \sigma
Summation: \sum_{i=1}^{n} x_i
Product: \prod_{i=1}^{n} x_i
Integral: \int_a^b f(x)\,dx
Limit: \lim_{x \to \infty} f(x)
Matrix: \begin{bmatrix} a & b \\ c & d \end{bmatrix}
Aligned eqs: \begin{aligned} ... \end{aligned}
MULTI-LINE ALIGNED EQUATIONS
%md
$$
\begin{aligned}
f(x) &= x^2 + 2x + 1 \\
&= (x + 1)^2
\end{aligned}
$$
USING displayHTML FOR MORE CONTROL
If you need rendering outside of a markdown cell (for example, inside a Python cell or with custom MathJax configuration), you can use displayHTML:
displayHTML("""
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<p>Inline: \\( e^{i\\pi} + 1 = 0 \\)</p>
<p>Display:</p>
$$\\frac{d}{dx}\\left( \\int_0^x f(t)\\,dt \\right) = f(x)$$
""")
Note the double backslashes in the Python string to escape the LaTeX backslashes.
TROUBLESHOOTING TIPS
1. If equations render as raw text, make sure the cell starts with %md on the very first line (no leading spaces or blank lines before it).
2. If you are using a notebook-scoped library that overrides the default JavaScript environment, it can interfere with MathJax. Try restarting the notebook session.
3. Dollar signs intended as literal currency symbols can accidentally trigger math mode. Escape them with a backslash: \$ to display a literal dollar sign.
4. Very long or complex LaTeX (e.g., large tikz diagrams) is not supported because MathJax handles math typesetting, not full LaTeX document compilation.
5. In the new notebook editor, make sure you are viewing the rendered output of the markdown cell (click outside the cell or press Esc) rather than the raw editing view.
DOCUMENTATION REFERENCE
The official docs confirm that %md cells support "text, images, and mathematical formulas and equations":
https://docs.databricks.com/en/notebooks/notebooks-code.html
For a full list of supported LaTeX math commands, refer to the MathJax documentation:
https://docs.mathjax.org/en/latest/input/tex/macros/index.html
If you can share more details about what specifically you are trying to render or any error you are seeing, I am happy to help with a more targeted example.
* This reply used an agent system I built to research and draft this response based on the wide set of documentation I have available and previous memory. I personally review the draft for any obvious issues and for monitoring system reliability and update it when I detect any drift, but there is still a small chance that something is inaccurate, especially if you are experimenting with brand new features.
If this answer resolves your question, could you mark it as "Accept as Solution"? That helps other users quickly find the correct fix.