3

enter image description here

I am trying but I am just unable to get this kind of box.

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

This gives me something like this: enter image description here

5
  • 1
    What have you tried? Just so we don't suggest something you've already tried.
    – Plergux
    Oct 10 '20 at 15:48
  • @Plergux check the edits. Oct 10 '20 at 15:58
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Rmano
    Oct 10 '20 at 16:06
  • @ThaqibDamani2.0 colframe and colbacktitle is where you define the colour of the text box and the frame. As you can see it is set to a variant of blue. You could try changing those two to orange for a start. Also, "enhanced jigsaw" is a specific tcolorbox theme. If I remember correctly you could do "enhanced.title" instead and "attach boxed title top left". But without having more to work with that's about all I can suggest at the moment.
    – Plergux
    Oct 10 '20 at 16:13
  • @Plergux can you give an example please, I am new to LaTeX. Oct 10 '20 at 16:23
5

Using \newtcbtheorem in combination with a boxed title, you can achieve the following output in which the boxes are numbered automatically. You can also use the usual label-ref-mechanism on these boxes.

I have also tried to simplify the other options by summarizing leftrule=1pt, rightrule=1pt, toprule=1pt,bottomrule=1pt, to boxrule=1pt. I have also replaced the corner related options with sharp corners since the corners in your example image seemed to nor be rounded. If you prefer the slightly rounded look, you can easily revert the changes.

enter image description here

\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

Here is an example on how you can reproduce the image using 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}

enter image description here

2
  • leftmargin from enumitem package can be used to adjust the left margin that seems to be too wide. :-) Oct 10 '20 at 16:54
  • To match it with the image posted by OP, I kept the leftmargins wide.
    – Tanvir
    Oct 10 '20 at 16:58

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.