Skip to content

PDF Chapter Preview does not incorporate "includes:" arguments #888

Open
@connorp

Description

@connorp

Despite the recommendation to only preview to HTML, I sometimes like to preview a bookdown chapter to PDF, so I can print or share with collaborators. I believe the preview_chapter() function is failing to incorporate data from the includes: YAML option in _output.yml when previewing to PDF.

Steps to Reproduce:

  1. Create a new bookdown project (just the minimal project created by
    File -> New Project… -> Book Project using bookdown is sufficient for a reprex).

  2. Add the following (example) line to `preamble.tex':

    \DeclareMathOperator*{\argmax}{arg\,max}

  3. Add the following line to a book chapter, for example 03-methods.Rmd:

    $$\argmax_f f(x)$$

  4. Compile the full book, confirming that the added LaTeX math line is rendered correctly (f centered below argmax)

  5. Preview the chapter to PDF:

    preview_chapter('03-method.Rmd', output_format = "pdf_book")

    This function call will fail, because LaTeX does not know the command \argmax, since preamble.txt was not added to the document. Inspection of the log file and .tex file remaining after the error confirms the absence of the preamble contents.

Previewing to HTML as normal does not have the issue. Files specified via includes: are incorporated appropriately in this case.

One other observation I made, though I'm not sure it rises to the level of its own bug report: when previewing to PDF via preview_chapter('03-method.Rmd', output_format = "pdf_book"), the resulting PDF contains the entire book contents, rather than just the specified chapter, as I would expect. Is this the intended behavior?

Session Info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.4, RStudio 1.2.5033

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3 bookdown_0.19   digest_0.6.25   evaluate_0.14   glue_1.4.0      graphics_3.6.3  grDevices_3.6.3 highr_0.8       htmltools_0.4.0
  jsonlite_1.6.1  knitr_1.28      magrittr_1.5    markdown_1.1    methods_3.6.3   mime_0.9        Rcpp_1.0.4      rlang_0.4.6     rmarkdown_2.1  
  stats_3.6.3     stringi_1.4.6   stringr_1.4.0   tinytex_0.22    tools_3.6.3     utils_3.6.3     xfun_0.13       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

    bugan unexpected problem or unintended behaviordocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions