How to change the block template for a specific theorem environment (LaTeX beamer)

Environments of amstism theorems (theorem, example, proof, solution, ...) make blocks on beam sliders. By default, this example environment uses a different template (example block) than a theorem or solution or proof (block).

How to force a solution to use a different template, for example a "block solution", which I can define?

Edit: Thanks to those who answered. I haven't implemented a workaround yet, but it seems like there are two ideas:

  • Override the command \th@foofor the theoretical environment with the name foo. The new command should override \inserttheoremblockenvas the desired block environment. See beamerbasetheorems.sty(near line 63) how this is done specifically for example.

  • Redefine the template theorem beginand theorem endto search for the correct environment of the theorem block based on the global variable \inserttheoremname(see beamerinnerthemedefault.sty). A lookup table can be stored in the registry pgfkeys. This approach will be a little higher and will not include any commands with @; however, YAGNI comes to mind.

+3
source share
1 answer

As seen from 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}}

Whatever style you like. You can also change the appearance of the [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}

(Did not try, just looked at the sources of rays)

EDIT: Still not sure what you want to do, but you can define your own theorem styles:

\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}

(It works, I tested it)

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}}

,

+1

Source: https://habr.com/ru/post/1740316/


All Articles