Repository navigation
Open
Description
Bug description
When exporting to PDF, and keep-tex: true and output-dir: "outdir" are both set in the relevant YAML, the .tex file remains in the working directory, even after the .pdf file is moved to outdir.
Reprex
- Create a new Quarto project, with the following contents in the
_quarto.ymlfile:project: title: "test" output-dir: "outdir" - Create a
test.qmdfile with the following contents:--- title: "test" format: pdf: keep-tex: true --- Hello - Render the project. Observe that
test.pdfis in theoutdirsubdirectory, buttest.texremains in the project directory.
System Stats
Results of quarto check:
[✓] Checking Quarto installation......OK
Version: 0.9.637
Path: /Applications/quarto/bin
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.9.6 (Conda)
Path: /Users/connor/opt/miniforge/bin/python
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with conda install jupyter
[✓] Checking R installation...........OK
Version: 4.2.1
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
rmarkdown: 2.14
[✓] Checking Knitr engine render......OK
RStudio Version 2022.02.3 Build 492. Session Info:
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1
Checklist
- formatted your issue so it is easier for us to read?
- included a minimal, self-contained, and reproducible example?
- documented the quarto version you're running, by providing the output produced by
quarto checkin a terminal in your issue? - documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- documented which operating system you're running? If on Linux, please provide the specific distribution as well.
- upgraded to the latest version, including your versions of R, the RStudio IDE, and relevant R packages?
Reacted by isaactpetersen, Stefan Weber and Greg Meyer
Activity
jjallaire commentedon Jul 6, 2022
The purpose of
keep-texis that you can run e.g. mklatex on it and produce the PDF. If we move it to theoutput-dirthen this no longer works. So this behavior is by design.connorp commentedon Jul 6, 2022
Hmm, interesting. I think this behavior does actually cause problems in a reasonable use case. If I have my
.qmdfile in a subdirectory of the project directory calledcode, and I setoutput-dir: outputs, Quarto will move the.pdffile and all the assets/images files intooutputs, but leave the.texincode. That movement happens after Quarto/pandoc invokes TeX to render the PDF, so it works fine then. But if I then were to try to render that.texfile again with TeX myself, it would fail, because the links to the assets/images are now broken.jjallaire commentedon Jul 6, 2022
The movement of assets/images into output-dir works only by accident (b/c the _files dir also has the HTML assets and is copied). Images are also copied only if they are also referenced in HTML. So you are free riding on the HTML behavior for LaTeX. The real fix is to make tex a proper output format for books and actually copy all of the assets (even if there is no HTML in play).
Net is that I agree this doesn't quite do what you want it to but its not a simple "copy here instead of there" fix, we need to do a bit more legwork to make it all work properly.
connorp commentedon Jul 6, 2022
Okay, makes sense. Is this issue sufficient to flag this as an area for future improvement, or should I reframe and resubmit? FWIW, I don't think this is an issue just for books. I'm rendering a very simple
.qmdto TeX/PDF that just has a line of R code that makes a graph. It's that graph image that is then separated from its associated.texfile. But for now, I'll just refrain from usingoutput-dirin this use case.jjallaire commentedon Jul 6, 2022
We know we need to take care of this both for .tex as well as for other text based formats like
asciidoc. Yes, we would indeed need to make it work for any use ofoutput-dir. So no need for an issue (I'll reopen this one as a form of reminder but it's for sure on the list already)cderv commentedon Oct 24, 2025
Related dicussion in