【问题标题】:How do I change the block template for specific theorem environments (LaTeX beamer)如何更改特定定理环境的块模板(LaTeX beamer)
【发布时间】:2010-04-08 13:48:44
【问题描述】:

amsthm 定理环境(定理,示例,证明,解决方案,...)在投影仪幻灯片上制作块。默认情况下,示例环境使用与定理或解决方案或证明(块)不同的模板(块示例)。

如何使解决方案使用我可以定义的不同模板,例如“块解决方案”?

编辑:感谢那些回答。我还没有实施解决方法,但似乎有两个想法:

  • 为名为@9​​87654322@ 的类似定理的环境重新定义\th@foo 命令。新命令应将\inserttheoremblockenv 重新定义为所需的块环境。请参阅beamerbasetheorems.sty(第 63 行附近)了解如何专门针对example 完成此操作。

  • 重新定义theorem begintheorem end 模板以根据全局变量\inserttheoremname 查找正确的定理块环境(请参阅beamerinnerthemedefault.sty)。查找表可以保存在pgfkeys 注册表中。这种方法会有点高级,不会涉及任何带有@ 的命令;但是,我想到了 YAGNI。

【问题讨论】:

    标签: latex beamer


    【解决方案1】:

    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}
    

    (没试过,只是查看了投影仪的来源)

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

    \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 的内部结构之一,以便在开始类似定理的环境时使用“定理开始”模板。该模板启动了一个名为“\insertblockenv”的块环境。此宏在 beamerbasetheorems.sty 中定义为“block”,并且仅在内部 '\th@example' 的覆盖中,'\insertblockenv' 宏才重新定义为“exampleblock”。所以这些是你的选择:如果 theoremstyle 是 example,exampleblock,block o/w。也许模板可以调整?
    • 您要更改现有的块环境还是定义新的块环境?
    • 我想更改现有的块环境。我不希望“定理”和“解决方案”(例如)在同一个 beamercolorbox 中。再过一两天我就没有机会回到这个话题了,但我认为使用 theorem begin 模板中的 PGF 密钥注册表可以完成一些事情。
    • 或者,也许只是破解 \th@solution 来改变 \insertblockenv 就像 beamerbasetheorems.sty 对 \th@example 所做的那样。
    • 你想在我的编辑中完成什么?您是否需要更多块环境或帮助创建新的?
    猜你喜欢
    • 2017-08-01
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    • 2011-03-17
    • 2020-06-19
    • 1970-01-01
    相关资源
    最近更新 更多