2

I'd like to put frames around equations in my beamer slides.

For this purpose, I use the package tcolorbox.

I use the macro \fiteq{} that I found somewhere else on this site to shrink overlong equations horizontally (see first equation below).

How can I adopt this macro to work with align commands, such as \\ or &? (See second equation below. When I surround the content with \fiteq{} I get error messages) enter image description here

I would be most happy with a solution that shrinks the equations instead of expanding the surrounding box.

Also: I would also like to be able to use the equation environment instead of align*, and then use \\ and & in a split environment. However, replacing ams align* by ams equation* yields bad vertical alignment: enter image description here

The code for the first image is below. For the second image I replaced ams align* by ams equation* in the first tcolorbox.

\documentclass{beamer}
\usepackage[most]{tcolorbox}
\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}
\begin{frame}
\begin{tcolorbox}[ams align*]% Replace by ams equation* to get second image
\fiteq{
A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z
}
\end{tcolorbox}
\begin{tcolorbox}[ams align*]
&A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z\\
\Leftrightarrow &A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z
\end{tcolorbox}
\end{frame}
\end{document}
3

if you change align* to equation*, you can embed either split or aligned within it, and \fiteq does what is wanted. it's also good to nullify \abovedisplayskip to avoid a large gap above the formula.

output of example code

\documentclass{beamer}
\usepackage[most]{tcolorbox}
\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}
\begin{frame}
\begin{tcolorbox}[ams align*]% Replace by ams equation* to get second image
\fiteq{
A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z
}
\end{tcolorbox}
\begin{tcolorbox}[ams equation*]
\abovedisplayskip=0pt \relax
\fiteq{\begin{split}
&A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z\\
\Leftrightarrow &A=B=C=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=W=X=Y=Z
\end{split}}
\end{tcolorbox}
\end{frame}
\end{document}

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.