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?

3 Answers 3


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«}}

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

  • Should this solution be prefered to the one egreg presented?
    – Sebastian
    Commented Sep 30, 2011 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
    Commented Sep 30, 2011 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.

  • I don't want to activate or deactivate it globally but individually with * or without
    – Sebastian
    Commented Sep 30, 2011 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .