I have several standalone documents/chapters (A.tex, B.tex, ...), that I want to assemble in a single document (Main.tex). Every chapter has its own section hierarchy (starting from sections, subsections...).

I can join all the chapters by doing:



but then I need to modify all the sections hierarchy within each chapter, to reduce the section level to start from subsections. Is there a way to add the documents without doing this change by hand? Defining the section level in a relative way?

Thanks for your help.

  • 3
    why can't you use \chapter{A} \input{A.tex} which is the intention of the design and why article starts at \section level so you can make them chapters of a report Jul 15, 2021 at 22:16
  • If you use an IDE like TexStudio, you can do as i did here tex.stackexchange.com/questions/666198/…
    – anis
    Dec 8, 2022 at 9:02

1 Answer 1


So you want to shift hierarchie up and down the level?

What you could do is redefining commands (I suppose), to turn e.g. a \chapter into a \section etc. After all, we talk about macros in Latex, and modifying what they do. You probably need to start at the lowest level and work upwards in this case ;-)

If this fails for some reason, e.g. because you need to handle various cases, scripting might be a solution. See an example on extracting equation-environments here How to extract equation-environments (or other blocks) inside a Latex document?. You can use the same approach to substitute hierarchy. A convenient way would be to run such a script separately on each of your files of interest.

You must log in to answer this question.

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