3

I would like to know if there is a package or a method to achieve exactly the kind of box in the following image.

Thanks in advance !

enter image description here

5
  • 2
    Yes, tcolorbox.
    – user121799
    Aug 10, 2019 at 2:48
  • Welcome to TeX.SE...Please provide the tags (MWE) what you tried to meet this output. And it is possible, by using tcolorbox, but I'm not sure about with bclogo
    – MadyYuvi
    Aug 10, 2019 at 4:05
  • I believe that for the second point "Preuve" with zigzag we will need bclogo.
    – ALI
    Aug 10, 2019 at 11:32
  • No, tcolorbox can do it as well.
    – frougon
    Aug 10, 2019 at 13:33
  • Ok, but how can i do for the second point : 'wavy vertical rule' above
    – ALI
    Aug 10, 2019 at 14:19

2 Answers 2

4

Welcome to TeX.SE!

Implementing a style giving the desired layout

As said in the comments, this box style can be obtained with the powerful tcolorbox. I do this in two steps:

  1. Define a my box style that can be applied to any tcolorbox and implements the design you want.

  2. Use \newtcolorbox to define an environment called mybox that uses the my box style.

Of course, you can apply the my box style to other tcolorboxes if you want—that is the whole point of separating the two operations.

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{lipsum}

\definecolor{boxTitle}{HTML}{fff79a}
\definecolor{boxBackground}{HTML}{fffce0}
\definecolor{boxFrame}{HTML}{f1e2b8}

\tcbset{my box/.style={
    enhanced, fonttitle=\bfseries,
    colback=boxBackground, colframe=boxFrame,
    coltitle=black, colbacktitle=boxTitle,
    attach boxed title to top left={xshift=0.3cm,
                                    yshift*=-\tcboxedtitleheight/2},
    boxed title style={
      before upper=\hspace*{0.5cm}, % reserve space for the image
      overlay={
       \node at ([xshift=0.5cm]frame.west)
         {\includegraphics[scale=0.65]{bc-dodecaedre}};
      }
    }
  }
}

\newtcolorbox{mybox}[1][]{my box, #1}

\begin{document}

\begin{mybox}[title={This is a great title, with a comma}]
\lipsum[1]
\end{mybox}

\end{document}

Screenshot

Note: the bc-dodecaedre graphics comes from the bclogo package, so you must have it installed in order to have the graphics (.mps file, obtained with MetaPost).

Automatically numbered boxes

Following your request in a comment, here are several ways of creating independently-numbered series of boxes using the layout we developed in the previous section (reusing it is particularly easy thanks to the my box style). There are basically two ways:

  • using auto counter in the first optional argument of \newtcolorbox (see the two box series defined in the example below: boxes of type A and boxes of type B);

  • using the theorems library of tcolorbox (see the theorem environment defined in the example).

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins, theorems}
\usepackage{nameref}            % only needed if you use \nameref

\definecolor{boxTitle}{HTML}{fff79a}
\definecolor{boxBackground}{HTML}{fffce0}
\definecolor{boxFrame}{HTML}{f1e2b8}

\tcbset{my box/.style={
    enhanced, fonttitle=\bfseries,
    colback=boxBackground, colframe=boxFrame,
    coltitle=black, colbacktitle=boxTitle,
    attach boxed title to top left={xshift=0.3cm,
                                    yshift*=-\tcboxedtitleheight/2},
    boxed title style={
      before upper=\hspace*{0.5cm}, % reserve space for the image
      overlay={
       \node at ([xshift=0.5cm]frame.west)
         {\includegraphics[scale=0.65]{bc-dodecaedre}};
      }
    }
  }
}

\newtcolorbox[auto counter]{countedboxa}[2][]{%
  my box, title={Counted box of type A~(\thetcbcounter): #2}, #1}
\newtcolorbox[auto counter, number within=section]{countedboxb}[2][]{%
  my box, title={Counted box of type B.~(\thetcbcounter): #2}, #1}

\newtcbtheorem[number within=section]{theorem}{Theorem}{my box}{th}

\begin{document}

\section{First section}
\label{sec:first}

\begin{countedboxa}[label={first box of type A}]{Some title}
  My number is~\thetcbcounter.
\end{countedboxa}

\begin{countedboxb}[label={first box of type B}]{Other title}
  Note the different numbering style due to our use of
  \verb|number within=section| for boxes of type~B. My number is~\thetcbcounter.
\end{countedboxb}

\begin{countedboxa}[label={second box of type A}]{Another title}
  My number is~\thetcbcounter. The third box of type A is number~\ref{third
    box of type A} on page~\pageref{third box of type A}.
\end{countedboxa}

\begin{countedboxb}[label={second box of type B}]{The title}
   My number is~\thetcbcounter. The third box of type B is number~\ref{third
    box of type B} on page~\pageref{third box of type B}.
\end{countedboxb}

\begin{theorem}{Compacity of Foo spaces}{foo}
% Text (mostly) from the tcolorbox manual
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number due to our use of
\verb|number within=section|. This theorem is numbered \ref{th:foo}, found
on page~\pageref{th:foo} and titled ``\nameref{th:foo}.''
\end{theorem}

An immediate but very convenient consequence of this result is
theorem~\ref{th:bar}.

\begin{theorem}{Bar}{bar}
Trivial consequence of theorem~\ref{th:foo}.
\end{theorem}

\section{Second section}

\begin{countedboxa}[label={third box of type A}]{Some title}
  See boxes~\ref{first box of type A} and \ref{second box of type A} in
  section~\ref{sec:first}.
\end{countedboxa}

\begin{countedboxb}[label={third box of type B}]{Title of the box}
  See boxes~\ref{first box of type B} and \ref{second box of type B} in
  section~\ref{sec:first}.
\end{countedboxb}

\begin{theorem}{Quux}{quux}
This is a very important result.
\end{theorem}

\end{document}

Page 1:

Page 1


Top of page 2:

Top of page 2

5
  • Thank you for your quick reply. Is it possible to insert different counter? for example one for the definition another for the theorem ....
    – ALI
    Aug 10, 2019 at 11:20
  • Please see the latest revision of my answer: I added several examples doing this kind of thing.
    – frougon
    Aug 10, 2019 at 12:26
  • Dear frougon. I appreciate what you do , but i still have a question about the second point "Preuve" with zigzag
    – ALI
    Aug 10, 2019 at 13:24
  • I already answered many questions here and you didn't even accept my answer (see “How do you accept an answer?” in case you don't know what this means). Please ask a new question—this request is completely unrelated to the rest. On this site, we like specific, simple and clear, abstract questions, because this makes the answers much more useful to readers than please-write-my-whole-book questions.
    – frougon
    Aug 10, 2019 at 13:27
  • For my tastes it is very nice.
    – Sebastiano
    Aug 17, 2019 at 15:36
1

Here is the answer for your point number 1, i.e., shaded box with round corner:

\documentclass{book}
\usepackage[tikz]{mdframed}
\tikzset{titregris/.style =
{draw=black, thick, fill=yellow, %
text=black, rectangle, rounded corners, right,minimum height=.7cm}}

\makeatletter
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt,linecolor=black]
\node[titregris,anchor=east,rectangle,fill=yellow!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[titregris,anchor=east,rectangle,fill=yellow!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=yellow,roundcorner=5pt,backgroundcolor=yellow!10,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\makeatother
\begin{document}

\begin{theo}[Inhomogeneous Linear]
This is my own box with a mandatory title
and options.

This is my own box with a mandatory title
and options following para.
\end{theo}

\end{document}

And regarding Point number 2, i.e., wavy vertical rule for text, not yet completed, may be some experts may give answer, meantime I'm also trying...

1
  • Thank you for your quick reply.
    – ALI
    Aug 10, 2019 at 11:22

You must log in to answer this question.

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