7

I would like to create frames / boxes for equations or text like in the Beamer class: enter image description here

outisde of the beamer documentclass, for example in the article class. Is there any package or trick to do this?

thanks

  • 3
    Take a look at the mdframed package. Does that look like what you want? – Loop Space Sep 10 '13 at 11:22
9

tcolorbox has also a beamer skin:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\colorlet{xlightblue}{blue!5}

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

\begin{document}

\begin{beamerlikethm}{Theorem (Pythagoras)}
\[ a^2 + b^2 = c^2 \]
\end{beamerlikethm}

\end{document}

enter image description here

As Gonzalo suggested, could happen that your box necessitate of being split on different pages. The library breakable of the package deal with this problem.

An example:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}

\usepackage{lipsum}

\colorlet{xlightblue}{blue!5}

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

\begin{document}

\begin{beamerlikethm}{Theorem (Pythagoras)}
\[ a^2 + b^2 = c^2 \]
\end{beamerlikethm}

\lipsum[1-4]

\begin{beamerlikethm}{Something}
\lipsum[5]
\end{beamerlikethm}

\end{document}

enter image description here

  • Perhaps you might want to add the breakable option so the box admits page breaks. – Gonzalo Medina Sep 10 '13 at 12:43
  • @GonzaloMedina: that's absolutely right. I'll add a reference on this. – Claudio Fiandrino Sep 10 '13 at 12:56
  • Just some hints for adjusting the vertical spacing of the formula in the example: the additional loading of the amsmath package corrects the spacing before the equation. Alternatively, the tcolorbox library theorems could be used (which loads amsmath). For multiline formulas, the library has special support for the spacing at the begin of the box, e.g. see the option 'ams nodisplayskip'. :-) – Thomas F. Sturm Sep 11 '13 at 6:45
  • @ThomasF.Sturm: thank you very much for the suggestion. I will modify the answer accordingly. :) – Claudio Fiandrino Sep 11 '13 at 7:00
6

Another approach with the »tcolorbox« package and its theorems library.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[most]{tcolorbox}

\newtcbtheorem{corollary}{Corollary}{%
  breakable,
  colback=blue!10,
  colframe=blue!25,
  fonttitle=\bfseries
}{cor}

\begin{document}
  \begin{corollary}{Title}{dummy}
    \[
      x+y=y+x
    \]
  \end{corollary}
\end{document}

enter image description here

  • Perhaps you might want to add the breakable option so the box admits page breaks. – Gonzalo Medina Sep 10 '13 at 12:43
  • @GonzaloMedina: You forgot to mention that the breakable option needs the breakable library. Since it was not asked here for boxes which allow page breaks, there was no necessity to add it. But as you mention that now, the OP is aware of it. – Thorsten Donig Sep 10 '13 at 12:53
  • 1
    Right, I didn't mention the library since I always load tcolorbox using \usepackage[most]{tcolorbox}, so I don't have to worry about loading the libraries explicitly. – Gonzalo Medina Sep 10 '13 at 12:57
  • @GonzaloMedina: That is a good option. – Thorsten Donig Sep 10 '13 at 12:58
5

tcolorbox package might be helpful.

\documentclass{article}
\usepackage{tcolorbox}
\begin{document}

\begin{tcolorbox}[colback=blue!5,colframe=blue!40!black,title=Theorem (Pythagoras)]
\[ a^2 + b^2 = c^2 \]
\end{tcolorbox}

\end{document}

enter image description here

The similar question was asked here.

  • Perhaps you might want to add the breakable option so the box admits page breaks. – Gonzalo Medina Sep 10 '13 at 12:44

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.