带框包装

带框包装

我在Tex 生成的 PDF并想知道使用什么包装来制作它:

enter image description here

有谁认得它吗?

答案1

tcolorbox这里是使用宏的快速设置\newtcbtheorem,但也可以使用普通\newtcolorbox宏完成。特殊标题设置需要skin库,该库包含在使用most选项中。

\newtcolorbox也采用了一种方法来展示如何改变框的选项,与之相反\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

答案2

这是使用 Tikz 的版本。框位于框架内,1mm两边都有边距。

输出

figure 1

代码

\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}

相关内容