1

I am trying to fit a long equation in a tcbtheorem environment. The problem is, the equation sticks out the box on the right side. How do I fix this? I'd prefer to not use multline to break the equation into multiple lines (it just isn't aesthetically pleasing to me). I also tried using \scriptstyle, but then the math becomes too small compared to the text in the theorem box. Ideally, either I'd like to expand the width of the tcbtheorem box a bit on either side, and slightly shrink the font size of the equation so that it fits. However, I am open to other suggestions that look nice.

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}


%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}


\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth}{lem}
\tcbset{colframe=green, colback=white}  
\resetcounteronoverlays{tcb@cnt@mylemmma}

\begin{document}
\section{Proofs}
\begin{frame}

    \begin{mylemmma}{Name of the Lemma}{lem}
        The function changes as follows. 
        \[-f(\sum_i g(-\psi - b)) \geq -f (\sum_i g(-\psi)) + \sum_i (b_i - h_i)^\top \left( \frac{g(-b)}{\sum_i g(-b)} \right) - error\]
%       \[{\scriptstyle -f(\sum_i g(-\psi - b)) \geq -f (\sum_i g(-\psi)) + \sum_i (b_i - h_i)^\top \left( \frac{g(-b)}{\sum_i g(-b)} \right) - error}\]
%\begin{multline*}
%   -f(\sum_i g(-\psi - b)) \\
% \geq -f (\sum_i g(-\psi)) + \sum_i (b_i - h_i)^\top \left( \frac{g(-b)}{\sum_i g(-b)} \right) - error
%   \end{multline*}
    \end{mylemmma}

\end{frame}


\end{document}

  • 1
    I had already upvoted the question but I have no good proposal. Personally I would go with multline and company. – user194703 May 24 at 21:43
  • Thank you! What is "company"? – lazulikid May 24 at 21:54
  • 2
    For instance, align* with or without \MoveEqLeft from mathtools. – user194703 May 24 at 21:55
2

Reducing the left margin in the \tcolorbox, some spacing adjustments, and a medium sized formula; is it better?

\documentclass{beamer}
\mode<presentation>
{
% \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
% \usecolortheme{default} % or try albatross, beaver, crane, ...
% \usefonttheme{default} % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usepackage{nccmath}

%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}

\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth, left=0pt}{lem}
\tcbset{colframe=green, colback=white}
\resetcounteronoverlays{tcb@cnt@mylemmma}

\begin{document}
\section{Proofs}
\begin{frame}

    \begin{mylemmma}{Name of the Lemma}{lem}
        The function changes as follows.
      \[\medmath{-f(\sum_i g(-\psi - b)) \geq -f \Bigl(\sum_i g(-\psi)\!\Bigr) + \sum_i (b_i - h_i)^{\!\top}\! \biggl( \frac{g(-b)}{\sum_i g(-b)} \biggr) - error} \]
    \end{mylemmma}

\end{frame}

\end{document}

enter image description here

| improve this answer | |
  • Thank you, @Bernard! I'll accept your answer. Unfortunately, the actual f and g I'm using in my slide are functions like exp and log, due to which the above expression is in fact even longer than now. This leads the equation to still spill out of the box. – lazulikid May 24 at 22:11
  • One followup question: is it possible to use medmath with multline? I am trying to do so, but it's throwing compilation errors. I think that might be the nicest option for me. – lazulikid May 24 at 22:15
  • I found it! So, thanks to Schrodinger's cat's comment above and your answer here, I was able to find the perfect way for me: I used \equation*, then \medmath, then \multlined (in mathtools package). It looks much better! – lazulikid May 24 at 22:19
  • I guess \medmath{...} cannnot have line breaks. But there's also a medsize environment. If you're interested, you should have a look at the package documentation. I often use the \mfrac command, when I have a numerical fraction as coefficient and I feel it shouldn't have the same size as fraction expressions. – Bernard May 24 at 22:19

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.