# Adjust width of tcolorbox to contains long Equation

My work based on that subject Create Beamer-Theorem like boxes

i want all long equations be inside a box and the width to be adjust based on the content

also the my box can't be split on different pages even i added breakable option As pointed out by Gonzalo Medina in a comment. by the way i use \usetheme{Luebeck}

here is my go

\documentclass[leqno,mathserif,hyperref={pdfpagelabels=false}]{beamer}
\usepackage{lmodern}
\usepackage{graphics,bm}
%\usetheme{AnnArbor}
\usetheme{Luebeck}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
\setbeamercolor{structure}{blue}
\usepackage[tightpage]{preview}

\setbeamercovered{transparent}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{enumerate}
\newcommand{\diff}{\mathop{}\mathopen{}\mathrm{d}}

\usepackage{lipsum}
\usepackage{enumitem}

\colorlet{xlightblue}{blue!5}

\newtcolorbox{Educ}[1]{
title=#1,
beamer,
colback=xlightblue,
colframe=blue!30,
fonttitle=\bfseries,
left=1mm,
right=1mm,
top=1mm,
bottom=1mm,
middle=1mm,
breakable,
}

\begin{document}
\section[Plan]{Plan}
\section[Introduction]{Introduction}
\section[Example1]{Example1}
\section[Example2]{Example2}
\begin{frame}
\frametitle{Solution d'une EDS}
\begin{Educ}{Définition}
Une solution de l'EDS $E(b,\sigma)$  est un couple $(X,W)$ de processus adaptés sur un espace de probabilité filtré $(\Omega,\mathcal{F},\mathcal{F}_{t},\mathbb{P})$ qui satisfait les conditions usuelles, vérifiant :
\begin{itemize}
\item $W$ est un $\mathcal{F}_{t}$-mouvement brownien m-dimensionnel;
\item pour tout $t\geq 0$, on a les conditions de régularité
$\mathbb{P}\big\{ \int_{0}^{t} \sum_{i=1}^{n} |b_{i}(s,X_{s})| \diff s <\infty \big\}=\mathbb{P}\big\{ \int_{0}^{t}\sum_{i=1}^{n}\sum_{j=1}^{m}|\sigma_{ij} (s,X_{s})|^{2}\diff s <\infty \big\}=1;$
\item pour tout $t\geq 0, i=1,\ldots,n$, on a presque sûrement
$X_{t}^{i}=X_{0}^{i}+\int_{0}^{t}b_{i}(s,X_{s})\diff s +\sum_{j=1}^{m}\int_{0}^{t}\sigma_{ij}(s,X_{s})\diff W_{s}^{j}.$
\end{itemize}
\lipsum[5]
\end{Educ}
\end{frame}

\end{document}


I can use align* so that the box can contians the equation but that take lot space that's why i want the equation be in one row and inside a box

\begin{align*}
&\mathbb{P}\big\{ \int_{0}^{t} \sum_{i=1}^{n} \abs{b_{i}(s,X_{s})} \diff s <\infty \big\}\\
&=\mathbb{P}\big\{ \int_{0}^{t}\sum_{i=1}^{n}\sum_{j=1}^{m}\abs{\sigma_{ij} (s,X_{s})}^{2}\diff s <\infty \big\}\\
&=1;
\end{align*}


• The breakable option breaks boxes across pages in a standard document, but not across slides or frames in beamer. Feb 23 '14 at 16:49
• Why do you need stuff from »tcolorbox«. Aren't the structures provided by »beamer« not satisfactory? Feb 23 '14 at 17:41
• @@Thorsten Donig yes @@Steven B. Segletes i can use with simply align but i want the equation be in one row and inside a box
– Educ
Feb 23 '14 at 17:44
• @Educ: "In one row and inside a box". So you will then have to shrink the font, right? That's the only option left with those requirements. Feb 23 '14 at 20:12
– Educ
Feb 23 '14 at 20:48

Since the OP indicated that shrinking the font is acceptable, it can be done this way. First, you place the equation into a box. Then you scale/resize the box (requires graphicx package).

I have EDITED this answer to make the rescale automatic, if you pass the equation to the defined macro \fiteq{}. If the equation is larger than 85% of \textwidth, it will be shrunk to that size. For demonstration, both equations in this slide were passed through \fiteq. Only the first one was resized.

\documentclass[leqno,mathserif,hyperref={pdfpagelabels=false}]{beamer}
\usepackage{lmodern}
\usepackage{graphicx,bm}
%\usetheme{AnnArbor}
\usetheme{Luebeck}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
%\setbeamercolor{structure}{blue}
\usepackage[tightpage]{preview}

\setbeamercovered{transparent}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{enumerate}
\newcommand{\diff}{\mathop{}\mathopen{}\mathrm{d}}

\usepackage{lipsum}
\usepackage{enumitem}

\colorlet{xlightblue}{blue!5}

\newtcolorbox{Educ}[1]{
title=#1,
beamer,
colback=xlightblue,
colframe=blue!30,
fonttitle=\bfseries,
left=1mm,
right=1mm,
top=1mm,
bottom=1mm,
middle=1mm,
breakable,
}
\newcommand\fiteq[1]{%
\sbox{\mybox}{$\displaystyle#1$}%
\ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
\else\usebox{\mybox}\fi%
}

\newsavebox{\mybox}

\begin{document}
\section[Plan]{Plan}
\section[Introduction]{Introduction}
\section[Example1]{Example1}
\section[Example2]{Example2}
\begin{frame}
\frametitle{Solution d'une EDS}
\begin{Educ}{Définition}
Une solution de l'EDS $E(b,\sigma)$  est un couple $(X,W)$ de processus adaptés sur un espace de probabilité filtré $(\Omega,\mathcal{F},\mathcal{F}_{t},\mathbb{P})$ qui satisfait les conditions usuelles, vérifiant :
\begin{itemize}
\item $W$ est un $\mathcal{F}_{t}$-mouvement brownien m-dimensionnel;
\item pour tout $t\geq 0$, on a les conditions de régularité
$\fiteq{% \mathbb{P}\big\{ \int_{0}^{t} \sum_{i=1}^{n} |b_{i}(s,X_{s})| \diff s <\infty \big\}=\mathbb{P}\big\{ \int_{0}^{t}\sum_{i=1}^{n}\sum_{j=1}^{m}|\sigma_{ij} (s,X_{s})|^{2}\diff s <\infty \big\}=1; }$
\item pour tout $t\geq 0, i=1,\ldots,n$, on a presque sûrement
$\fiteq{% X_{t}^{i}=X_{0}^{i}+\int_{0}^{t}b_{i}(s,X_{s})\diff s +\sum_{j=1}^{m}\int_{0}^{t}\sigma_{ij}(s,X_{s})\diff W_{s}^{j}.% }$
\end{itemize}
\lipsum[5]
\end{Educ}
\end{frame}

\end{document}


• @@Steven B. Segletes Thanks so much but please what about others questions : is there any way make me able breaks boxes across slides or frames in beamer since Mr Gonzalo Medina said that "The breakable option breaks boxes across pages in a standard document, but not across slides or frames in beamer." also the width to be adjust based on the content ?
– Educ
Feb 23 '14 at 22:22
• @Educ If Gonzalo Medina says that content cannot auto-break across beamer frames, then you can take that answer to the bank. He is wise in the ways of LaTeX. As to the 2nd question, I suggested you search this site for help on that. One such search reveals, for example, tex.stackexchange.com/questions/30312/…. In addition to the answers on that page, you will also find in the right margin a column labeled "Linked". Those are other questions along the same lines as that question. Feb 23 '14 at 23:30