如何为特定的定理环境更改LaTeX beamer中的块模板

4
amsthm定理环境(theorem,example,proof,solution等)在beamer幻灯片上创建了块。默认情况下,example环境使用不同的模板(block example),而theorem、solution或proof(block)则不同。
如何使solution使用像“block solution”这样我可以定义的不同模板?
编辑:感谢那些回答的人。我还没有实施解决方法,但似乎有两个想法:
1.重新定义名为"foo"的类似定理的环境的\th@foo命令。新命令应重新定义\inserttheoremblockenv为所需的块环境。具体请参见beamerbasetheorems.sty(大约63行)中为example特别完成此操作。
2.重新定义定理开始和定理结束模板,以基于全局变量\inserttheoremname查找正确的定理块环境(请参见beamerinnerthemedefault.sty)。查找表可以保留在pgfkeys注册表中。该方法稍微高级一些,不涉及任何带有@的命令;但是,可能用不到。
1个回答

2

如在beamerbasetheorems.sty中所见:

\documentclass[notheorems]{beamer}

\theoremstyle{plain}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

% or

\theoremstyle{definition}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

% or

\theoremstyle{example}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

无论你喜欢哪种风格,你都可以改变[alert|example]块的外观:

\setbeamercolor{block body}{fg=blue,bg=white}
\setbeamercolor{block body alerted}{fg=blue,bg=white}
\setbeamercolor{block body example}{fg=blue,bg=white}

(我没有尝试过,只是查看了beamer的源代码)

编辑:仍然不确定你想要做什么,但是您可以定义自己的定理样式:

\makeatletter
\def\th@something{%
  \normalfont % body font
  \def\inserttheoremblockenv{alertblock}  
}
\theoremstyle{something}
\newtheorem{warn}[theorem]{WARNING}
\makeatother

\begin{warn}[Attention please]
This is dangerous
\end{warn}

这个是有效的,我已经测试过了。

你有3个预定义的块,可以使用 \defbeamertemplate 进行自定义。请参考文档和源代码了解如何操作。如果你需要更多的块环境,可以看看 basebeamerlocalstructure.sty

  \newenvironment<>{alertblock}[1]{%
    \begin{actionenv}#2%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%\usebeamerfont{block}%
        \setbeamercolor{local structure}{parent=alerted text}}%
      \usebeamertemplate{block alerted begin}}
    {\par%
      \usebeamertemplate{block alerted end}%
    \end{actionenv}}

希望能对您有所帮助。

我真正想做的是创建一个新的定理/示例/警告块的替代方案。beamerbasetheorems.sty 覆盖了 amsthm 的一个内部函数,以便在开始类似定理的环境时使用“theorem begin”模板。该模板启动了一个名为 '\insertblockenv' 的块环境。该宏在 beamerbasetheorems.sty 中被定义为“block”,仅在内部 '\th@example' 的覆盖中,'\insertblockenv' 宏被重新定义为“exampleblock”。因此,这些是您的选择:如果定理样式是示例,则为 exampleblock,否则为 block。也许可以调整模板? - Matthew Leingang
你想修改现有的块环境还是定义一个新的块环境? - Meinersbur
我想要更改一个现有的块环境。我不希望"theorem"和"solution"(例如)在同一个beamercolorbox中。我会再过一两天才能回来处理这个问题,但我认为可以使用PGF的键注册表在theorem begin模板中实现一些功能。 - Matthew Leingang
或者,也许只需黑客\th@solution来更改\insertblockenv,就像beamerbasetheorems.sty对\th@example所做的那样。 - Matthew Leingang
你在我的编辑中想要实现的是什么?你需要更多的代码块环境还是帮助创建新的环境? - Meinersbur

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接