[Tex/LaTex] How to end an unnumbered subsection


I cannot find a way to end an unnumbered subsection.
I either have an unnumbered subsection \subsection*{} with no end
or an environment

  This is some arbitrary content.

that is numbered.
Here is a MWE:

  \section{First section}
     \subsection*{Unnumbered subsection}
  Here comes some content that should be in First section but not in the Unnumbered subsection
  This is some arbitrary content. the theoremes number should correspond with the First section but not with the "Unnumbered subsection".
  \section{Second section}

The question is how to make everything comming before the Second section but after the Unnumbered subsection not part of the Unnumbered subsection.

Best Answer

LaTeX does not directly regard \section(s) etc as having "ends": a section "ends" when a new section begins. So \section{} and its ilk are not environments, but commands which mark the beginning of a new section.

What you are really concerned about here is with the way counters are used in labels. But in this your question seems to be under a misapprehension, or perhaps a number of misapprehensions.

In general, if you use a combination of \label{} and \ref{} to refer back to a section number, the number used will be the last number set. So if, for instance, you have:

\section{Numbered}% <- Section 1
\section*{Unnumbered}% <- No number
... \label{mylabel}
... See section \ref{mylabel}

You will still get a reference to "section 1". (If you set the label without any section having been used, you would get no reference: but what is LaTeX to do!.)

If you have, as you suggest, a subsection that is unnumbered, the behaviour is similar. If, before your unnumbered subsection there is a numbered subsection, then the label will refer to that -- i.e. the unnumbered subsection is treated as if it didn't exist.

\section{Numbered}% <- Section 1
\subsection{Numbered}% <- Subs 1.1
See subsection \ref{mylabel}

You will get "subsection 1.1". In other words, the unnumbered section or subsection commands don't "reset" anything, they just leave the label intact. If, however, you had the unnumbered subsection first, you would get just a reference to the section.

\section{Numbered}% <- Section 1
See subsection \ref{mylabel}

would give you "subsection 1".

In other words An unnumbered heading leaves the counters unchanged: you will get whatever reference was "active" immediately before the unnumbered heading, and no reference is none was active.

This means, in fact, that if you had a numbered section and subsection "active" (let's suppose your counters were sitting at "1.3") and then start a new unnumbered section, a reference within that unnumbered subsection will still be "1.3".

Odd as this all seems, most of the time it makes reasonable sense, and in fact in your example it probably does more or less what you want it to. A reference within the unnumbered subsection will just give you a reference to the section. This is probably, usually, correct. In any case, it's not clear what "the right thing" to do with mixtures of numbered and unnumbered sections is, and if you have unnumbered sections you should probably be referring to pages anyway!

Now your theorem is a different story. In principle, a theorem has a counter which is quite independent of the section in which it appears. In your MWE, the théorème will be numbered 1 because it is the first theorem, no matter that it appears in an unnumbered subsection.

You can, however, set your theorems up so that the numbering resets with each section.


If you do that, then:

  • The subsection makes no difference, so in your MWE the theorems will be numbered 1.1, 1.2 etc, even if they come in unnumbered subsections.
  • An unnumbered section would leave the counter unchanged, so that the numbering would continue from the previous section. So ...

    Theorem numbered 1.1
    Theorem numbered 1.2, because section was not reset.
  • If you start a theorem before any numbered section has begun, it will get numbered 0.1, etc.

If you decided to include subsection numbering in your theorems and then mix numbered and unnumbered subsections, your readers will probably kill you, but in principle the same approach will be taken: the previous (numbered) subsection counter will be applied until a new numbered subsection begins.

Related Question