# How to change subsection to section and subsubsection to subsection?

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

\documentclass[11pt,titlepage]{article}%
\usepackage{standalone}
\standalonetrue

\ifstandalone %building this as standalone?
\renewcommand{\subsection}{\section}
\renewcommand{\subsubsection}{\subsection}
\fi

\begin{document}

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


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

I also tried

\ifstandalone
\let\subsection\section
\let\subsubsection\subsection
\fi


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

\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

\let\subsection\section
\let\subsubsection\subsection


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

\let\subsubsection\subsection
\let\subsection\section


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

But why not just

\ifstandalone
\section{dummy section title}
\fi