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?

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

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .