1

I saw the following framed box in a Tex-generated PDF and was wondering what package had been used to make it:

enter image description here

Does anybody recognize it?

  • 1
    Tikz is perfectly able to do the job, but it's not the only one. – Alenanno Jun 6 '15 at 10:07
  • Either mdframed or tcolorbox, I would say – user31729 Jun 6 '15 at 10:09
7

Here is a quick setup with tcolorbox, using the \newtcbtheorem macro, but it can done with a normal \newtcolorbox macro as well. The special title setup requires the skin library, which is included using most option.

I applied a \newtcolorbox approach as well, to show how the options of the boxes can be changed, contrary to \newtcbtheorem.

\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 left=
  {xshift=1.5em,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 left=
  {xshift=1.5em,yshift=-\tcboxedtitleheight/2},
  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]
Everything needed to decrypt the drive data is stored on the drive itself. No secret is
present in the enclosure.

$\Rightarrow$ The attacker should be able to brute-force the PIN or extract the encryption key
only in software.
\end{summary}


\end{document}

enter image description here

  • The colours don't match! (+1) – Alenanno Jun 6 '15 at 12:07
  • @Alenanno: Yes, I wanted to exaggerate and to show the configurability of tcolorbox stuff – user31729 Jun 6 '15 at 12:08
  • Ahah don't worry, that was tongue in cheek. :P – Alenanno Jun 6 '15 at 12:10
  • colors don't bother me, but the extra space above the text does. please make it go away. – barbara beeton Jun 6 '15 at 17:11
  • @barbarabeeton: The spacings can be controlled by the top and bottom options -- it's just an example, nothing I would use for myself. – user31729 Jun 6 '15 at 17:20
2

Here's a version with Tikz. The box is within the frame with a margin of 1mm on either side.

Output

figure 1

Code

\documentclass[a4paper, 12pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{geometry} 
\usepackage{tikz} 
\usepackage{lipsum}

\newcommand{\mybox}[4]{
    \begin{figure}[h]
        \centering
    \begin{tikzpicture}
        \node[anchor=text,text width=\columnwidth-1.2cm, draw, rounded corners, line width=1pt, fill=#3, inner sep=5mm] (big) {\\#4};
        \node[draw, rounded corners, line width=.5pt, fill=#2, anchor=west, xshift=5mm] (small) at (big.north west) {#1};
    \end{tikzpicture}
    \end{figure}
}

\begin{document}
\lipsum*[1]

\mybox{Summary}{red!40}{red!10}{Everything needed to decrypt the drive data is stored on the drive itself. No secret is
present in the enclosure.}

\mybox{Summary 1}{green!40}{green!10}{This is a very different box... Well, ok, just the colour.}

\lipsum*[2]
\end{document}
  • @Christian Hupfer's version is a more faithful reproduction of the original, however I do prefer yours from an aesthetic standpoint (spacing, shadows). Plus, tikz ;-) – lodhb Jun 7 '15 at 8:25
  • 1
    @lodhb: The shadows are there, the spacings can be changed and tcolorbox is tikz ;-) – user31729 Jun 7 '15 at 8:49

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.