Repository navigation
Closed
Description
Steps to reproduce:
- Create a basic bookdown project using RStudio new project and choosing "Book project using bookdown"
- Test that
bookdown::render_book("index.Rmd", bookdown::pdf_book())builds correctly. - Edit
_output.ymlto addextra_dependencies: "subfig"to thepdf_bookoutput:
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
extra_dependencies: "subfig"
- Edit
04-application.Rmdto 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
- 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
Labels
No labels
Activity
j-magnolia commentedon Aug 21, 2020
The problem here is passing a constructed
bookdown::pdf_book()object torender_book. If I pass a string instead:the book renders correctly.
I am closing this issue.
cderv commentedon Aug 22, 2020
Seems like an issue 🤔 it should work the them with both type of input.
yihui commentedon Aug 22, 2020
I know why the previous way fails, but don't have time to explain in detail. I strongly recommend that you pass a character string instead of a function to the output format. In short, if you pass a function, you must provide all options in the function call. If you pass a string, it uses options provided in
_output.yml.https://bookdown.org/yihui/bookdown/usage.html
cderv commentedon Aug 22, 2020
Oh ok ! Noted. Don’t need more explanation 😅
Short and clear. I understand now.
j-magnolia commentedon Aug 22, 2020
It might be useful to add @yihui's comment above to the documentation for
bookdown::render_bookandrmarkdown::render:cderv commentedon Aug 22, 2020
I completely agree as I was also thinking about that. This would be a great addition. You can submit a PR or I’ll do that Monday.
j-magnolia commentedon Aug 23, 2020
PR #931 submitted.
j-magnolia commentedon Aug 27, 2020
I have closed PR #931 and submitted two new PRs: #958 and rstudio/rmarkdown#1907 to address the documentation primarily in rmarkdown, with a note in the
bookdown::render_book()docs to look at thermarkdown::render()docs for details on how theoutput_formatargument is handled.github-actions commentedon Mar 31, 2021
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.