# Duplicate and modify section hierarchy

In a large thesis style document being prepared, there are certain parts (latex hierarchy \part{}) that are being treated as insertions of previously prepared work. This may include articles or abstracts which are more suited to hierarchal division within the part using sections (skipping chapters). Mainly this is to avoid "Chapter X" with the radically different chapter formatting.

I would like to copy (probably newcommand) and subsequently redefine the section command to only include the section number so that I can call a latex command called \papersection{} which will not contain the chapter prefix ex. ( 1. Intro. )

For completeness I would like to be able to share the formatting and hierarchy for the \papersection*{} equivalent if possible.

\documentclass{report}
%\usepackage{chngcntr}
%\counterwithin{figure}{section}
\begin{document}
\part{(First Part)}
\section{Intro}
Since this part is for a research paper - the article class would be more appropriate but the report class has been used for the rest of the document as numbering hierarchy such as 1.1 is desired.

Would rather be using \papersection{Intro} so that all my sections do not include the repetitive and unnecessary 1.x

\end{document}


Alternately (and this would be my preferred approach), can a \begin{x} ... \end{x} environment command be issued to temporarily redefine the \documentclass template being used? In this context, it would have to be compatible with nested environments such as bibunits, tables, figures, equations, etc.

\documentclass{report}
\begin{document}
\part{(First Part)}
\begin{PaperEnvironment}% open up an environment that refers to the article class

\section{Intro}
Can I change documentclass templates mid stream?  If so, I don't have to redefine section anymore...

\end{PaperEnvironment}
\end{document}


The document is being prepared using a custom cls file based on the report template. I cannot switch to memoir, book, scrreport, etc. at this time.

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
– cfr
Dec 22, 2014 at 0:53
• The only way to use distinct classes in the same document is to compile the sub-documents separately and to then include them as PDFs, say. This is straightforward. But you cannot switch to a different document class in the middle of a document.
– cfr
Dec 22, 2014 at 0:54
• Does the custom class redefine any of the sectioning commands e.g. \section or whatever? If I compile your MWE, for example, I get 0.1 - not 1.1.
– cfr
Dec 22, 2014 at 0:57

It is not possible to use more than one document class in a single document unless you compile sub-documents separately and include the compiled files with a package such as pdfpages. If that is not an option, you could define a new environment - paper, say - which removes the chapter number when typesetting sections at the beginning of the environment, and restores it at the end. This is simpler than duplicating the entire \section command because we can just change \thesection.

I am not sure what you mean about the starred sectioning commands since those do not have a number anyway.

\documentclass{report}
\usepackage{kantlipsum}
\makeatletter
\newenvironment{paper}{%
\global\let\oldthesection\thesection
\renewcommand{\thesection}{\@arabic\c@section}%
}{%
\global\let\thesection\oldthesection}
\makeatother
\begin{document}
\chapter{Chapter First}
\kant[1]
\section{Kant}
\kant[2]
\section{Kant Again}
\kant[3]
\chapter{Chapter Second}
\kant[4]
\part{(First Part)}
\begin{paper}
\section{Intro}
Since this part is for a research paper - the article class would be more appropriate but the report class has been used for the rest of the document as numbering hierarchy such as 1.1 is desired.

Would rather be using \section{Intro} so that all my sections do not include the repetitive and unnecessary 1.x
\end{paper}
\part{Second Part}
\chapter{More Kant}
\kant[5]
\section{Kant Keeps Going}
\kant[6]
\end{document}


• Thanks, that's what I was indeed envisioning when I was asking for an environment block - didn't realize that renewcommands could be applied to an existing command but restrict the scope to a new declaration. Dec 22, 2014 at 3:28
• @EngBIRD What the code actually does is make a copy of the standard command before redefining it, and then restores the old version by copying it back at the end. Glad it helps ;). It is a lot easier than duplicating the entire apparatus of \section ;).
– cfr
Dec 22, 2014 at 3:30
• To try and clarify the reason behind the * aspect. I have redefined the formatting used for the major hierarchy types throughout the document in my class file, but each paper will require custom formatting (which is why I thought the easiest way to adjust the formatting would be with a newcommand of section called papersection). Since this new formatting style still needs to be parallel (in the absence of numbers) I assumed I would still need to redefine a version with the * equivalent. I assume I will be able to include commands that control formatting in the redefinition. Dec 22, 2014 at 3:32
• Could you potentially point me to a resource where I can learn more about \let and \global \c@ etc. It would be great to learn how these are assembled and work so that their complexity (i.e. to include formatting controls) could be applied. Thanks! Dec 22, 2014 at 3:38
• @EngBIRD Yes... But I've only redefined the section number. If you need to redefine other commands also, you will need to copy those commands first and then restore them at the end.
– cfr
Dec 22, 2014 at 3:38