I have a number of .tex files containing sections which are \input{} into a large document. I'd now like to create an "excerpt" document that includes only a subset of these sections. The problem is, the hierarchy level should be different in the excerpt than in the main document. That is, in the main document the concerned section may be a \subsection, but in the excerpt it must be a \section (i.e. everything moves up a level). Is there a way to handle this hierarchy level correctly in different files using \input{}?

  • 1
    You could just put \renewcommand\subsection{\section} and similar redefinitions in the preamble for the excerpt. – Ian Thompson Mar 13 '15 at 8:41
  • That's a great idea. I guess this still means that I'd have to be consistent with hierarchy differential though? i.e. I can't have a \subsection and a \subsubsection from the original document both be \sections in the excerpt... That may be too much to ask in any case. Thanks for your help! – mindthief Mar 13 '15 at 9:07
  • You could rename \subsubsection to \section as well if you want to. Anything is possible with TeX... – Ian Thompson Mar 13 '15 at 9:19
  • Right but the \subsection itself has \subsubsections which should be preserved as one-level-below. So these \subsubsections should become \subsections, while other stand-alone \subsections used should become \sections... I guess I could just have all the .tex files without sectioning tags and manually add those tags in each base file. Would be tedious though, since that would mean having a separate .tex file for every section, subsection, subsubsection, ... – mindthief Mar 13 '15 at 9:27

Since in comments you imply that you want to change the relative levels rather than just move a branch up or down the hierarchy, I'd use custom commands in the input files.

If qqqq.tex looks like

zz zz zz
xx xx xx
\sectB{more things}
ww ww ww

Then one document can go


with everything at the same level, and another can go


with A headings a level down and B headings two levels down

  • I think that just might do it! – mindthief Mar 13 '15 at 9:47

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.