How to align multiple equations in Marp (a tool to convert .md files into PDF)?

835 Views Asked by At

I've been trying to find a solution to align multiple equations in Marp (a tool to convert .md files into PDF) but can't find a solution.

I tried using \begin{equation}......\end{equation}(which apparently is not supported in Marp), and various combinations of $....$, $$....$$ but can't find a hack.

I'm trying to generate something like : 1 but instead I get this: 2

here is my code:

$$ E_{\theta}[\theta] = \int_{\theta}\theta\ p(\theta)\ d\theta $$
$$ E_D[E_{\theta}[\theta|D]] = \int_D\Bigg\{\int_{\theta}\theta\ p(\theta|D)\ d\theta \Bigg\}\ p(D)\ dD $$

What am I missing. There is a solution for R Markdown, but I'm not sure if Marp supports R Markdown. I also can't find a way to import packages in Marp too.

Please help. Thanks.

1

There are 1 best solutions below

0
On
  1. Put $$ at the start and end of the equations - but not after each each equation.
  2. Then separate each equation with \\.
  3. Put an & before each equals (where you want it to align)
  4. Use the \begin{aligned} and \end{aligned} function.

Here is a simple example:

$$\begin{aligned} 1 + 2 + 3 + 4 &= 10 \\
20 \times 80 &= 1600 \end{aligned}$$

Here is your example in this format:

$$\begin{aligned}E_{\theta}[\theta] &= \int_{\theta}\theta\ p(\theta)\ d\theta \\
E_D[E_{\theta}[\theta|D]] &= \int_D\Bigg\{\int_{\theta}\theta\ p(\theta|D)\ d\theta \Bigg\}\ p(D)\ dD \end{aligned}$$

These these examples when rendered:

math-alignement-results