我正在使用\truncate
和\insertsectionhead
在 beamer 环境中。在某些情况下,编译会崩溃。有关更多详细信息,请考虑此 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}
当需要截断节头以适应指定的大小时,编译会失败,并显示
TeX capacity exceeded, sorry [pdf link stack size=10]. \begin{frame} 10 \end{frame}
通过将章节名称更改为更短的标题或减少幻灯片数量,可以避免这种情况。
使用\show\insertsectionhead
,我已经找到了定义
\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}
似乎\the\c@page
保留了定义节名的页码。但是,我无法通过手动执行类似以下操作来重现错误
\begin{frame}
\truncate{15pt}{\hyperlink{Navigation2}{This fails}}
\end{frame}
\begin{frame}
\truncate{15pt}{\hyperlink{Navigation2}{This fails}}
\end{frame}
...
由于没有 就不会发生此错误\truncate
,因此我想在不增加 TeX 堆栈大小的情况下修复它。有谁知道更基本的 MWE(不使用 beamer)或解决此问题的方法?
答案1
对复杂的参数使用 \truncate 不是一个好主意。您必须修补内部 beamer 命令。
\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}