[Tex/LaTex] Numbering subsections in one section only

numberingsectioning

I have a document in which I generally do not want to number the chapters, sections and subsections. Only one section should contain roman numbered subsections, how do I achieve that? I tried

\documentclass{report}
\setcounter{secnumdepth}{-1}

\begin{document}

\chapter{mwe}
\section{unnumbered subsections}
\subsection{unnumbered}

\section{roman numbered subsections}
\setcounter{secnumdepth}{2}
\renewcommand{\thesubsection}{\textnormal{\roman{subsection}}.}

\subsection{roman one}
\subsection{roman two}
\end{document}

However, this gives me an error at the \section{roman one} stating: Missing number treating as zero. Any suggestions for correction or ideas on alternative approaches?

Best Answer

If you change the document class from article to book or report, your document works without error. The code in your question uses the \chapter command which is undefined in the article class. Try:

\documentclass{book}
\setcounter{secnumdepth}{-1}
\begin{document}
\tableofcontents
\chapter{mwe}
\section{unnumbered subsections}
\subsection{unnumbered}
\section{roman numbered subsections}
\setcounter{secnumdepth}{2}
\renewcommand{\thesubsection}{\textnormal{\roman{subsection}}.}
\subsection{roman one}
\subsection{roman two}
\setcounter{secnumdepth}{-1}
\chapter{Second chapter}
\section{unnumbered subsections}
\subsection{unnumbered}
\end{document}

Sometimes it's good to use \addtocounter instead of \setcounter, so you could raise or lower the numbering level without using the absolute value.

Also, as you can see, I used the counter value -1 for not numbering chapters, instead of 0.

In general, I think it's a bit inconsistent to change the numbering depth within a document.