• R语言
  • Bookdown 输出 gitbook 格式时,`\tag{}` 与 `(\#eq:label)`冲突

问题说明

我在用 Bookdown 写一篇论文。有一个重要的数学条件希望用 \tag{}命名,并能在之后引用。

\begin{equation}
    \tag{$\mathrm{R}$}
    V_1 \ge \hat{U}_1 \text{ with the equality if and only if }x =1
    (\#eq:R)    
\end{equation}

这个方程在 gitbook 格式时无法生成,之后也无法引用。

gitbook 格式

输出 pdf 格式则无此问题。

pdf 格式

我的bookdown环境

xfun::session_info('bookdown')

R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134), RStudio 1.2.1335

Locale:
LC_COLLATE=Chinese (Simplified)China.936
LC_CTYPE=Chinese (Simplified)
China.936

LC_MONETARY=Chinese (Simplified)China.936
LC_NUMERIC=C

LC_TIME=Chinese (Simplified)
China.936

Package version:
base64enc_0.1.3 bookdown_0.9 digest_0.6.18 evaluate_0.13

glue_1.3.1 graphics_3.5.2 grDevices_3.5.2 highr_0.8

htmltools_0.3.6 jsonlite_1.6 knitr_1.22 magrittr_1.5

markdown_0.9 methods_3.5.2 mime_0.6 Rcpp_1.0.1

rmarkdown_1.12 stats_3.5.2 stringi_1.4.3 stringr_1.4.0

tinytex_0.12 tools_3.5.2 utils_3.5.2 xfun_0.6

yaml_2.2.0

问题分析

我尝试了

  1. 调整 \tag{}的位置(公式环境开始,(\#eq:label)前,(\#eq:label)后) 以及
  2. 取消公式缩进,

均未成功。我起初以为这应该是 bookdown 包的问题。因为网页公式代码里,出现了两个 \tag。其中(\#eq:label)在网页环境下显示\tag{4.1}

补充:昨天在StackOverflow上问了这个问题,但没啥回应,就来论坛问了。刚才发现 StackOverflow 上还被益辉编辑了...
不好意思重复提问了。不管哪边先给了解释,我会在另一边及时更新。

    albert-R 请报告一下 xfun::session_info('bookdown'),另外试试公式里不缩进看可不可以。