我需要引用\frametitle
我已用新命令标记的部分\mylabel
。以下是代码
\documentclass{beamer}
\makeatletter
\newcommand*{\mylabel}[2]{%
\@bsphack
\begingroup
\def\@currentlabel{#2}%
\label{#1}%
\endgroup
\@esphack
}
\makeatother
\begin{document}
\section[Title 1]{This is a long title that gos on very long long long long long
long long title more long long }{\mylabel{LabelTopic1}{This is a long title that
gos on very long long long long long long long title more long long }}
\frame<presentation>{\frametitle{\ref{LabelTopic1}}}
\end{document}
这就是我所得到的
问题是名称太长,一行frametitle放不下,而且行没有换行。我认为命令中缺少了一些东西\mylabel
。但我不知道是什么。
感谢您的任何帮助
答案1
标题和章节名称就是所谓的移动参数,其中的宏应该受到保护,以免受到厄运和荷兰天气的影响。(如果感兴趣,可以额外阅读:为什么要使用 \DeclareTextFontCommand 而不是 \newcommand?)编译两次
\documentclass{beamer}
\makeatletter
\newcommand*{\mylabel}[2]{%
\@bsphack%
\begingroup%
\def\@currentlabel{#2}%
\label{#1}%
\endgroup%
\@esphack%
}
\makeatother
\begin{document}
\section[Title 1]{This is a long title that gos on very long long long
long long long long title more long long }{% Watch the next line
\protect\mylabel{LabelTopic1}{This is a long title that gos on very
long long long long long long long title more long long}%
}
\frame<presentation>{\frametitle{\ref{LabelTopic1}}}
\end{document}