pdf – Compiling Multiple .tex Files into Multiple Outputs in Overleaf

document-classesnestingoverleafpdfsubfiles

Clarification: I am looking for a way to automatically run pdflatex on multiple .tex files to produce multiple separate .pdf files when I click the Recompile button in Overleaf.

I have multiple .tex files, which have different document classes in Overleaf. Because they have different document classes, I don't believe that the subfiles package is a viable solution.

I have currently been compiling them separately and uploading the result back into Overleaf, but this solution is not the best if you forget to compile one file that you updated.

I believe that maybe latexmk can be used for this.


An alternative solution to this, and possibly a better solution: is there a way of nesting different document classes? If so, I can just use \input on the subfiles.

Thank you in advance!

Best Answer

There are several ways of handling multiple documents

for example if you have an article class doc1 and a memoir doc2

You can have a main.tex

\documentclass{article}

\usepackage{pdfpages}
\usepackage{shellesc}

\ShellEscape{pdflatex doc1}
\ShellEscape{pdflatex doc2}

\begin{document}

\includepdf[pages=-]{doc1.pdf}
\includepdf[pages=-]{doc2.pdf}

\end{document}

That includes

doc1

\documentclass{article}

\begin{document}

an article
\end{document}

and

doc2

\documentclass{memoir}

\begin{document}

a memoir
\end{document}

If you hit recompile on the main document it will run pdflatex on all three.


See in action:

https://www.overleaf.com/read/jkkbgwfbkpvn#01e47c

Related Question