I want to create a simple environment in LaTaX that's alike the following figure. If, for example, this environment has some spare comments like references or so, to be added above the environment (like metric projection) and to also fell into the frame; However, I want it to be completely compatible with the page; I mean, when some of it holds in a page and the remaining flows to the next page, the thing doesn't get messed up, analogous to a text which will be placed in the text flow; and when there is some footnotes within the environment, the footnote to be placed in the current page. How may I create such a standard environment which is very compatible to the other environments and to be like the aforementioned? I'm asking the veterans with a great deal of experience that which commands and suitable packages I may use to produce such an environment which if I enter the followings:

\begin{defi}[metric projection]
Hello bla bla bla bla

I end up with an output like the following figure: enter image description here


1 Answer 1


Here's an example use of the mentioned tcolorbox package for you:





\newtcolorbox[use counter=example]{defi}[3][]{%
drop fuzzy shadow, % shadow
colback=yellow!40, % background color of main box
colframe=black, % frame color of main box
top=4mm, % inserted space on top
arc=4mm, % edge arc
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
overlay unbroken and first={%
\node[rectangle,rounded corners=10pt,draw=black,fill=white, % first heading box
inner sep=1.5mm,anchor=west] (def) at ([xshift=3.6mm]frame.north west)
{\textbf{\Large Definition \thetcbcounter.}};
\node[ellipse,draw=black,fill=white, % second heading box
inner sep=1mm,anchor=west] at ([xshift=-11mm]def.east)
{\textbf{\footnotesize\hspace{3mm} #2}};
\node[rectangle,rounded corners=10pt,draw=black,fill=white, % first heading box
inner sep=1.5mm,anchor=west] (def) at ([xshift=3.6mm]frame.north west)
{\textbf{\Large Definition \thetcbcounter.}};},

\begin{defi}{Metric Projection}{label:metricprojection}

This is an adapted version of some code from the tcolorbox manual which additionally gives you the oportunity of labelling the box ("label:metricprojection" in my example). The heading boxes are simple tikz nodes for which you can find numerous examples etc. all over TEX.SE and the web in general, so adjusting them to your exact needs shouldn't be a thing.

The first node is printed two times in order to overlap the second one, which aligns to it. There might be a better way to achieve this, but honestly I don't know how (comments on this are welcome!). It works perfectly well this way though.

Page breaks are not a problem for this, but your requirements regarding footnotes seem to be not possible to match with tcolorbox, see question 124546.

You must log in to answer this question.

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