4

I use the new LaTeX beamer theme mtheme by Matthias Vogelgesang (see http://bloerg.net/2014/09/20/a-modern-beamer-theme.html).

As some section titles are a little longer I tried to break the titles via \newline but this seems to be impossible.

Does anyone see a way to break the section titles in this theme?

Gonzalo Medina
  • 505,128
Simon Z.
  • 153

1 Answers1

4

The problem here is that the section title is included inside a TikZ \node with no provisions for text spanning several lines. The problem can be easily solved in a number of ways, perhaps the simpler one is adding a text width=<length> option to the node, as the following simple example demonstrates:

\documentclass[10pt, compress]{beamer}
\usetheme{m}

\makeatletter
\def\progressbar@sectionprogressbar{%
  {\usebeamercolor{palette primary}%
    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \divide\progressbar@tmpdim by 100
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb
    \multiply\progressbar@tmpdim by 100

    \makebox[\textwidth][c]{
      \begin{tikzpicture}[tight background]

        \node[anchor=west, fg, inner sep=0pt,text width=\linewidth] at (0pt, 0pt) {\insertsectionHEAD};

        \draw[anchor=west, fg!20, fill=fg!20, inner sep=0pt]
        (2pt, -16pt) rectangle ++ (\progressbar@pbwd, \progressbar@pbht);

        \draw[anchor=west, fg, fill=fg, inner sep=0pt]
        (2pt, -16pt) rectangle ++ (\progressbar@tmpdim, \progressbar@pbht);
      \end{tikzpicture}%
    }
  } % end usebeamercolor{palette primary}
}

\makeatother
\begin{document}

\section{Elements and some other longer text so the title spans several lines}
\begin{frame}
test
\end{frame}

\end{document}

The original definition for \progressbar@sectionprogressbar has

\node[anchor=west, fg, inner sep=0pt] at (0pt, 0pt) {\insertsectionHEAD};

The modified version in my example is

\node[anchor=west, fg, inner sep=0pt,text width=\linewidth] at (0pt, 0pt) {\insertsectionHEAD};

The result frame with the section title (notice that line breaking is now allowed and automatic):

enter image description here

Gonzalo Medina
  • 505,128