I am working on a large document in Overleaf, and in order to keep an overview over the chapters, I have arranged them in a subfolder with a naming structure like this:





I am subsequently adding more chapters to this, and sometimes changing their order. Hence I was wondering if it's possible to automatically include all files in that subfolder in sorting order into the document? I have seen that it is possible in LaTeX only through bash scripts, so I figured this wouldn't work in Overleaf.

Or maybe I'm not seeing things clearly and there is an even better solution to this problem?

  • 1
    Overleaf-specific questions should be directed to Overleaf's helpdesk. I hear their LaTeX support staff is top-notch. – Mico Jan 15 at 11:02
  • In that case sorry for spamming this forum, I'll direct myself to their support then! – Cb31w01 Jan 15 at 12:20
  • 1
    Your document will not be very large presumably, maybe 20 chapters max? In such a case it would probably take you less time to just adjust one or two \include statements if something changes, instead of trying to create a fully automatic solution. – Marijn Jan 15 at 12:26

yes you can use those scripts, overleaf runs with shell-escape on linux texlive 2020 so for example


will list the filenames in the current folder.

  • 1
    I'm from the Overleaf Support team and I confirm that you can run basic shell scripts. However, I wouldn't recommend this: It adds another layers of code and makes things much more difficult to debug, with (IMHO) a negligible gain. – yo' Jan 15 at 13:58
  • 1
    @yo' yes I wouldn't disagree with that (which is one reason I only showed ls and left the processing as an exercise for the reader) also marijn's comment under the question. – David Carlisle Jan 15 at 14:02

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.