How do I enter groovy, typeset mathematics into Discourse?

Discourse at Mark's Math uses LaTeX snippets to input mathematics. This approach is very common among tools that aim to communicate mathematics. Thus, a very similar approach is taken by tools as diverse as Math.StackExchange (a forum), Obsidian (note taking software), Jupyter (a computational notebook), and more.

The basics of LaTeX

The LaTeX representation of some rather simple expressions are pretty close to what you'd expect, like

  • $x^2$ for x^2 or
  • $\sin(x^{12})$ for \sin(x^{12})

Already, though, we can see necessary evils like

  • dollar sign $delimeters$,
  • backslash \escapes, and
  • braced {grouping}.

Things get a bit more complicated as we move to formulae like

\int_{-\infty}^{\infty} e^{-\frac{1}{2} x^{2}} \, dx = \sqrt{2\pi}

which can be written in LaTeX as

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

There are some general principles, though:

  • Generally, mathematics is dollar-sign delimited:
    • single dollars for inline math like $\sin(x^2)$ for \sin(x^2) or
    • double dollars for display math like $$\int \sin(x^2) \, dx$$ for
\int \sin(x^2) \, dx
  • Functions and commands are indicated with a preceding backslash like
    • $\pi$ for \pi,
    • $\infty$ for \infty,
    • $\cos(x)$ for \cos(x),
    • $\frac{1}{12}$ for \frac{1}{12},
    • $\sum$ for \sum, as in
\sum_{n=1}^{\infty} \frac{1}{n^2} = -\frac{\pi^2}{6}.

Forum assistance

There are a couple of built in ways to get assistance on typesetting Latex expressions.

Finding code for given expresssions

You can cntrl-click or right-click on an expression to pull up a contextual menu to get all sorts of information on that expression - including the LaTeX source that produced it. If you try that for the expression above, for example, you can find the Show Math As > TeX Commands menu item like so:

The AI contextual menu

The AI contextual menu Screenshot 2026-01-07 at 10.18.15 AM provides access to a proofreading tool that focuses on mathematical content in particular. You can use it to assist with your LaTeX typesetting.

Suppose, for example, that you type in

integral_-inf^oo e^(-x^2 dx

This might seem close to right but, really, isn't proper LaTeX, nor even syntactically correct. If you process it through the proofreader, though, you get

$$\int_{-\infty}^{\infty} e^{-x^2} \, dx$$

which typesets beautifully!

Here are a couple before after screenshots:

Before

After

LaTeX in the markdown editor

Generally, LaTeX is just one more piece of markup you need to worry about when working with the Markdown editor. Let's think about the formula

If f(x) = e^{-x^2}, then

\int_{-\infty}^{\infty} f(x) \, dx = \sqrt{\pi}.

This whole post, up to here, could be entered

## LaTeX in the markdown editor

Generally, LaTeX is just one more piece of markup you need to worry about when working with the Markdown editor. Let's think about the formula

If $f(x) = e^{-x^2}$, then
$$\int_{-\infty}^{\infty} f(x) \, dx = \sqrt{\pi}.$$

Thus, LaTeX fits into markdown quite naturally.

LaTeX in the rich editor

It turns out that the rich editor doesn’t really like it when you type mathematics in directly. Instead, we can use the Screenshot 2026-01-07 at 10.18.22 AM to access the \sqrt{x} Insert Math menu item:

You might need to scroll down a bit to find the Insert Math menu item. Once you do so, though, a separate modal window should pop up where you can type in the math. You do not need the dollar signs; the modal will insert them for you. There’s a switch that allows you to specify block mode for displayed equation or not for inline.

The whole thing looks like so:

\int_{-\infty}^{\infty} e^{-x^2} \, dx

The modal does not currently have a proofread button. You can proofread the whole post, once you’ve got and the proofreader will process the mathematics, as well.

1 Like