The package tcolorbox
provides the option overlay
and some other friends. A simple solution for your left part can be:
\documentclass{article}
\usepackage{graphicx}
\usepackage[most]{tcolorbox}
\newtcolorbox{lattention}{breakable,enhanced,arc=0mm,colback=gray!5,colframe=gray,leftrule=12mm,%
overlay={\node[anchor=north west,outer sep=2pt] at (frame.north west) {\includegraphics[width=8mm]{attention}}; }}
\usepackage{lipsum}
\begin{document}
\begin{lattention}
\lipsum[2]
\end{lattention}
\begin{lattention}
\lipsum
\end{lattention}
\end{document}
Of course you need the picture attention
. After this the result will be:
The adjustment is yours ;-)
The skin
library of tcolorbox
has the feature of attached box titles, which can be styled on their own, as well as being shifted with xshift
and yshift
options.
To attach the box title top right, just say attach box title to top right={...}
, with some options, see the manual (version 3.70, as of now, page 131 for more options and possibilities)
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbtheorem{Summary}{\bfseries Summary}{enhanced,drop shadow={black!50!white},
coltitle=black,
top=0.3in,
attach boxed title to top right=
{xshift=0em,yshift=-\tcboxedtitleheight/2},
boxed title style={size=small,colback=pink}
}{summary}
\newtcolorbox[auto counter]{summary}[1][]{title={\bfseries Summary~\thetcbcounter},enhanced,drop shadow={black!50!white},
coltitle=black,
top=0.3in,
attach boxed title to top right=
{xshift=0pt},
boxed title style={size=small,colback=pink},#1}
\begin{document}
\begin{Summary}{}{firstsummary}
Brontosaurs are thin at one end, thick in the middle and thin again on the other end
\end{Summary}
\begin{summary}[boxed title style={colback=yellow},colback=green]
Brontosaurs are thin at one end, thick in the middle and thin again on the other end
See excavations of Brontosaurs skeletons
\end{summary}
\end{document}
Here, two versions are shown, own with an overlay of the box title and own with almost no boundary space between bottom of the title box and the top of the regular tcolorbox
frame. In my point of view, the first version does provide the better look.
Best Answer
Using the
attach boxed title to bottom center
key (along withminipage boxed title*
to compensate the different width) you can easily achieve what you want:The code: