You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using pdflatex, I ran into a problem compiling when output_dir had spaces in the filename rmarkdown::render(). pdflatex() gave the error Undefined control sequence. I realize that the file cannot be found due to a space in output_dir.
rmarkdown::render(
input = "lab-specific-report.Rmd", #name of child R Markdown file
output_dir = "my_folder/pgm name/doc", #Latex Fails with spaces
output_file = "My_File_1_Week_1",
output_format = "pdf_document",
)
Upon compiling, LaTex pdflatex gave this error:
Undefined control sequence
LaTeX Font Info: Trying to load font information for T1+lmtt on input line 9
3.
(c:/Users/ph137/AppData/Roaming/TinyTeX/texmf-dist/tex/latex/lm/t1lmtt.fd
File: t1lmtt.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
! Undefined control sequence.
...rmessage LaTeX Error: File `my_folder/pgm name/doc
l.99 ..._/figure-latex/report-plots-1}
\end{center}
Here is how much of TeX's memory you used:
12231 strings out of 480954
185972 string characters out of 5905841
511514 words of memory out of 5000000
29269 multiletter control sequences out of 15000+600000
413278 words of font info for 37 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
85i,3n,88p,668b,328s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
After reviewing Yui's comments (see #1285 (comment)), I suggest to add a warning in rmarkdown::render() indicating that the spaces in the filenames may cause LaTex to fail its compilation, maybe in pdflatex, but definitely in xelatex. Add something like this in the function:
if(length(grep(" ", output_dir, fixed = TRUE)) > 0){
warning("The output directory contains a space. LaTex may have trouble finding files. Suggest to remove space if possible.",
call. = FALSE)
}
Other suggestions include using a relative directory (which I am not a fan of) or a temporary drive, but spaces throw off LaTex. I am not sure what to do if you can't remove spaces from the filename.
The text was updated successfully, but these errors were encountered:
Thank you. Yes, great idea. I agree that your comment should work. So you mean to set output_dir to its default, NULL (and move the rendered file after)?
Yet, if render() could warn a user that a space in output_dir exists, I think that would help the user identify the source of the problem, as the LaTex undefined control sequence error is often difficult to diagnose.
We could try add a warning for this. All the file input like output_dir, output_file, intermediate_dir, ... could be sensible to things like that and it is hard to know beforehand.
We could start with small step by adding a warning when we know this is necessary. Thanks for the suggestion !
Using
pdflatex
, I ran into a problem compiling whenoutput_dir
had spaces in the filenamermarkdown::render()
.pdflatex()
gave the errorUndefined control sequence
. I realize that the file cannot be found due to a space inoutput_dir
.This problem has been well documented
https://stackoverflow.com/questions/57061618/error-generating-pdf-document-with-rmarkdown-when-output-dir-contains-spaces
#1285 (comment)
although
pdflatex
is somewhat more tolerant of spaces in the past.Upon compiling, LaTex
pdflatex
gave this error:After reviewing Yui's comments (see #1285 (comment)), I suggest to add a warning in
rmarkdown::render()
indicating that the spaces in the filenames may cause LaTex to fail its compilation, maybe inpdflatex
, but definitely inxelatex
. Add something like this in the function:Other suggestions include using a relative directory (which I am not a fan of) or a temporary drive, but spaces throw off LaTex. I am not sure what to do if you can't remove spaces from the filename.
The text was updated successfully, but these errors were encountered: