2

I have an Overleaf project that contains multiple .tex files to create different PDF documents. If I compile one of the .tex files and download it, it is named after the Overleaf project. Currently, if I want the PDF file to have the same name as the corresponding .tex file, I have to rename the PDF file after downloading. Is there a way to make Overleaf change the PDF filenames to the names of the .tex files they are created from? Say, I have doc1.tex and doc2.tex. My goal is that when I download the PDF file for doc1.tex the PDF file is named doc1.pdf and when I download the PDF file for doc2.tex the filename is doc2.pdf.

My approach is to create a custom latexmkrc file. When I add the following line to Overleaf's default latexmkrc file, the compilation works.

$pdflatex = 'pdflatex -shell-escape -file-line-error --synctex=-1 %O %S ';

But appending -jobname=newfilename to this line does not change the name of the PDF file when I download it.

What is the problem here or is there a better approach?

1
  • I think that is a question better asked at Overleaf Support than here. Apr 25 at 13:46
3

(Tom from Overleaf Support here.)

If your different TeX files are called e.g. first.tex and second.tex, you can achieve having first.pdf amongst the output files so that when you download it, it will be called this way. Note that this is unfortunately not really straightforward; we didn't really intend a single project to be used that way with a lot of downloading of the PDFs for different documents within the project.

Anyway, to achieve the above, you can make a file called e.g. make_first.tex with contents:

\documentclass{article}
\usepackage{shellesc,pdfpages}
\ShellEscape{latexmk -pdf first}
\begin{document}
\includepdf[pages=-]{first.pdf}
\end{document}

If needed, you can switch -pdf to -lualatex or -xelatex to change the compiler. You can have a similar setup for any of the documents within the project.

However, first.pdf is only shown among the "Logs and Output Files" in the current UI. If you want to reach them better you can opt in for our Beta Program to get a new UI that's currently being finalized and that makes it easier to reach the output files. (This is current as of April 2021.)

1
  • Neat trick, Pasting the lines \ShellEscape{latexmk -pdf first} and \includepdf[pages=-]{first.pdf} multiple times for different .tex files even one "make" file is sufficient. Thanks.
    – upe
    Apr 26 at 17:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.