在marginpar中带有标题和示例编号的练习框

发布于 2022-09-04 22:15:52

在marginpar中带有标题和示例编号的练习框,可以实现下面样式:
image.png

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{tasks}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{mygreen}{HTML}{A5B37A}
\setlist{label=\textcolor{mygreen}{\bfseries\arabic*},leftmargin=0cm}
\settasks{%
counter-format=tsk[a],%
label-format=\bfseries\color{mygreen},%
label-offset=1ex,%
label-align=right,%
label-width=1ex,%
item-indent=0em,
column-sep=1em,
after-item-skip=0pt}

\newcounter{example}

\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\sffamily\bfseries,
         top=0mm,
         bottom=0mm,
         right=0mm,
        colback=white,
        colframe=white,
        colbacktitle=mygreen,
        coltitle=white,
        attach boxed title to top left,
        boxed title style={sharp corners},
        },
    L/.style={
            \stepcounter{example}
            \draw [ultra thick,mygreen] ($(frame.north west)+(0.1em,0.1em)$)--($(frame.north east)+(0,0.1em)$);
            \node [text=mygreen,anchor=south east] at (frame.north east) {\bfseries\sffamily FOUNDATION};
            \node [draw,mygreen,text=black,thick,anchor=north east] at (frame.north west) {Example \the\value{example}};
        },
}

\newtcbtheorem[]{proof}{Exercise}{thmbox,L}{theo}

\begin{document}

\begin{proof}{}{}

\begin{enumerate}

\item Simplify:

\begin{tasks}(4)
\task $5x+3x$
\task $5x-3x$
\task $-5x+3x$
\task $-5x-3x$
\end{tasks}

\item Simplify:

\begin{tasks}(4)
\task $-2a+3a+4a$
\task $-2a-3a+4a$
\task $-2a-3a-4a$
\task $-2a+3a-4a$
\end{tasks}
\end{enumerate}

\end{proof}

\end{document}

样式二:
image.png

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{tasks,enumerate,xcolor,marginnote}

\colorlet{exercisecolor}{green!70!black!50!brown}
\settasks{counter-format=tsk[a],label-format=\sffamily\bfseries\color{exercisecolor}}
\newcounter{example}
\reversemarginpar
\newcommand\examplenumber{%
  \refstepcounter{example}
  \marginnote{%
    \color{exercisecolor}%
    \fbox{\sffamily Example \arabic{example}}%
  }%
}%
\newenvironment{exercise}[2]{
  {
    \color{exercisecolor}%
    \noindent\colorbox{exercisecolor}{%
      \color{white}\sffamily\bfseries\large Exercise #1%
    }\hfill\textsf{\bfseries #2}
    \hrule depth 0.1em\relax
  }%
  \enumerate[\color{exercisecolor}\bfseries1]%
}{\endenumerate}
\begin{document}

\begin{exercise}{3A}{FOUNDATION}
  \item\examplenumber Simplify:
    \begin{tasks}(4)
    \task $5x+3x$
    \task $5x-3x$
    \task $-5x+3x$
    \task $-5x-3x$
    \end{tasks}

  \item Simplify:
    \begin{tasks}(4)
    \task $-2a+3a+4a$
    \task $-2a-3a+4a$
    \task $-2a-3a-4a$
    \task $-2a+3a-4a$
    \end{tasks}
\end{exercise}

\end{document}

选自这里:https://tex.stackexchange.com/questions/414375/exercise-box-with-title-and-example-number-in-marginpar

0 条评论

发布
问题