bookdown :: word_document2中各节的交叉引用不起作用

问题描述 投票:1回答:1

标题说明了一切。请参见下面的最小(非工作)示例。

---
title: "Untitled"
author: "Anonymous"
date: "09/01/2020"
output:
  bookdown::word_document2:
    reference_docx: template.docx
---

# First Section {#sec1}

Etc.


# Second Section

See section \@ref(sec1).

当我编织以上内容时,收到以下警告:

Output created: mre.docx
Warning message:
The label(s) sec1 not found 

输出中的引用已替换为两个问号(??)。当我将YAML标头中的输出选项替换为pdf_document2时,没有错误。我的template.docx为所有标题样式启用了节编号,并且节编号正确(只是没有编号)。

-

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.2  Matrix_1.2-18   bookdown_0.16   htmltools_0.4.0 tools_3.6.2     yaml_2.2.0      reticulate_1.13 Rcpp_1.0.3      rmarkdown_1.17  grid_3.6.2      knitr_1.26      jsonlite_1.6   
[13] digest_0.6.22   xfun_0.11       rlang_0.4.1     lattice_0.20-38 evaluate_0.14  

-

> pandoc --version
pandoc 2.8
Compiled with pandoc-types 1.20, texmath 0.12, skylighting 0.8.3
r rstudio r-markdown pandoc bookdown
1个回答
0
投票

我一直在努力解决相同的问题,但找到了解决方法

这是Rstudio小组正在处理的已知问题。https://github.com/rstudio/bookdown/issues/787

通过使用随Rstudio一起安装的pandoc版本(目前为2.7.2),我能够解决此问题。在Windows中,我是通过从PATH中删除pandoc,然后重新启动Rstudio会话来完成此操作的。

© www.soinside.com 2019 - 2024. All rights reserved.