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!

7
  • 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
    Commented Apr 5, 2023 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
    Commented Apr 5, 2023 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. Commented Apr 5, 2023 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
    Commented Apr 5, 2023 at 17:26
  • 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 Commented Apr 5, 2023 at 17:42

1 Answer 1

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

2
  • Wow, this is amazing. This is exactly what I wanted. Thanks you so much!
    – L Duran
    Commented Apr 5, 2023 at 19:35
  • 1
    More information about the \write18 operator <tex.stackexchange.com/q/20444/289244> I suppose it's a little hard to find things when you don't know the name.
    – L Duran
    Commented Apr 5, 2023 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .