TransWikia.com

Thmtools and declaretheoremstyle in Beamer

TeX - LaTeX Asked on April 24, 2021

I am trying to define a custom theorem environment using thmtools. It works as expected in e.g., documentclass{article}, but in beamer I receive the error

"use of ifbeamercolorempty doesn’t match its definition"

and compilation ends. Here is my attempt:

documentclass[10pt,xcolor={dvipsnames},notheorems]{beamer}

usepackage{amsthm,thmtools}
colorlet{theoremblue}{blue!4}
    declaretheoremstyle[
    spaceabove=6pt, 
    spacebelow=6pt,
    headfont=normalfontbfseries,
    notefont=mdseries, notebraces={(}{)},
    bodyfont=itshape,
    postheadspace=1em,
    qed=qedsymbol,
    shaded= {rulecolor=blue,
            rulewidth=2pt, 
            bgcolor=theoremblue
            },
]{myplain}

declaretheorem[name=Theorem, style=myplain]{theorem}

begin{document}
begin{frame}{Test}
begin{theorem}[test]
Let $x$ be ldots
end{theorem}
end{frame}
end{document}

One Answer

To internally redefine the qedsymbol to the value of option qed while allowing usage qed=qedsymbol, thmtools uses protected@edefqedsymbol{<value of option "qed">}. This assumes that the qedsymbol can bear protected@edef. But beamer redefines qedsymbol to

defqedsymbol{leavevmodehbox{usebeamertemplate*{qed symbol}}}

in which usebeamertemplate is fragile hence the whole cannot bear.

In the following example, a protected wrapper of qedsymbol, xqedsymbol is provided, and you can safely use xqedsymbol in the value of key qed.

documentclass[10pt,xcolor={dvipsnames},notheorems]{beamer}
usepackage{amsthm,thmtools}
colorlet{theoremblue}{blue!4}

makeatletter
% a robust wrapper of qedsymbol
protectededefxqedsymbol{unexpandedexpandafter{qedsymbol}}
makeatother

declaretheoremstyle[
    spaceabove=6pt, 
    spacebelow=6pt,
    headfont=normalfontbfseries,
    notefont=mdseries, notebraces={(}{)},
    bodyfont=itshape,
    postheadspace=1em,
    qed=xqedsymbol,
    shaded= {rulecolor=blue,
            rulewidth=2pt, 
            bgcolor=theoremblue
            },
]{myplain}

declaretheorem[name=Theorem, style=myplain]{theorem}

begin{document}
begin{frame}{Test}
  begin{theorem}[test]
    Let $x$ be ldots
  end{theorem}
end{frame}
end{document}

enter image description here

Correct answer by muzimuzhi Z on April 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP