[英]“Erroneous nesting of equation structures” in using “\begin{align}” in a multi-line equation in rmarkdown to knit+pandoc pdf
I am writing some multi-line equations in R Markdown - LaTeX, using auto-numbering and \\begin{align}. 我正在使用自动编号和\\ begin {align}在R Markdown - LaTeX中编写一些多线方程。 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. 当输出为html_document时,这很有用。 Here's the result:
这是结果:
But when I change the output document to pdf: 但是当我将输出文档更改为pdf时:
output: pdf_document
I get the following error (I am using RStudio latest Version 0.98.1056): 我收到以下错误(我正在使用RStudio最新版本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).
我已经检查了Stack Overflow和谷歌,虽然有一些相关的帖子/问题(例如这里 , 这里 , 这里 ),但没有一个解决问题(或适用于我的问题)。
I've also tried to tweak everything. 我也尝试过调整一切。 The most evident solution would be to get rid of the \\begin{align} environment,
最明显的解决方案是摆脱\\ begin {align}环境,
(@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).
首先,html版本不能很好地工作,因为自动编号不会出现在多线方程的中心,而是出现在第一行(我不喜欢它)。
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 \\). 其次,尽管这种情况下的pdf版本确实编译并生成了pdf,但它并不认识到它是一个多线方程(就像它不能识别新的线命令一样)。
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).
我有点喜欢R Markdown,因为它真正将分析与写作和通信集成在一个工具中(而不是使用许多不同的工具来回)。 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.
但是,在我们编写一个单独的源文件并且它以几种不同的输出格式正确呈现之前,似乎还有很长的路要走。
I was receiving the same error when trying to send an aligned block to PDF. 尝试将对齐的块发送到PDF时,我收到了同样的错误。 Try changing the following:
尝试更改以下内容:
$$
\begin{align}
y = x^2 \\
y = x^3 \\
y = \sqrt[2]{x}
\end{align}
$$
to the following: 以下内容:
$$
\begin{aligned}
y = x^2 \\
y = x^3 \\
y = \sqrt[2]{x}
\end{aligned}
$$
\\begin{align}
is a self-contained math environment, whereas \\begin{aligned}
needs to be placed inside an existing math environment. \\begin{align}
是一个独立的数学环境,而\\begin{aligned}
需要放在现有的数学环境中。 Since Rmd delineates math sections with $$...$$
, it seems like \\begin{align}
was trying to start a second math environment within the first and causing problems. 由于Rmd用
$$...$$
描述数学部分,似乎\\begin{align}
试图在第一个数学环境中启动第二个数学环境并导致问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.