I remember learning how to to this long time ago, but I can't figure now how.

And google search is not turning anything.

I have a standalone latex file which starts with subsection because this file is part of a larger document which will be all bundled using the standalone package into one large document.

But when I build this specific file on its own, I want the subsection to become section and the subsubsection to become subsection. This is what I tried


\ifstandalone %building this as standalone?


\subsection{Problem 1} %this should become \section when standalone
\subsubsection{Part a} %this should become \subsection when standalone
\subsubsection{Part b}

But when I compile the above using lualatex then both the subsection and the subsubsection become section.

Mathematica graphics

I also tried


same result.

What is the correct way to do this? The fix must only be in the preamble as shown above, nothing after the \begin{document}

Using TL 2018

1 Answer 1


\renewcommand shouldn't work because it expands to whatever those are at the time you end up using them (ie, when you use the commands in your document, everything gets redefined to section). \let changes the left to become whatever the right is at that moment. With


\subsection becomes \section, and then \subsubsection becomes \subsection (which you just made \section). It should work to reverse the \lets:


Then \subsubsection gets the same definition as \subsection, and \subsection gets the same definition as \section.

But why not just

\section{dummy section title}

instead of redefinitions?

  • Thanks. I remember now. It was the order trick. I've done this before as I said, but forgot how :) . As for why not the second way you show, it is because having it redefined in preamble means I do not need to add the code everywhere again in the document around each subsection, etc...in preamble, it is done once only.
    – Nasser
    Sep 14, 2018 at 3:41

You must log in to answer this question.

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