Como posso replicar isso usando tcolorbox?

Oct 11 2020

Estou tentando, mas não consigo obter esse tipo de caixa.

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

Isso me dá algo assim:

Respostas

5 leandriis Oct 10 2020 at 23:53

Usando \newtcbtheoremem combinação com um título em caixa, você pode obter a seguinte saída em que as caixas são numeradas automaticamente. Você também pode usar o mecanismo de referência de etiqueta usual nessas caixas.

Também tentei simplificar as outras opções resumindo leftrule=1pt, rightrule=1pt, toprule=1pt,bottomrule=1pt,em boxrule=1pt. Eu também substituí as opções relacionadas sharp cornersaos cantos por, uma vez que os cantos em sua imagem de exemplo pareciam não ser arredondados. Se você preferir a aparência ligeiramente arredondada, pode facilmente reverter as alterações.

\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}
4 Tanvir Oct 10 2020 at 23:52

Aqui está um exemplo de como você pode reproduzir a imagem usando 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}