pdf,docx,html输出中的书本中一致的数学方程式编号 [英] Consistent math equation numbering in bookdown across pdf, docx, html output
问题描述
在书本中,有一个LaTeX数学环境可以为每个方程式编号,而不管输出是.pdf,.docx,.html还是?添加此 LaTeX:
\ begin {align}X&= Y \\Z& = W\ end {align}
在
DOCX :缺少方程式编号.
HTML:缺少等式编号.
注意:
- 使用
pdf_book
,word_document2
,gitbook
生成输出. - 这与我的未解决问题有关:
PDF输出类似.在LibreOffice中看到的字输出非常糟糕,但是方程式编号(包括引用)在那里.所以我想这是本地的或LibreOffice特定的问题.
In bookdown, is there a LaTeX math environment which numbers each equation, regardless of whether the ouptut is .pdf, .docx, .html? Adding this LaTeX:
\begin{align} X &= Y \\ Z &= W \end{align}
Into the bookdown-demo outputs the following:
PDF: works as expected.
DOCX: missing equation numbers.
HTML: missing equation numbers.
Notes:
- The output was generated using
pdf_book
,word_document2
,gitbook
. - This is related to an unanswered question of mine: Align environment in R Markdown which works for both docx and pdf output?
UPDATE: Merging Ralf's answer below along with other learnings of mine, in bookdown, the following all work consistently and as expected across .pdf, .docx, .html output.
Add a single un-numbered equation: \begin{equation*} X = Y \end{equation*} Add a single numbered equation: \begin{equation} X = Y (\#eq:eq02) \end{equation} I refer to previous, equation \@ref(eq:eq02). Add multiple un-numbered equations: \begin{align*} X &= Y \\ Z &= W \end{align*} Add multiple equations with numbering for each: \begin{align} X &= Y (\#eq:eq05)\\ Z &= W (\#eq:eq06) \end{align} I refer to previous, equation \@ref(eq:eq05) and equation \@ref(eq:eq06). Add multiple equations with a single numbering for all: \begin{equation} \begin{aligned} X &= Y \\ Z &= W \end{aligned} (\#eq:eq04) \end{equation} I refer to previous, equation \@ref(eq:eq04).
解决方案For equation numbering support in
bookdown
you need to assign labels. the following works for me:--- output: bookdown::html_document2: default bookdown::word_document2: default bookdown::pdf_document2: default --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` \begin{equation} \begin{aligned} X &= Y \\ Z &= W \end{aligned} (\#eq:eq1) \end{equation} \begin{align} X &= Y (\#eq:eq2) \\ Z &= W (\#eq:eq3) \end{align} See Equation \@ref(eq:eq1) or Equations \@ref(eq:eq2) and \@ref(eq:eq3).
HTML Output:
PDF output is similar. Word output as seen in LibreOffice is pretty bad, but the equation numbers including references are there. So I guess this is a local or LibreOffice specific problem.
这篇关于pdf,docx,html输出中的书本中一致的数学方程式编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- The output was generated using