1

I would like to construct a new environment that I can call like:

\begin{Box}{*Title of Box*}

** Text **
** Math equations **

\end{Box}

It shall have the following properties:

  • The box background shall have a colour.
  • The text inside the box shall have a distance of 3 - 5 mm to the boundary.
  • Important: It shall break at the end of a page and continue at the next page.

Is there someone who can do that?

  • 4
    Use the package tcolorbox. – Ulrike Fischer Jun 2 '16 at 11:08
  • Welcome to TeX.SE. How wide should be color box be? – Mico Jun 2 '16 at 11:37
4

This can be achieved with tcolorbox, one of my favourite packages (;-))

\documentclass{article}

\usepackage[most]{tcolorbox}

% Define a new box for this
\newtcolorbox[auto counter]{MyBox}[2][]{%
  title={MyBox \thetcbcounter\ #2},
  boxsep=1mm,
  colback=white!40!yellow,
  breakable,
  #1
}

\usepackage{blindtext}
\begin{document}

\begin{MyBox}{My nice title box}

\blindtext

$E=mc^2$

\blindtext[3]



\end{MyBox}


\begin{MyBox}[width={0.5\textwidth},coltitle={blue}, colbacktitle={gray},colback={green!60!blue}]{My nice title box, but not so wide}

\blindtext

$E=mc^2$

\blindtext[3]



\end{MyBox}

\end{document}

enter image description here

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.