I'm using bookdownplus R package with dnd template. I used the following code.

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

When I compile the document, it throws the error:

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

Any hints to solve the issue. Thanks

Session Info

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  

Edited

Using the suggestions of @Maurits Evers, I updated TinyTex using wget -qO- "https://yihui.name/gh/tinytex/tools/install-unx.sh" | sh on Ubuntu 18.04 LTS. I stilling getting the error: `! Undefined control sequence. l.61 \hypertarget {chapter-1-bookdownplus}{%

Error: Failed to compile dnd.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips.` Any thoughts.

Bug Reported

Bug is reported tinytex and bookdownplus.

1 Answers

0
Maurits Evers On

I cannot reproduce your issue on MacOS running MacTex with bookdownplus_1.5.6.

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

gives the following output

#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

I think the issue might be related to your incomplete/missing LaTeX environment. The error you're seeing suggests that you are missing the hyperref package. Depending on your OS, I believe that most (all?) standard (La)TeX distributions (e.g. MacTex/TeX Live on MacOS, MiKTeX on Windows, ...) include hyperref by default. So the first thing to do is to ensure that you have a working TeX distribution on your OS. Then try re-compiling the bookdownplus example.


Making sure that you have a functional TeX distribution

Let's create a sample LaTeX file test.tex with the following content

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

Store the file in a folder and from that same folder open an R terminal and compile the document with

tinytex::pdflatex("test.tex")

The output should be a PDF file test.pdf.