# Surtitle for section?

I'm writing a book in which I would like certain sections to have a "surtitle" like this:

I would probably like the table of contents entry to look like "Science and Society: The Galileo Affair," and the page header to say "The Galileo Affair."

The closest I can think of is something like this:

\section[The Galileo Affair]{Science and Society: The Galileo Affair}


But this won't give me the visual layout shown above, and the initial part of the title won't appear in the TOC.

Is there any package that gives a straightforward way to accomplish this?

• titlesec may be able to do this, but with complicated layouts I generally just start a document class from scratch. Then again, I have a tendency to re-invent the wheel. – Sean Allred Jan 10 '15 at 20:06
• Is this the equivalent of the \part? – Uwe Ziegenhagen Jan 10 '15 at 20:18
• @UweZiegenhagen: No, the surtitle only applies to section 1.7 in my example. Section 1.8 would not be about science and society. – Ben Crowell Jan 10 '15 at 20:27

You can try this code. Use \sectionsurtitle{....} before the sections where you want the surtitle. Note that you can used a starred version \sectionsurtitle* for unnumbered sections.

\documentclass{scrartcl}
\usepackage{lipsum}

\usepackage{suffix}

\newcommand\sectionsurtitle[1]{\surtitletoc{#1}\printsectionsurtitle{#1}}
\WithSuffix\newcommand\sectionsurtitle*[1]{\printsectionsurtitle{#1}}

\makeatletter
\newcommand{\printsectionsurtitle}[1]{%
{\parindent0pt\vspace*{20pt}%
\sffamily\uppercase{#1}%
\par\nobreak}
}
\newcommand{\surtitletoc}[1]{%
\protect\contentsline{section}%
{\mdseries\sffamily\protect\scriptsize\uppercase{#1}}{}{}}
}
\makeatother

\begin{document}
\tableofcontents

\bigskip

\sectionsurtitle{Science and society}
\section{The Galileo Affair}
\lipsum[1]

\sectionsurtitle{Art}
\section{The Michelangelo Affair}
\lipsum[1]

\section{A normal section}
\lipsum[1]

\sectionsurtitle*{Nothing}
\section*{A unnumbered section}
\lipsum[1]
\end{document}


Output:

EDIT

After your comment I think that you can use this code:

\documentclass{scrbook}
\usepackage{lipsum}

\usepackage{suffix}

\newcommand\sectionsurtitle[2]{\printsectionsurtitle{#1}\section[#1: #2]{#2}\sectionmark{#2}}
\WithSuffix\newcommand\sectionsurtitle*[2]{\printsectionsurtitle{#1}\section*{#2}}

\makeatletter
\newcommand{\printsectionsurtitle}[1]{%
{\parindent0pt\vspace*{20pt}%
\sffamily\uppercase{#1}%
\par\nobreak}
}
\makeatother

\begin{document}
\tableofcontents

\bigskip

\chapter{Test}

\sectionsurtitle{Science and society}{The Galileo Affair}
\lipsum[1]

\sectionsurtitle{Art}{The Michelangelo Affair}
\lipsum[1]

\section{A normal section}
\lipsum[1]

\sectionsurtitle*{Nothing}{A unnumbered section}
\lipsum[1]
\end{document}


Output:

and the ToC

• Thanks, that was very helpful! I had in mind something slightly different for the table of contents. Also, since I have leading dots in my ToC, your code produced an extra line of them. What worked for me was to do the following variation on your code: \newcommand\sectionwithsurtitle[3]{\printsectionsurtitle{#1}\section[#1: #3]{#2}\sectionmark{#3}} – Ben Crowell Jan 10 '15 at 21:03
• @BenCrowell You're welcome. See the edit. – karlkoeller Jan 10 '15 at 21:54

I'd go with a key-value syntax:

\documentclass[openany]{book}
\usepackage{titlesec}
\usepackage{xparse}

\titleformat{\section}
{\normalfont\Large\sffamily\printcurrentsurtitle}
{\thesection}
{1em}
{}

\ExplSyntaxOn

\keys_define:nn { crowell/section }
{
surtitle .tl_set:N = \l_crowell_section_surtitle_tl,
toc      .tl_set:N = \l_crowell_tocentry_tl,
}

\NewDocumentCommand{\Section}{sO{}m}
{
\keys_set:nn { crowell/section }
{
surtitle = {},
toc = { #3 },
#2
}
\IfBooleanTF{#1}
{\section*{#3}}
{
\section[
\tl_if_empty:NF \l_crowell_section_surtitle_tl
{ \l_crowell_section_surtitle_tl : ~ }
\l_crowell_tocentry_tl
]{#3}
}
}

\NewDocumentCommand{\printcurrentsurtitle}{ }
{
\tl_if_empty:NF \l_crowell_section_surtitle_tl
{
\mbox{\normalsize\MakeUppercase{\l_crowell_section_surtitle_tl}}\par
}
}

\ExplSyntaxOff

\begin{document}

\tableofcontents

\chapter{Title}

\Section[surtitle=Science and Society]{The Galileo Affair}

\Section{No surtitle for this one}

\Section*[surtitle=Unnumbered]{Section}

\Section[
surtitle=Science and Society,

Note that the value given for toc= is what's added next to the surtitle in the TOC; in the header you'll get the section title, or what's specified as value for header= (in this case page 3 will have “TGA”.