I have a large bookdown project. It compiles perfectly well, into HTML and PDF.
But I would like bookdown to produce the TeX file, then do some processing on that TeX file before then producing the final PDF.
I have set (removing some lines for brevity) in my _output.yml
file:
bookdown::pdf_book:
latex_engine: xelatex
self_contained: false
keep_tex: yes
And indeed the file _main.tex
is produced when using the Build
button in Rstudio
, or bookdown::render_book()
.
The file _main.tex
is placed in the _book
directory under the main directory, as one expects.
What commands do I then run to produce the PDF file from this .tex
file?
I see three options, all of which fail:
- Run
tinytex::xelatex(file="_main.tex")
from the main directory.
This obviously fails, because the file_main.tex
is not in that directory:Error: LaTeX failed to compile _main.tex.
- Run
tinytex::xelatex(file="_book/_main.tex")
from the main directory.
This fails to find some image files:! LaTeX Error: File '01-Introduction_files/figure-latex/FIG-1' not found.
These files are produced, but reside in the directory_bookdown_files
, under the main directory, which cannot be found. - Move to the
_book
directory first (i.e.,setwd("_book")
), then runtinytex::xelatex(file="_main.tex")
.
This fails, complaining about missing files again (the image files are, for instance, a directory above).
It seems like this should be easy, but I am clearly missing something.
So my question:
- How can I successfully compile the
.tex
file that is produced by runningbookdown::render_book()
?
Any help appreciated.
P.