按照特定方式编写练习

按照特定方式编写练习

我正在尝试编写代码,使练习看起来像下面的图片。这是我的代码。星星提供了有关练习难度级别的信息,分为 1、2 或 3 级。第一个是我想要的图片,第二个是我实际拥有的,感谢您的帮助

在此处输入图片描述 在此处输入图片描述

\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{pstricks-add}
\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}

答案1

在此处输入图片描述

\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}

相关内容