2

In the following two codes, I would like to include a title in the upper right and have a counter for the statement.

I would also like to have the title in the environment ...

\documentclass[a4paper]{article}
\setlength{\parindent}{0pt}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\definecolor{titleboxcolor}{RGB}{200,200,200}
\newcommand{\titlepath}{
  \fill[titleboxcolor]
  (title.south east)
  --(title.east)coordinate(A)
  to[curve to,out=90,in=0]($(A)+(-5mm,5mm)$)
      --($(title.north west)+(5mm,0mm)$)coordinate(B)
to[curve to,out=180,in=90]($(B)+(-5mm,-5mm)$)coordinate(C)
      --($(C)+(0mm,-5mm)$)
      to[curve to,out=90,in=180]($(title.south west)+(+5mm,0mm)$)coordinate(F)
      --cycle;
      \draw[titleboxcolor,draw=none]%ultra thick
      ([yshift=0.5\pgflinewidth]title.south east)--
      ([yshift=0.5\pgflinewidth]title.south-|interior.east);
    }
\newtcolorbox{myenvironment}{
  enhanced,
  %frame empty,
  colframe=titleboxcolor,
  title=Example,
  colback=yellow!10,
  coltitle=black,
  attach boxed title to top left={xshift=0mm},
  boxed title style={empty},
  underlay boxed title=\titlepath
}
\begin{document}
Before... 
\begin{myenvironment}
My example 1 here... 
\end{myenvironment}
... 
\begin{myenvironment}
My example 2 here... 
\end{myenvironment}
After... 
\end{document}

\documentclass[a4paper]{article}
\setlength{\parindent}{0pt}
\usepackage[most]{tcolorbox}
\makeatletter
\newtcolorbox{mybox}[2][]{
        enhanced, 
        breakable,
        sharp corners,
        rounded corners=northwest,
        colback=white,
        colframe=black!30,
        fonttitle=\bfseries\large\sffamily,
        %frame hidden,
        title=#2,
        attach boxed title to top left,
        boxed title size=standard,
        boxed title style={%
                empty,
                rounded corners=north, 
                boxrule=0pt,
                bottom=0pt,
        },
          underlay boxed title={%
                \filldraw[rounded corners=\kvtcb@arc, black!30, line width=.5mm]
                    (title.south east)--++(93:\tcboxedtitleheight)--++(183:\tcboxedtitlewidth)--++(-87:\tcboxedtitleheight)|-cycle;
                \draw[tcbcolframe, line width=.5mm] (title.south)|-(frame.north east);
                },
        #1
    }
\makeatother
\begin{document}
Before... 
\begin{mybox}{Example}
My Example 1 here... 
\end{mybox}
... 
\begin{mybox}{Example}
My example 2 here... 
\end{mybox}
After...
\end{document}

Thanks a lot for your help.


I would like it to look like this :

Thanks !

2
  • Please add a sketch of the expected otuput. Do you want to actually add a title or do you just want to move the gray box containing the text "Example" to the upper right instead of the upper left edge of the box? Please clarify. What does "have the title in the environment" mean?
    – leandriis
    Commented Apr 5, 2021 at 7:35
  • @user239017 -- for the second code set added -- \path[fill=black!30,line width=.4mm] (frame.north east)--++(1pt,0)coordinate(n3)--++(0,8mm)--++(-20mm,0) arc (-90:90:-4mm)--cycle; \node at ([shift={(-8mm,4mm)}]frame.north east){\itshape\textbf{\sffamily MyTitle}}; to get the title on right side -- please see the answer below
    – js bibra
    Commented Apr 5, 2021 at 10:14

1 Answer 1

1

For the second code set

enter image description here

\documentclass[a4paper]{article}
\setlength{\parindent}{0pt}
\usepackage[most]{tcolorbox}
\makeatletter
\newtcolorbox{mybox}[2][]{
    enhanced, 
    breakable,
    sharp corners,
    rounded corners=northwest,
    colback=white,
    colframe=black!30,
    fonttitle=\bfseries\large\sffamily,
    %frame hidden,
    title=#2,
    attach boxed title to top left,
    boxed title size=standard,
    boxed title style={%
        empty,
        rounded corners=north, 
        boxrule=0pt,
        bottom=0pt,
    },
    underlay boxed title={%
        \filldraw[rounded corners=\kvtcb@arc, black!30, line width=.5mm]
        (title.south east)--++(93:\tcboxedtitleheight)--++(183:\tcboxedtitlewidth)--++(-87:\tcboxedtitleheight)|-cycle;
        \draw[tcbcolframe, line width=.5mm] (title.south)|-(frame.north east);
        \path[fill=black!30,line width=.4mm] (frame.north east)--++(1pt,0)coordinate(n3)--++(0,8mm)--++(-20mm,0) arc (-90:90:-4mm)--cycle;
        \node at ([shift={(-8mm,4mm)}]frame.north east){\itshape\textbf{\sffamily MyTitle}};
    },
    #1
}
\makeatother
\begin{document}
    Before... 
    \begin{mybox}{Example}
        My Example 1 here... 
    \end{mybox}
    ... 
    \begin{mybox}{Example}
        My example 2 here... 
    \end{mybox}
    After...
\end{document}
1
  • Thank you for your answers... I would like to know how to put a counter. Thanks !
    – insan
    Commented Apr 9, 2021 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .