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.

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

I use the following command to have section headings with subtitles

\newcommand{\Section}[2]{\section[#1]{#1\\\small »#2«}}

But now I only can have numbered sections because the * doesn't work for my own command. How can I have my command working both ways, with and without the asterisks?

share|improve this question
up vote 9 down vote accepted

This is the standard way to define *-variants:

\newcommand{\@xyzstar}<what to do when there's a *>
\newcommand{\@xyz}<what to do when there's not a *>

In you case it's probably

\newcommand{\@Sectionstar}[2]{\section*{#1\\\small »#2«}}
\newcommand{\@Section}[2]{\section[#1]{#1\\\small »#2«}}
share|improve this answer

The xparse package provides an intuitive means for incorporating stars * in commands. Conditioning on whether you are using a starred/unstarred version is done using \IfBooleanTF:

\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\usepackage{xparse}% http://ctan.org/pkg/xparse
\NewDocumentCommand{\Section}{s m m}{
    {\section*{#2\\\small \guillemotright #3\guillemotleft}}% Unnumbered section
    {\section[#2]{#2\\\small \guillemotright #3\guillemotleft}}% Numbered section
\Section{First section}{first title}
\Section*{Second section}{second title}

enter image description here

share|improve this answer
Should this solution be prefered to the one egreg presented? – Sebastian Sep 30 '11 at 19:10
@Sebastian: This might be a user preference. If you're comfortable with @egreg's solution and it is easy for you to modify, then that's that. Otherwise, for me, xparse is easy to read in terms of the code, rather than following a sequence of commands. In my answer, xparse is an additional package that has to be loaded (that comes with additional functionality). In @egreg's answer, manual definition of 2 commands is required (one for the starred * and one for the unstarred version). your choice. – Werner Sep 30 '11 at 19:17

It might be preferable to control section numbering globally. That is, you use non-asterisk sectioning commands everywhere in your document and then you use a command to say which section levels will be numbered.

Here's how to do it. If you place


in your preamble, then only the highest level section will be numbered.

share|improve this answer
I don't want to activate or deactivate it globally but individually with * or without – Sebastian Sep 30 '11 at 9:05

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.