2

Here is my code:

\documentclass[slidescentered]{beamer}
\usepackage{amsthm,thmtools,xparse}
\makeatletter
\newif\if@namespace\@namespacefalse
\newcommand{\contrel}[2]{
\if@namespace
    Continua da
\else
    #1~--~continua da
\fi
\ #2
}
\thmt@define@thmuse@key{continued}{%
  \thmt@suspendcounter{\thmt@envname}{\thmt@trivialref{#1}{??}}%
  \g@addto@macro\thmt@newoptarg{{}%
    \thm@continues{#1}%
    \@iden}%
}
\newcommand\thm@continues[1]{%
  \ifcsname hyperref\endcsname
    \hyperref[#1]
  \else
    {}
  \fi
  {\contrel{\nameref*{#1}}{\cont@from}}%
}
\makeatother
\declaretheoremstyle[
spaceabove=\topsep, spacebelow=\topsep,
headfont=\normalfont\bfseries,
notefont=\bfseries, notebraces={}{},
bodyfont=\normalfont\itshape,
postheadspace=.5em,
name={\ignorespaces},
numbered=no,
headpunct=.]
{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}moo}
    {\IfValueTF{#4}
        {\gdef\cont@from{#4}
        \begin{@thmattr}[name={\protect\nameref*{#3}},continued=#3]}
        {\IfValueTF{#3}
            {\begin{@thmattr}[name=#1\ #2,label=#3]}
            {\begin{@thmattr}[name=#1\ #2]}
        }
    }
    {\end{@thmattr}}

\begin{document}
\begin{frame}
\begin{teorspec}[Principio]{di D'Alembert}
Foobar.
\end{teorspec}
\end{frame}
\end{document}

Output:

enter image description here

Everything is fine, except those brackets are evidently out of place. Indeed, I said notebraces={}{}, which should have suppressed them, and does suppress them in report, a thing I've been exploiting for the past over a year. So why is beamer putting those brackets back? And how do I get rid of them?

Update

I added the \makeatletter part. THat \if@namespace is for a purpose I don't quite remember, but it seems useless in this particular theorem. Left it to have the code the way it is in the package. I will look into how to get rid of it, perhaps.

Update 2

I accepted egreg's answer since the code he gave solved my problem. However, I would still like to know why the problem was there in the first place. What is beamer doing that conflicts with my code? And more importantly, should I ask a new question about this?

1

I think you're misunderstanding what name does in the options to a theorem. Since I don't understand what continued is for and what \nameref*{#3} is supposed to do, I'll show just the basics:

\documentclass[notheorems,slidescentered]{beamer}
\usepackage{amsthm,thmtools,xparse}

\protected\def\thistheoremname{}
\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\normalfont\bfseries,
  bodyfont=\normalfont\itshape,
  postheadspace=.5em,
  name={\thistheoremname},
  numbered=no,
  headpunct=.]
{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}m}
 {\def\thistheoremname{#1 #2}\begin{@thmattr}}
 {\end{@thmattr}}

\begin{document}
\begin{frame}
\begin{teorspec}[Principio]{di D'Alembert}
Foobar.
\end{teorspec}
\end{frame}
\end{document}

enter image description here

  • You are right that I forgot the definition of continued: copying stuff off a package it is easy to forget bits. It is my personal version of continues or whatever it is. Will add it in soon. The \nameref recovers the name of the theorem in the case it is continued. What would I be misunderstanding about name? In report this behaves as expected.. – MickG Oct 28 '15 at 5:55
  • AFAIK in report, if I use \newtheorem and then provide a name, I get a bold "Thm kind \the thm counter` (name).", then the theorem is typeset in Italics. Does this change in Beamer? With that theorem style, no counter nor kind, and the brackets should be suppressed. No? – MickG Oct 28 '15 at 6:12
  • It does seem strange that after suppressing the name I have a name fed in to the @thmattr, now that I see it... but it always worked... – MickG Oct 28 '15 at 6:24
  • 1
    @MickG beamer does many redefinitions and it's surely possible that tmhtools conflicts with it. – egreg Oct 28 '15 at 7:18
  • 1
    A macro defined as \protected is not expanded when \edef is doing its full expansion of the replacement text. – egreg Oct 29 '15 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.