0

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:

\section{A}
\input{A.tex}

\section{B} \input{B.tex}

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.

Bernard
  • 271,350
  • 4
    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 – David Carlisle Jul 15 '21 at 22:16
  • If you use an IDE like TexStudio, you can do as i did here https://tex.stackexchange.com/questions/666198/binding-texstudio-indent-section-shortcut – anis Dec 08 '22 at 09:02

1 Answers1

0

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.

MS-SPO
  • 11,519