Tx · LaTeX & TikZ

How to Break a Subsection Title in Beamer

Published By the 9to5Science editorial team

At a glance

  1. 1. Use a Short Title

    Put the navigation version of the subsection title in the optional argument of \subsection.

  2. 2. Insert the Break

    Add a protected line break between the two parts of the short title.

  3. 3. Keep the Full Title

    Use the mandatory argument for the complete subsection title in the document structure.

  4. 4. Check the Theme

    If Copenhagen keeps the title on one line, shorten the navigation title or customize its headline.

Beamer uses two versions of a sectioning title: the mandatory argument is the full title, while the optional argument is the shorter title used in navigation bars, headers, tables of contents, and bookmarks.

For the Copenhagen theme, request the line break in the optional argument of \subsection. When the navigation template permits multiline content, this lets the navigation area use a two-line version while the slide structure retains the complete title.

Basic syntax

\subsection[First line\protect\\Second line]{The complete subsection title}

The \protect makes the line-break command safer in this moving argument. The full title in braces is still the actual subsection title used by Beamer’s document structure.

A shorter navigation title is often better than forcing a break:

\subsection[Background and method]{A detailed background and methodological discussion}

The optional title is not merely a cosmetic duplicate. It is specifically intended for places where the full title does not fit, including the Copenhagen navigation area.

Complete example

The following document demonstrates the usual approach:

\documentclass{beamer}
\usetheme{Copenhagen}

\begin{document}

\section{Methods}

\subsection[Data collection\protect\\and cleaning]
  {Data collection and data-cleaning procedures}

\begin{frame}{Data collection and data-cleaning procedures}
  The subsection title is represented by a shorter, two-line title
  in the navigation area.
\end{frame}

\end{document}

The first optional argument is the version displayed in the navigation bar. The second, mandatory argument is the full subsection title. In a presentation with several subsections, this distinction prevents the navigation bar from becoming too wide.

Keeping PDF bookmarks valid

Section titles are written to auxiliary files and PDF metadata. Formatting commands such as \\ do not belong in a PDF bookmark, so a title containing a line break can produce a hyperref warning or an unsuitable bookmark.

Use \texorpdfstring when you need an explicit PDF-safe alternative:

\subsection[
  \texorpdfstring{First line\protect\\Second line}{First line -- Second line}
]{The complete subsection title}

The first argument of \texorpdfstring is used for typeset output, while the second is used where plain PDF text is required. The bookmark will contain First line -- Second line rather than a literal line-break command.

For many Beamer documents, the simpler form is sufficient:

\subsection[First line\protect\\Second line]{Full subsection title}

Use the longer \texorpdfstring form if your compiler reports warnings from hyperref or if the PDF outline matters.

Why the break may not appear

A line break in the title does not guarantee a visible two-line navigation entry. Some Beamer navigation templates place each subsection in a fixed horizontal box. Such a box is intended for one-line labels, and its contents may overflow, be clipped, or otherwise fail to break onto two lines.

If that happens, the most reliable solution is to shorten the optional title:

\subsection[Data preparation]{Data collection, preparation, and validation}

This is usually preferable in a presentation because the navigation bar remains readable and does not increase the height of every slide.

If the two-line appearance is essential, the theme’s headline or navigation template must be changed so that the subsection entry is given a specified height and can contain a paragraph rather than a single-line horizontal box. That is a theme customization, not a change to the \subsection command itself. The exact redefinition depends on the Beamer version and on whether the theme uses the headline, section in head/foot, or subsection in head/foot templates.

Breaking the title shown on a slide

The subsection title and a frame title are different objects. If the text that needs a break is the title at the top of a frame, put the break in \frametitle instead:

\begin{frame}
  \frametitle{First line\protect\\Second line}
  Slide contents go here.
\end{frame}

For a frame title, no optional sectioning argument is involved. You can also give the frame a shorter navigation title with:

\begin{frame}[t]
  \frametitle[Short frame title]{A longer frame title\protect\\with a line break}
  Slide contents go here.
\end{frame}

Common mistakes

  • Putting the break only in the full argument: The navigation bar normally uses the optional argument, so changing only {Full subsection title} may not change what Copenhagen displays.
  • Using a raw break in a moving argument: Prefer \protect\\ or the \texorpdfstring form for titles written to auxiliary files and bookmarks.
  • Expecting automatic wrapping: A long subsection title is not automatically wrapped by every Beamer theme.
  • Confusing subsection and frame titles: Use \subsection for document navigation and \frametitle for the heading on an individual slide.
  • Making every navigation label multiline: Two-line labels can increase the headline height or cause collisions. A concise optional title is generally the most stable design.

References

  1. The beamer class User Guide

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.