# Writing exercices in a certain fashion

I am trying to write to code that makes exercices look like the picture below. Here’s my code. The stars give information about the exercice difficulty level which are graded 1,2 or 3. The first is picture i want and the second, what i actually have Thanks for any help

\documentclass[11pt]{book}
\usepackage[margin=2.5cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{mathrsfs}

\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\newtcolorbox{exercisebox}%
{
enhanced,
breakable,
colback=white, colframe=green!15!white,
colbacktitle=white!15!pink, coltitle=pink!50!black,
left=0pt,right=0mm,top=3mm,bottom=3mm,
pad at break=0pt,bottomrule at break=0pt,toprule at break=0pt,
borderline={0mm}{0mm}{green!50!white,dashed},
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.4pt},
title=EXERCICES,
}

\usepackage{eso-pic}
\usepackage{etoolbox}
\usepackage{enumitem}
\newcommand\circitem[1]{%
\tikz[baseline=(char.base)]{%https://tex.stackexchange.com/questions/204116/uniform-size-of-circles-around-enumitems
\node[circle,draw=gray, fill=gray!30,
minimum size=1.2em,inner sep=0] (char) {#1};}}
\newcommand\boxitem[1]{%
\tikz[baseline=(char.base)]{%https://tex.stackexchange.com/questions/204116/uniform-size-of-circles-around-enumitems
\node[fill=orange!30,
minimum size=1.2em,inner sep=0] (char) {#1};}}
\AtBeginEnvironment{tcolorbox}{%
\setlist[enumerate,1]{label=\protect\boxitem{\arabic*}}
\setlist[enumerate,2]{label=\protect\circitem{\alph*}}
}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{xcolor}
\newcommand\Exercice[1]{\fboxrule1.5pt%
\fcolorbox{gray}% frame
{cyan}% background
{\large\itshape\textbf{Exercise~#1}}%
\par\medskip}

\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows}
\usepackage{tkz-tab}
\usepackage{mdframed}

\usepackage{varwidth}
\usepackage{listings}
\usepackage{hyperref}

\usepackage{lipsum}

\begin{document}
\section{EXERCICES}

\begin{exercisebox}
\Exercice{1}
Determiner la valeur de $a$ pour que $f$ définie par:\\
$\begin{cases} f(x)=\dfrac{\sqrt{\sin(x)}-1}{x-\frac\pi2};\text{ si } x\ne\frac\pi2\\ f\left(\dfrac\pi2\right)=a \end{cases}$ soit continue en $\dfrac\pi2$

\end{exercisebox}
\end{document}

• You mention rating the difficulty of the exercise using one through three stars, but the example image shows three half filled stars. Which difficulty level does that translate to? How would an exercise of the difficulty level one look like? Just one star instead of the three or one color filled star alongside two outlined but empty ones? Oct 24 at 12:54
• Your current code produces a box with a partly green dashed border, while the image you included does not show such a border. Do you want to keep it? Oct 24 at 12:55
• Exaclty this picture does not involves the difficulty rating, but that is what i really want to do Oct 24 at 12:56
• It is not necessary to keep the green border Oct 24 at 12:58
• If the image dos not correctly show the difficulty rating, then please prepare a sketch of what you would like it lo look like. Especially: do you need half filled stars or only completely filled stars? Oct 24 at 12:58

\documentclass{article}

\usepackage{amsmath,amssymb}
\usepackage{nccmath}

\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{decorations.pathmorphing, positioning}

\newcounter{mycounter}
\setlength{\parindent}{0pt}
\definecolor{myblue}{RGB}{0,163,217}

\usepackage{fontawesome}
\newcommand{\onestar}{\faStar~\faStarO~\faStarO}                                     % difficulty ratings. I you don't want the outlined but empty star, remove \faStarO.
\newcommand{\twostar}{\faStar~\faStar~\faStarO}
\newcommand{\threestar}{\faStar~\faStar~\faStar}

\usepackage{lipsum}                                                                  % for dummy text in the example boxes.
\begin{document}

\newtcolorbox{mybox}[1][\onestar]{                                                   % \onestar is the default difficulty.
step=mycounter,                                                                  % boxes are automatically numbered
enhanced,
colback=white,                                                                   % white background
frame hidden,                                                                    % hide frame
top=10pt, left=0pt, right=0pt,                                                   % top, left and right distances to the invisible borders of the box
borderline north={1pt}{0pt}{green!75!black,                                      % green zig zag line
decoration={zigzag,
amplitude=2pt,
pre=moveto,pre length=4.25cm,
post length=6.75cm},
decorate},
overlay={%
\tikzset{overlay=false, draw=none, anchor=west}
\node[fill=myblue, text=red,                                                 % background and textcolor of "Exercise" box
minimum height=1.5em] at (frame.north west) (box1){\textbf{Exercise}}; % position of "Exercise" box
\node[fill=myblue, text=red,                                                 % background and textcolor of exercise number box
right = 1mm of box1,                                                   % position of exercise number box
minimum height=1.5em] (box2){\textbf{\themycounter}};
\node[text=orange, fill=white,                                               % background and textcolor of difficulty rating box
right = 3mm of box2, ] (difficulty){#1};                               % position of difficulty rating box
}}

\begin{mybox}[\onestar]
Simplifier les expressions suivantes:
\begin{enumerate}
\item $A=\mfrac{5^3\times(3^2\times2)^{-1}}{3^{-1}\times(2^{-3}\times5)^2}$
\item ...
\end{enumerate}
\end{mybox}

\begin{mybox}[\twostar]
\lipsum[1][1-3]
\begin{enumerate}
\item \lipsum[1][1-1]
\item ...
\end{enumerate}
\end{mybox}

\begin{mybox}[\threestar]
\lipsum[1][1-3]
\begin{enumerate}
\item \lipsum[1][1-1]
\item ...
\end{enumerate}
\end{mybox}

\begin{mybox}
\lipsum[1][1-3]
\begin{enumerate}
\item \lipsum[1][1-1]
\item ...
\end{enumerate}
\end{mybox}

\end{document}

• Thank you @leandriis’s Oct 24 at 14:56
• My humble suggestion is to include a less intense pastel color than dark blue. Red on blue is generally not a good association even if it is the user's request. Good job. Oct 24 at 19:05