我正在尝试,但就是无法得到这种盒子。
\newtcolorbox{defn}[1][]{
width=\textwidth,
colback=white!20,
colframe=blue!75!blue,
colbacktitle=blue!85!blue,
fonttitle=\bfseries,
left=2ex,
right=2ex,
top=2pt,
arc=2pt,
outer arc=0pt,
leftrule=1pt,
rightrule=1pt,
toprule=1pt,
bottomrule=1pt,
breakable,
enhanced jigsaw,
title= #1}
答案1
与带框标题结合使用\newtcbtheorem
,您可以实现以下输出,其中框会自动编号。您还可以在这些框上使用常用的标签引用机制。
我还尝试通过总结leftrule=1pt, rightrule=1pt, toprule=1pt,bottomrule=1pt,
为 来简化其他选项boxrule=1pt
。我还用 替换了与角落相关的选项,sharp corners
因为示例图像中的角落似乎不是圆的。如果您更喜欢略圆的外观,您可以轻松恢复更改。
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbtheorem{defn}{Definition}{
width=\textwidth,
colback=white!20,
colframe=orange,
colbacktitle=orange,
fonttitle=\bfseries,
sharp corners,
boxrule=1pt,
breakable,
enhanced,
boxed title style={sharp corners},
attach boxed title to top left
}{def}
\begin{document}
\begin{defn}{box title}{label}
contents
\end{defn}
\ref{def:label}
\end{document}
答案2
下面是如何使用重现图像的示例tcolorbox
。
\documentclass{article}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
%
\definecolor{newcolor}{RGB}{246,164,4} %
\begin{document}
\begin{tcolorbox}[enhanced,title=Definition 1: Set,
colframe=newcolor,arc=0mm, fonttitle=\bfseries,coltitle=white,
attach boxed title to top left={xshift=0.mm,yshift=-0.50mm},
boxed title style={skin=enhancedfirst jigsaw,size=small,arc=0mm,bottom=0mm,
interior style={fill=newcolor}}]
\begin{itemize}
\item[$\bullet$] A \emph{set} is a collection of object.
\item[$\bullet$] These objects are called \emph{elements} of the set.
\item[$\bullet$] If $A$ is a set and $x$ is an element of $A$, write $x\in A$.
\item[$\bullet$] If $x$ is not an element of $A$, write $A\not\in A$.
\end{itemize}
\end{tcolorbox}
\end{document}