beamer
目前与软件包不兼容caption
(如这里所述)。我想定义一个附加命令,其工作方式与\caption*
该包的命令类似,即排版标题而不带标签,也不带表格/图形列表中的条目,但格式与常规\caption
命令相同。重要提示:我仍然需要正常\caption
命令,因此我不能只是全局重新定义\setbeamertemplate{caption}
我正在考虑
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{caption}
\begin{document}
\begin{frame}{Some title}
\begin{table}
\begin{tabular}{cc}
A & B \\
C & D \\
\end{tabular}
\caption{Some numbered Table and its description. Even more and more and more text.}
\end{table}
\begin{table}
\begin{tabular}{cc}
A & B \\
C & D \\
\end{tabular}
\caption*{Some unnumbered Table and its description. Even more and more and more text.}
\end{table}
\end{frame}
\end{document}
答案1
这是实现此目的的一种方法;\caption*
继承相同的格式\caption
(特别是,它具有相同的上下跳过和单行功能):
代码:
\documentclass{beamer}
\usepackage{letltxmacro}
\usepackage{xparse}
\LetLtxMacro\oldcaption\caption
\makeatletter
\RenewDocumentCommand\caption{som}{
\IfBooleanTF{#1}
{
\setbeamertemplate{caption label separator}[none]
\def\insertcaptionname{}%
\def\insertcaptionnumber{}%
\def\insertcaption{#3}%
\nobreak\vskip\abovecaptionskip\nobreak
\sbox\@tempboxa{\usebeamertemplate**{caption}}%
\ifdim \wd\@tempboxa >\hsize
\usebeamertemplate**{caption}\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\nobreak\vskip\belowcaptionskip\nobreak
}
{\oldcaption[#2]{#3}}
}
\makeatother
\newcommand\TestTable{%
\begin{tabular}{cc}
A & B \\
\end{tabular}%
}
\begin{document}
\begin{frame}{Some title}
\begin{table}
\TestTable
\caption{Some numbered Table and its description. Even more and more and more text.}
\end{table}
\begin{table}
\TestTable
\caption*{Some unnumbered Table and its description. Even more and more and more text.}
\end{table}
\begin{table}
\TestTable
\caption{Some numbered Table}
\end{table}
\begin{table}
\TestTable
\caption*{Some unnumbered Table}
\end{table}
\end{frame}
\end{document}