Macro for promoting sections to chapters

by PadawanLondon   Last Updated September 11, 2019 18:23 PM

I have a document where I would like to "promote" all sections to chapters, all subsections to sections, etc. That should affect not only the table of contents, but the documents as a whole.

For example:

\section{Title A}
\subsection{Title B}
\subsubsection{Title C}

Should actually be treated as if the document was like this:

\chapter{Title A}
\section{Title B}
\subsection{Title C}

I searched in this website how to do it, but most of the answers seem to focus on the table of contents. I tried to do it myself by adding the following to my document:


However what I get with that is that everything becomes a chapter, as if it is applied recursively. So the result is as if the document was like this:

\chapter{Title A}
\chapter{Title B}
\chapter{Title C}

Does anyone have an idea of how I can get what I need with minimal changes to the original tex files (possibly none, since it is a huge document with many sections)?

Thank you!

Answers 2

One option:




\section{Test section to chapter}
\subsection{Test subsection to section}
\subsubsection{Test subsubsection to subsection}
\paragraph{Test paragraph to subsubsection}
\subparagraph{Test subparagraph to paragraph}


An image of the document with the \let lines commented out:

enter image description here

An image of the same document with the \let lines active:

The ToC:

enter image description here

and the first page of the body:

enter image description here

Gonzalo Medina
Gonzalo Medina
February 19, 2014 13:33 PM

If you mean you want to make this action nearly automatic, you could use the C-c = option in reftex with the AUCTeX package. From there, use > or < to promote or demote the relevant portion of the document. This brings with it the sub-portions of those documents.

Jason Hemann
Jason Hemann
September 11, 2019 17:37 PM

Related Questions

Updated July 23, 2015 14:10 PM

Updated June 27, 2017 16:23 PM

Updated June 25, 2018 17:23 PM

Updated March 19, 2017 12:23 PM

Updated October 04, 2017 01:23 AM