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

enter image description here enter image description here



    colback=white, colframe=green!15!white,
    colbacktitle=white!15!pink, coltitle=pink!50!black,
    pad at break=0pt,bottomrule at break=0pt,toprule at break=0pt,
    attach boxed title to top center={yshift=-2mm},
    boxed title style={boxrule=0.4pt},

        \node[circle,draw=gray, fill=gray!30,
              minimum size=1.2em,inner sep=0] (char) {#1};}}
              minimum size=1.2em,inner sep=0] (char) {#1};}}
\fcolorbox{gray}% frame
          {cyan}% background





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

  • 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?
    – leandriis
    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?
    – leandriis
    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?
    – leandriis
    Oct 24 at 12:58

enter image description here



\usetikzlibrary{decorations.pathmorphing, positioning}


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

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

\newtcolorbox{mybox}[1][\onestar]{                                                   % \onestar is the default difficulty.
    step=mycounter,                                                                  % boxes are automatically numbered    
    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
                                            pre=moveto,pre length=4.25cm, 
                                            post length=6.75cm},
        \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

Simplifier les expressions suivantes:
    \item $A=\mfrac{5^3\times(3^2\times2)^{-1}}{3^{-1}\times(2^{-3}\times5)^2}$
    \item ...

    \item \lipsum[1][1-1]
    \item ...

    \item \lipsum[1][1-1]
    \item ...

    \item \lipsum[1][1-1]
    \item ...

  • 1
    Thank you @leandriis’s
    Oct 24 at 14:56
  • 7
    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.
    – Sebastiano
    Oct 24 at 19:05

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.