I have written a R script to generate 2 RMarkdown PDF reports for a given dataset.

The script runs without error on my main Linux machine with Texlive. I adjusted it for my work laptop with Windows and MiKTeX and it runs perfectly.

However when I installed the program on my coworker's Windows machine (he is the one who needs to be generating the reports every two weeks) RMarkdown fails to compile the second report. The first report runs just fine.

The log file ends with

[5 <D:/Tower_Raw Data/QAQC Reports/HB1ts_RawQAQCReport_20200322_files/figure-la
! Undefined control sequence.
\grffile@filename ->D:\Tower 
                             _Raw Data\QAQC Reports\HB 1ts_RawQAQCReport_202...
l.292 ...22_files/figure-latex/unnamed-chunk-38-1}
!  ==> Fatal error occurred, no output PDF file produced!

My first thought is that the "_" in the folder name "Tower_Raw Data" is a problem. Since the \grffile@filename line has unusual spacing around it. This doesn't seem to make sense though given that both reports are generated from the same data and written to the same folder with the first report compiling successfully.

Does anyone have a suggestion?

Here is the full log output if anyone is interested: https://pastebin.com/gFpgyzEc

  • Probably the miktex is older. There have been a number improvements lately regarding the handling of file names with spaces. But you should not start pdftex with an absolute path, switch into the correct folder and call simply pdflatex HB1ts_RawQAQCReport_20200322. – Ulrike Fischer Apr 11 '20 at 16:02
  • Today I updated Miktex through the console to the latest version and it still failed. I can however confirm that the underscore in the path to the destination is causing the issue because I manually changed the output directory to a simple one Desktop/Report/ and it wrote the PDF just fine. – JForsythe Apr 13 '20 at 19:13
  • To clarify my problem : I am running RMarkdown from an R script saved in a different directory than the output path. It needs to write the PDF to the <D:\Tower_Raw Data\QAQC Reports\> folder. RMarkdown is being called twice (for 2 reports). Curiously the first report is written perfectly but not the second even though they have the same output directory path. – JForsythe Apr 13 '20 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.