Compilateur LaTeX en ligne
www.cpierquet.fr
fichiers/c.pierquet/tcbtheorempfb.tex
↓ télécharger
% !TeX document-id = {027aa361-ad57-4475-90c2-8d32109d8e5b}
% !TeX TXS-program:compile = txs:///pdflatex

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{fontawesome5}
\tcbuselibrary{skins,breakable,theorems}
\usepackage{lipsum}

% ==== on créé le compteur global partagé
\newcounter{coincoin}

% ==== on code les boîtes, toutes via tchteorem
\tcbset{
  SousTitre/.store in=\pfbboxsoustitre,
  SousTitre={},
  ComplementTitre/.store in=\pfbboxcplttitre,
  ComplementTitre={}
}

\tcbset{
  pfbbox/.style={
    enhanced,sharp corners=uphill,boxrule=1.25pt,%
    breakable,%
    before skip=0.5em,after skip=0.5em,%
    colframe=#1,
    colback=white,top=4mm,left={4mm-3pt-1.25pt},right={4mm-3pt-1.25pt},
    attach boxed title to top left={xshift=4mm,yshift*=-\tcboxedtitleheight/2},
    boxed title style={colframe=#1,colback=white,boxrule=1.25pt},
    fonttitle=\bfseries\color{#1},
    coltitle=#1,
    after title={%
      \ifx\pfbboxcplttitre\empty\else\pfbboxcplttitre\fi
    },
    overlay={%
      \ifx\pfbboxsoustitre\empty\else
        \node[fill=white,anchor=east,xshift=-8pt,text=red!75!black,font=\bfseries\sffamily] at (frame.north east) {\vphantom{Ppé}\pfbboxsoustitre} ;
      \fi
    }
  }
}

% ==== Génération des boites, une par une (à voitr avec une macro de génération un peu plus tard...)

\newtcbtheorem[use counter=coincoin]{MaBoiteThm}{\faBomb~Théorème}{pfbbox=blue}{thm}%
\newtcbtheorem[use counter=coincoin]{MaBoiteDef}{\faYinYang~Définition}{pfbbox=red}{def}%
\newtcbtheorem[use counter=coincoin]{MaBoiteExo}{\faPuzzle~Exemple}{pfbbox=orange}{exo}%
\newtcbtheorem[use counter=coincoin]{MaBoiteRmq}{\faBabyCarriage~Remarque}{pfbbox=teal}{rmq}%

\begin{document}

\begin{MaBoiteThm}[SousTitre={MP$^*$}]{}{thm:aaaa}
\lipsum[1][1-2]
\end{MaBoiteThm}

\begin{MaBoiteDef}[]{}{def:aaab}
\lipsum[1][1-2]
\end{MaBoiteDef}

\begin{MaBoiteDef}[SousTitre={L3}]{}{def:aaac}
\lipsum[1][1-2]
\end{MaBoiteDef}

\begin{MaBoiteRmq}[]{}{rmq:aaad}
\lipsum[1][1-2]
\end{MaBoiteRmq}

\begin{MaBoiteThm}[SousTitre={MPSI},ComplementTitre={~Mega important}]{LE THÉORÈME}{thm:aaae}
\lipsum[1][1-2]
\end{MaBoiteThm}


\end{document}