![{beamer} 使用 \insertsection 加载图像时出现错误:超出 TeX 容量,抱歉](https://linux22.com/image/384943/%7Bbeamer%7D%20%E4%BD%BF%E7%94%A8%20%5Cinsertsection%20%E5%8A%A0%E8%BD%BD%E5%9B%BE%E5%83%8F%E6%97%B6%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%EF%BC%9A%E8%B6%85%E5%87%BA%20TeX%20%E5%AE%B9%E9%87%8F%EF%BC%8C%E6%8A%B1%E6%AD%89%20.png)
我正在尝试为部分框架设置模板。在此框架上,我想加载按部分标题选择的图像,如中所述这个问题。
但是当应用建议的解决方案时,我得到了一个无限循环。以下 MWE 引发错误:
\documentclass{beamer}
\usetheme{default}
\usepackage{graphicx}
\usepackage{inputenc}
\usepackage[space]{grffile}
\begin{document}
\section{some section name}
\begin{frame}{\insertsectionhead}
\insertsectionhead
% this line causes:
% TeX capacity exceeded, sorry [input stack size=5000]. \section{some section name}
\includegraphics[draft]{\insertsectionhead}
\end{frame}
\end{document}
如何使用节名作为文件名以\includegraphics{}
避免无限循环?
答案1
无耻地向@egreg 的精彩回答:
\documentclass{beamer}
\usetheme{default}
\usepackage{graphicx}
\usepackage{inputenc}
\usepackage[space]{grffile}
\newcommand\insertsectionHEAD{%
\expandafter\insertsectionHEADaux\insertsectionhead}
\def\insertsectionHEADaux#1#2#3{#3}
\begin{document}
\section{some section name}
\begin{frame}
\includegraphics[draft]{\insertsectionHEAD}
\end{frame}
\end{document}
稍后会解释,我现在必须走了……