I am writing some multi-line equations in R Markdown - LaTeX, using auto-numbering and \begin{align}. Here's a working the example:
---
title: "test"
output: html_document
---
(@eq01) $$
\begin{align}
y = x^2 \\
y = x^3 \\
y = \sqrt[2]{x}
\end{align}
$$
This works great when the output is html_document. Here's the result:
But when I change the output document to pdf:
output: pdf_document
I get the following error (I am using RStudio latest Version 0.98.1056):
I've been trying to read the documentation as suggested in the error message, but I do not seem to get a handle on it. I've checked Stack Overflow and Google and although there are some related posts/questions (for example here, here, here), none of them solve the problem (or apply to my problem).
I've also tried to tweak everything. The most evident solution would be to get rid of the \begin{align} environment,
(@eq01) $$
y = x^2 \\
y = x^3 \\
y = \sqrt[2]{x}
$$
but it does not work for two reasons. First, the html version does not work as nicely because the auto-numbering does not appear centered in the multi-line equation, but rather on the first line (and I don't like it like that).
Second, although the pdf version in this case does compile and produce the pdf, it does not recognize that it is a multi-line equation (it's like it does not recognize the new line command \).
Any ideas are really appreciated. I've been struggling with this for a while and I cannot find a solution. I kinda love R Markdown because it really integrates the analysis with writing and communicating in a single tool (rather than using many different tools going back and forth). However, it seems there is still a long way to go before we can write one single source file and that it renders appropriately in several different output formats.
$$
...$$
, sincealign
initiates math-mode on its own. – Werner\begin{equation} \begin{aligned} y = x^2 \\ y = x^3 \\ y = \sqrt[2]{x} \end{aligned} \end{equation}
But it does not render the equations in html output. Also, the auto-numbering using only LaTeX does not get along with equation numbering using "(@eq) $$" – Hernando Casas\begin{equation}
...\end{equation}
starts math-mode, which is not whatalign
wants. – Werneralign
toaligned
- there's a difference. – Werneraligned
looks working well with both PDF and HTML. What is the problem? – kohske