22

I am trying to create a multi-line equation in RMarkdown. I have tried the following code, extracted from http://www.rstudio.com/ide/docs/authoring/using_markdown_equations,

$$
\begin{aligned}
  \dot{x} & = \sigma(y-x) \\
  \dot{y} & = \rho x- y - xz 
\end{aligned}
$$

however the knitred HTML document gives a single-line equation:

screen shot of single line equation from html

3 Answers 3

4

This code produced 2 HTML lines, as desired, when cut and paste into RStudio in Windows 7 with knitr. If the second slash at the end of the 3rd line was removed, it produced the result shown in example.

3
  • Do you mean as follows: $$ \begin{aligned} \dot{x} & = \sigma(y-x) \ \dot{y} & = \rho x- y - xz \end{aligned} $$ because if so, I still get the same result as above. I also have Windows 7, R Studio 0.98.484 and I am using R version 3.0.2 (32-bit) Commented Jan 15, 2014 at 23:48
  • With R v3.0.2 (64-bit), Windows 7, RStudio 0.98.490 & knitr v1.5, when the code you provided above was copied and pasted into RStudio with no changes, it produced two lines of equations. Also worked properly when code was typed in. As a test, when the 2nd backslash was deleted at the end of the 3rd line of code (\dot{x} & = \sigma(y-x) \), it produced the single line equation you provided as an example.
    – Charlie
    Commented Jan 16, 2014 at 3:38
  • 9
    $$\begin{eqnarray} a^2 + b^2 &=& c^2 \\ &=& 5 \end{eqnarray}$$ works in my environment.
    – user51966
    Commented Mar 21, 2016 at 15:46
4

It's now a decade since this question was asked, but I'm having good luck with:

$$
\begin{split}
  \dot{x} & = \sigma(y-x) \\
  \dot{y} & = \rho x- y - xz 
\end{split}
$$

Within split, the locations demarcated by & will be aligned.

Solution from @Castel:

enter image description here

Using split:

enter image description here

This is especially useful for derivations:

$$
\begin{split}
x & = \int_{\tau_0}^{\tau_n}\tau^{-\alpha}\; d\tau \\
  & = \frac{\tau_0^{1-\alpha}-\tau_n^{1-\alpha}}{a-1}
\end{split}
$$

enter image description here

0

I'm using markdown with Logseq and in this environment simply entering $$ \dot{x} = \sigma(y-x) \\ \dot{y} = \rho x- y - xz $$, allowed me to enter multi-line equations. Note the I removed the begin and end of the original message and also the &'s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.