我已经应用了问题的答案投影仪中定理名称后面紧接着的定理内容回答我的问题。我在 \inserttheorempunctuation 后面放了 \normalfont,但结果出乎意料。请看图 1。
\documentclass[envcountsect]{beamer}
\usetheme{CambridgeUS}
\usefonttheme{serif}
\makeatletter
\setbeamertemplate{theorem begin}
{%
\begin{\inserttheoremblockenv}
{%
\inserttheoremheadfont
\inserttheoremname
\inserttheoremnumber
\ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi%
\inserttheorempunctuation
\normalfont
}
}
\setbeamertemplate{theorem end}{\end{\inserttheoremblockenv}}
\makeatother
\begin{document}
\section{ABC}
\begin{frame}
\begin{theorem}[ABC]
This is a theorem
\end{theorem}
\end{frame}
\end{document}
结果是:
我想把内容放在后面定理(没有换行符)。它看起来像这样
答案1
您需要将格式命令放入正文中,而不是标题中,theoremblockenv
并选择block title
标题元素的字体和颜色以模仿您要求的样式。与有标题和无标题的两个块示例进行比较。
\documentclass[envcountsect]{beamer}
\usetheme{CambridgeUS}
\usefonttheme{serif}
\usepackage{etoolbox}
\makeatletter
\setbeamertemplate{theorem begin}
{%
\begin{\inserttheoremblockenv}
{}{\usebeamerfont*{block title}\usebeamercolor[fg]{block title}%
\inserttheoremname
\inserttheoremnumber
\ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
\inserttheorempunctuation}
\normalfont
}
\setbeamertemplate{theorem end}{\end{\inserttheoremblockenv}}
\makeatother
\begin{document}
\section{ABC}
\begin{frame}
\begin{theorem}[ABC]
This is a theorem
\end{theorem}
Text.
\begin{block}{Block title}
A block with title.
\end{block}
Text.
\begin{block}{}
A block without title.
\end{block}
\end{frame}
\end{document}