pdf,docx,html输出中的书本中一致的数学方程式编号 [英] Consistent math equation numbering in bookdown across pdf, docx, html output

查看:50
本文介绍了pdf,docx,html输出中的书本中一致的数学方程式编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在书本中,有一个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:

    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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆