bookdownplus:dnd模板错误!未定义的控制顺序。 l.61 \ hypertarget

时间:2019-04-20 16:19:43

标签: r r-markdown knitr tinytex bookdownplus

我正在使用bookdownplus模板的R dnd软件包。我使用了以下代码。

library('bookdownplus')
bookdownplus('dnd', render = TRUE, rproj = TRUE)

当我编译文档时,它会引发错误:

! Undefined control sequence.
l.61 \hypertarget
                 {chapter-1-bookdownplus}

任何提示都可以解决此问题。谢谢

会话信息

sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] bookdownplus_1.5.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1      bookdown_0.9.2  packrat_0.5.0   digest_0.6.18  
 [5] magrittr_1.5    evaluate_0.13   stringi_1.4.3   rstudioapi_0.10
 [9] rmarkdown_1.12  tools_3.5.3     stringr_1.4.0   tinytex_0.11   
[13] xfun_0.6        yaml_2.2.0      compiler_3.5.3  htmltools_0.3.6
[17] knitr_1.22.8  

已编辑

根据@Maurits Evers的建议,我在wget -qO- "https://yihui.name/gh/tinytex/tools/install-unx.sh" | sh上使用Ubuntu 18.04 LTS更新了TinyTex。我仍然遇到错误:`!未定义的控制顺序。 l.61 \超目标                  {chapter-1-bookdownplus} {%

错误:未能编译dnd.tex。有关调试提示,请参见https://yihui.name/tinytex/r/#debugging。任何想法。

已举报错误

报告了tinytexbookdownplus的错误。

1 个答案:

答案 0 :(得分:0)

在运行带有bookdownplus_1.5.6的MacTex的MacOS上,我无法重现您的问题。

library('bookdownplus')
bookdownplus('dnd', render = TRUE, rproj = TRUE)

给出以下输出

#trying URL 'https://github.com/pzhaonet/bookdownplus/raw/master/upload/dnd/demo.zip'
#Content type 'application/zip' length 3325858 bytes (3.2 MB)
#==================================================
#downloaded 3.2 MB
#
#
#
#processing file: dnd.Rmd
#  |......................                                           |  33%
#  ordinary text without R code
#
#  |...........................................                      |  67%
#label: unnamed-chunk-1 (with options)
#List of 2
# $ type  : chr "quotebox"
# $ engine: chr "block"
#
#  |.................................................................| 100%
#  ordinary text without R code
#
#
#output file: dnd.knit.md
#
#/usr/local/bin/pandoc +RTS -K512m -RTS dnd.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output dnd.tex --table-of-contents --toc-depth 3 --template tex/template_dnd_dev.tex --number-sections --highlight-style tango --latex-engine pdflatex --natbib --top-level-division=chapter --variable tables=yes --standalone
#
#Output created: _book/dnd.pdf

enter image description here

我认为问题可能与您的LaTeX环境不完整/缺失有关。您看到的错误表明您缺少hyperref package。根据您的操作系统,我认为默认情况下,大多数(所有)标准(La)TeX发行版(例如MacOS上的MacTex / TeX Live,Windows上的MiKTeX等)都包含hyperref。因此,要做的第一件事是确保操作系统上具有可用的TeX发行版。然后尝试重新编译bookdownplus示例。


确保您的TeX发行版功能正常

我们创建一个包含以下内容的示例LaTeX文件test.tex

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{https://www.r-project.org}{The R Project for Statistical Computing}
\end{document}

将文件存储在一个文件夹中,然后从同一文件夹中打开R终端,并使用

编译文档
tinytex::pdflatex("test.tex")

输出应为PDF文件test.pdf

相关问题