Skip to content

extra_dependencies and includes:in_header not working for PDF output. #930

@jonathan-g

Description

@jonathan-g

Steps to reproduce:

  1. Create a basic bookdown project using RStudio new project and choosing "Book project using bookdown"
  2. Test that bookdown::render_book("index.Rmd", bookdown::pdf_book()) builds correctly.
  3. Edit _output.yml to add extra_dependencies: "subfig" to the pdf_book output:
bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: xelatex
  citation_package: natbib
  keep_tex: yes
  extra_dependencies: "subfig"
  1. Edit 04-application.Rmd to add the example code from https://bookdown.org/yihui/rmarkdown-cookbook/latex-subfigure.html:
## Example one

```{r subfig-test, fig.cap='Figure 1', fig.subcap=c('(a)', '(b)', '(c)'), fig.ncol=2, fig.align="center", out.width="50%"}
plot(1:10)
plot(cars, pch = 19)
boxplot(Sepal.Width ~ Species, data = iris)
```

## Example two
  1. Build using bookdown::render_book("index.Rmd", bookdown::pdf_book()).

Expected result:

I expect a PDF document like the one in the example at https://bookdown.org/yihui/rmarkdown-cookbook/latex-subfigure.html

Actual result:

XeLaTeX reports an error:

! Undefined control sequence
l.249 {\centering \subfloat
                           [(a)\label{fig:subfig-test-1}]{\includegraphics[w...

Error: LaTeX failed to compile Foo.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Foo.log for more info.

After this error I tried again, adding the line

\usepackage{subfig}

to preamble.tex, but I still got the same error.

Inspecting the generated Foo.tex file, there is neither an include{preamble.tex} nor a \usepackage{subfig}.

This error is similar to #888

> xfun::session_info("bookdown")
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363), RStudio 1.3.1056

Locale:
  LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  LC_TIME=English_United States.1252    

Package version:
  base64enc_0.1.3      bookdown_0.20.3      digest_0.6.25       
  evaluate_0.14        glue_1.4.1           graphics_4.0.2      
  grDevices_4.0.2      highr_0.8            htmltools_0.5.0     
  jsonlite_1.7.0       knitr_1.29           magrittr_1.5        
  markdown_1.1         methods_4.0.2        mime_0.9            
  rlang_0.4.7          rmarkdown_2.3.2.9003 stats_4.0.2         
  stringi_1.4.6        stringr_1.4.0        tinytex_0.25        
  tools_4.0.2          utils_4.0.2          xfun_0.16           
  yaml_2.2.1          

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions