3

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!

L Duran
  • 33
  • 2
    This makes it sound like you're compiling on a local TeX installation. If so, why are you using Overleaf? Why are you wanting to convert to png? Are you creating images to include into a master document? – Teepeemm Apr 05 '23 at 16:29
  • Thank you for your comment! WRT local installation: I would generally prefer to use a local installation, but I am working with multiple computers where I don't have admin privileges to perform installation, so Overleaf is the preferable solution. WRT PNGs, latexmkrc: In this case, I don't want to convert to PNG. It's just something that I believe would be like the solution that I am looking for to compile multiple .tex files automatically, but it doesn't necessarily have to be a solution with latexmkrc. – L Duran Apr 05 '23 at 16:38
  • you can compile multiple files manually on overleaf, simply select the file and click on recompile. You could ask the overleaf support if there is an option to automate that. – Ulrike Fischer Apr 05 '23 at 17:00
  • @Ulrike Fischer Thank you! This is actually what I have been doing. It's not ideal at all, but it works when I remember to compile and upload, which I don't forget often. Thanks for the suggestion of contacting overleaf support! I will try that. – L Duran Apr 05 '23 at 17:26
  • An alternative solution that I considered is the possibility of nesting document classes although I doubt that there's a way of doing this, but I added it to my question. – L Duran Apr 05 '23 at 17:27
  • 1
    it isn't clear why you mention png. why do you want to convert a document to bitmap image? You can use latexmk to run pdflatex on multiple files and get multiple pdf – David Carlisle Apr 05 '23 at 17:42
  • Thanks, David Carlisle! Yes, thanks, I am specifically interested in using latexmk to run pdflatex on multiple files and get multiple pdf! I understand about the mentioning of the PDF. It was just an example for what I believe is a similar solution, but I also think it's confusing. So I will remove it. – L Duran Apr 05 '23 at 19:24

1 Answers1

3

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

yo'
  • 51,322
David Carlisle
  • 757,742