1

I'm using \truncate and \insertsectionhead in a beamer environment. Under certain conditions, compilation crashes. For more detail, consider this MWE:

\documentclass[t]{beamer}

\usepackage[british]{babel}
\usepackage{biblatex}
\usepackage{truncate}

\title{The wizard of Oz}
\author{L. Frank Baum}
\date{\today}
\institute{Somewhere Over the Rainbow}

\setbeamertemplate{headline}
{
    \vspace{0.3cm}
    % If (and only if) the sectionhead needs to be truncated, compilation fails
    \truncate{15pt}{\insertsectionhead} 
    % Inserting the non-truncated sectionhead instead always works fine
    %\insertsectionhead
    \hfill
    \insertshorttitle
}

\begin{document}
\frame[plain]{\titlepage}

% If (and only if) the sectionhead needs to be truncated, compilation fails

% This isn't truncated -> works
% \section*{Works}

% This will be truncated -> fails
\section*{This fails}

\begin{frame} 1 \end{frame}
\begin{frame} 2 \end{frame}
\begin{frame} 3 \end{frame}
\begin{frame} 4 \end{frame}
\begin{frame} 5 \end{frame}
\begin{frame} 6 \end{frame}
\begin{frame} 7 \end{frame}
\begin{frame} 8 \end{frame}
\begin{frame} 9 \end{frame}
\begin{frame} 10 \end{frame}
\end{document}

When the sectionhead needs to be truncated to fit the specified size, compilation fails with

TeX capacity exceeded, sorry [pdf link stack size=10]. \begin{frame} 10 \end{frame}

By changing the section name to a shorter title or by reducing the number of slides, this can be avoided.

Using \show\insertsectionhead, I already found the definition

\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}

where \the\c@page seems to stay the page number where the section name was defined. However, I am not able to reproduce the error by manually doing something like

\begin{frame} 
\truncate{15pt}{\hyperlink{Navigation2}{This fails}}
\end{frame}

\begin{frame} 
\truncate{15pt}{\hyperlink{Navigation2}{This fails}}
\end{frame}

...

As this error doesn't happen without the \truncate, I'd like to fix it without increasing the TeX stack size. Does anyone know a more basic MWE (without using beamer) or a solution to this problem?

1 Answer 1

1

Using \truncate on an complicated argument is not a good idea. You will have to patch the internal beamer command.

\documentclass[t]{beamer}

\usepackage[british]{babel}
\usepackage{biblatex}
\usepackage{truncate}

\title{The wizard of Oz}
\author{L. Frank Baum}
\date{\today}
\institute{Somewhere Over the Rainbow}

\usepackage{xpatch}
\makeatletter
\newcommand\truncinsertsectionhead{}
\xpatchcmd\beamer@section{\beamer@resumemode}
{
 \edef\truncinsertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{\truncate{15pt}{#1}}}}%
 \beamer@resumemode
}{}{\fail}

\setbeamertemplate{headline}
{
    \vspace{0.3cm}
    \truncinsertsectionhead
    \hfill
    \insertshorttitle
}

\begin{document}
\frame[plain]{\titlepage}

% If (and only if) the sectionhead needs to be truncated, compilation fails

% This isn't truncated -> works
% \section*{Works}

% This will be truncated -> fails
\section*{This fails}

\begin{frame} 1 \end{frame}
\begin{frame} 2 \end{frame}
\begin{frame} 3 \end{frame}
\begin{frame} 4 \end{frame}
\begin{frame} 5 \end{frame}
\begin{frame} 6 \end{frame}
\begin{frame} 7 \end{frame}
\begin{frame} 8 \end{frame}
\begin{frame} 9 \end{frame}

\begin{frame} 10 \end{frame}
\end{document}
1
  • 1
    This works perfectly, thanks!
    – matsewe
    Sep 9, 2019 at 8:51

You must log in to answer this question.

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