How to redefine the theorem environment like beamer?

I am trying to prepare a slides from the lecture notes which is already prepared in latex. If the notes is not prepared already, tcbtheorem is a wellknown way to showcase the theorem environment. But somehow I cant use it because tcbtheorem uses two arguments for title and reference like

\begin{definition}{Elementary Set}{label here}

defintion goes here

\end{definition}


whereas, we have already typed as

\begin{definition}[Elementary Set]\label{def:elementaryset}
If $A$ is union of a finite number of intervals, $A$ is said to be an elementary set. Set of all elementary sets in ${\mathbb{R}}^p$ is denoted by $\mathcal{E}$.
\end{definition}


in all the 50page notes in amsthm style. So, the way to acheive what we want is to redefine the theorem environment so that it look like beamer theorem environment. For that purpose, I have taken etoolbox and tcolorbox as a tool. Here is my MWE.

\documentclass[serif,fontsize=11pt]{article}

\usepackage{etoolbox,amssymb}
\usepackage[many]{tcolorbox}

\newtheorem{definition}{Definition}[section]

\AtBeginEnvironment{definition}{\begin{tcolorbox}[title=Definition]}
\AtEndEnvironment{definition}{\end{tcolorbox}}

\begin{document}

\begin{definition}[Elementary Set]\label{def:elementaryset}
If $A$ is union of a finite number of intervals, $A$ is said to be an elementary set. Set of all elementary sets in ${\mathbb{R}}^p$ is denoted by $\mathcal{E}$.
\end{definition}

\end{document}


The out shows something like,

My requirement:

Definition 0.1(Elementary set) should come in the title of the tcolorbox.

How to achieve this?

Thanks in advance!! TeX masters...

• Why don't you use the \newtcbtheorem macro instead? – user31729 Oct 5 '17 at 17:47
• I already have hand ready document with me as lecture notes..@ChristianHupfer – David Oct 5 '17 at 17:49
• And tcbtheorem uses two arguments for title and reference like \begin{definition}{Elementary Set}{label here} which I may not be able to change in my lecture notes..right?? – David Oct 5 '17 at 17:51
• You should add this information to your post. – user31729 Oct 5 '17 at 17:52
• Thanks for the notices. I have edited my question @ChristianHupfer. – David Oct 5 '17 at 18:04

1 Answer

Since \newtcbtheorem has a different setup, especially with the label argument, I suggest to use a \renewtcolorbox{definition} and faking the title line.

Using beamer option even provides the beamer look.

The label mechanism is done either with label= or \label if the \@currentlabel macro is defined manually in before upper={\protected@edef\@currentlabel{...}} -- but using label= is the better way to go here.

\documentclass[serif,fontsize=11pt]{article}

\usepackage{etoolbox,amssymb}
\usepackage[many]{tcolorbox}

\newtheorem{definition}{Definition}[section]

\makeatletter
\renewtcolorbox[use counter=definition,number within=section]{definition}[1][]{
enhanced,beamer,
title={Definition \thedefinition\ (#1)},
before upper={\protected@edef\@currentlabel{\csname p@definition\endcsname\csname thedefinition\endcsname}}
}
\makeatother

\begin{document}

\begin{definition}[Elementary Set] \label{Foo}
If $A$ is union of a finite number of intervals, $A$ is said to be an elementary set. Set of all elementary sets in ${\mathbb{R}}^p$ is denoted by $\mathcal{E}$.
\end{definition}

See \ref{Foo}

\end{document}


• Its perfectly what I want..but the reference is not working.. – David Oct 5 '17 at 18:08
• @David. Your example does not have a reference – user31729 Oct 5 '17 at 18:09
• Sorry for the late reply. I have edited my post just when you were answering my question. And this does not break through pages as it does in tcbtheorem. Any help regarding that? – David Oct 5 '17 at 18:17
• @David: Oh my, just use breakable as option ... – user31729 Oct 5 '17 at 18:18
• @Christian..Yeah..thank you so much..It works like a charm..Kindly help me in reference please. – David Oct 5 '17 at 18:22