Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
The example gives no error, only with article before the edit. However, you should change the base value of secnumdepth from 0 to -1, see my answer. –  Stefan Kottwitz Oct 31 '11 at 9:21
    
@user7091: There's no need to edit the titles of your questions to inclue keyword |: That's what the tags are for, they get shown directly underneath the question title on the main page. –  Jake Nov 1 '11 at 7:09

2 Answers 2

up vote 10 down vote accepted

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.

share|improve this answer
    
I identified the real problem and posted it here. Thanks for your efforts –  D.Roepo Oct 31 '11 at 19:23

Instead of messing manually with the counters, try the starred versions of the sectioning commands, they exclude numbering (and the entry in the table of contents, for that matter):

\documentclass{article}

\begin{document}

\section*{unnumbered subsections}
\subsection*{unnumbered}

\section*{roman numbered subsections}
\renewcommand{\thesubsection}{\textnormal{\roman{subsection}}.}

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

Edit: If you want to include the starred sections in the ToC again, please read up the procedure in Centering \section* and adding them to the ToC.

share|improve this answer
    
His original code works now because he changed from article to report. report has support for chapters where article does not. –  Roelof Spijker Oct 31 '11 at 9:20
    
Yes it does. I wasn't aware that the problem lay elsewhere. If interested, see here. –  D.Roepo Oct 31 '11 at 19:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.