TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a LaTeX article, \section* behaves like this:

\documentclass[12pt]{article} \begin{document}
\section*{Not numbered} \thesection % --> 0
\section{Numbered} \thesection % --> 1

However, with beamer the following happens:

\documentclass[12pt]{beamer} \begin{document}
\section*{Not numbered} \frame{\thesection}  % --> 1
\section{Numbered} \frame{\thesection} % --> 2

Why is this? Could I correct this behaviour?

Now, what I actually need is a command \secnr for beamer that will print nothing when in a starred section and the correct -viz. documentclass article- numbering in unstarred sections. So that would require:

  1. Fixing the numbering misbehavious in beamer
  2. An if to test "if current section is starred ..."

A solution to either (or both) of these problems would be very welcome.

share|improve this question
up vote 2 down vote accepted

beamer implements \section* in a different way. The actual section number is kept in the (TeX) counter \beamer@tocsectionnumber, which is not advanced when \section* is found.

A possible solution to your problems is

\patchcmd\beamer@section{by 1\relax}
  {by 1\relax\xdef\secnr{\the\beamer@tocsectionnumber}\global\starredfalse}{}{}

This defines \secnr as you want: in a \section* it expands to nothing, while in a \section it expands to the section's number. The \ifstarred conditional is true after a \section* and false after a \section.

share|improve this answer
Thank you! Those pretocmd and patchcmd macros are stunning. – Archibald Jul 29 '11 at 10:50

Your Answer


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.