我想为我的学生建立一个有创意的练习和问题集。我无法利用附件中的资源创建与附件中所示的相同图形。有人能帮我吗?
\documentclass[italian]{book}
\usepackage{amssymb,latexsym, mathtools}
\usepackage[utf8]{inputenc}
\usepackage{babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{stackengine,xcolor}
\let\svitem\item
\newcommand\difbox[1]{\stackengine{0pt}{\color{gray!30}\rule{5ex}{1.15ex}}{%
\color{red}$\mkern1mu\makeballs{#1}$}{O}{c}{F}{F}{L}}
\def\makeballs#1{\ifnum#1>0\relax{\bullet}%
\expandafter\makeballs\the\numexpr#1-1\relax\fi}
\newenvironment{benumerate}
{\renewcommand\item[1][1]{\def\difficulty{##1}\svitem}%
\def\labelenumi{\smash{\stackunder[1pt]{\color{teal}%
\bfseries\sffamily\large\theenumi}{\difbox{\difficulty}}}}%
\enumerate}{\endenumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{siunitx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titlesec}
\usepackage{multicol}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=2cm]{geometry}
% \usepackage[a4paper,left=2.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm,
% marginparsep=3mm,marginparwidth=18mm,
%headheight=0mm,headsep=0cm,
%footskip=1.5cm,includeheadfoot%,showframe
%]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{fadings}
% Headers
\definecolor{gray}{cmyk}{0,0,0,0.4}
\definecolor{darkgrey}{cmyk}{0,0,0,0.6}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhead{} % Remove head fields
\fancyfoot{} % Remove foot fields
\setlength{\headheight}{24pt}
\fancyhead[RO]{\sffamily\bfseries\footnotesize\textcolor{gray}\leftmark\hspace{0.3cm}\sffamily\bfseries\normalsize\textcolor{darkgray}\thepage}
\fancyhead[LE]{\sffamily\bfseries\textcolor{darkgray}\thepage\hspace{0.3cm}\sffamily\bfseries\footnotesize\textcolor{gray}\leftmark}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headrule}{%
\vskip-\baselineskip\vskip4pt
\ifodd\count0\hfill\begin{tikzpicture}
\fill[darkgray,path fading=west] (0,0) rectangle (4.98,0.02);
\end{tikzpicture}\else\begin{tikzpicture}
\fill[darkgray,path fading=east] (0,0) rectangle (4.98,0.02);
\end{tikzpicture}\fi}
\parindent0pt
\parskip6pt
\makeatletter
\makeatother
\newcounter{myExercise}[section]
\setcounter{myExercise}{1}
\newcommand\exercise{\textbf{Esercizi \thesection.\stepcounter{myExercise}\themyExercise.\,}}
\newcommand\mySol[1]{\textcolor{cyan!20!blue}{[$#1$]}}
\setlength{\columnsep}{12pt}
\setlength\columnseprule{0pt}
\begin{document}
\section*{Velocità}
\begin{multicols}{2}
\begin{benumerate}
\item[1]
Un'automobile transita al km 25 di un'autostrada alle ore 8:25 e transita al km 29 alle ore 8:27. Qual è la sua velocità media in km/h? \hfill\mySol{120\,\, \text{km/h}}
\item[2] In autostrada ogni kilometro è contrassegnato da un numero. Guardando fuori dal finestrino, ti accorgi che passano 36 s tra un cartello e l'altro. A quale velocità stai procedendo? \hfill\mySol{100\,\, \text{km/h}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\item
\hfill\mySol{\ldots}
\end{benumerate}
\end{multicols}
\end{document}
答案1
我试图重现图形和外观,但还有更多的工作要做,而且留给了 OP,因为有些硬编码部分实际上无法配置。
tcolorbox
通过使用和节点可以实现等级/技能水平框最简单的定位TikZ
。
该\mylib
代码是从tcolorbox
文档中“窃取”的。
\documentclass[italian]{book}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{stackengine}
\usepackage{xcolor}
\newcommand\difbox[1]{\stackengine{0pt}{\color{gray!30}\rule{5ex}{1.15ex}}{%
\color{red}$\mkern1mu\makeballs{#1}$}{O}{c}{F}{F}{L}}
\def\makeballs#1{\ifnum#1>0\relax{\bullet}%
\expandafter\makeballs\the\numexpr#1-1\relax\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[copy-decimal-marker,color=blue]{siunitx}
\usepackage{multicol}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=2cm]{geometry}
% \usepackage[a4paper,left=2.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm,
% marginparsep=3mm,marginparwidth=18mm,
%headheight=0mm,headsep=0cm,
%footskip=1.5cm,includeheadfoot%,showframe
%]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr} % Load fancyhdr after geometry!
\usepackage{tikz}
\usetikzlibrary{fadings}
% Headers
\definecolor{gray}{cmyk}{0,0,0,0.4}
\definecolor{darkgrey}{cmyk}{0,0,0,0.6}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhead{} % Remove head fields
\fancyfoot{} % Remove foot fields
\setlength{\headheight}{24pt}
\fancyhead[RO]{\sffamily\bfseries\footnotesize\textcolor{gray}\leftmark\hspace{0.3cm}\sffamily\bfseries\normalsize\textcolor{darkgray}\thepage}
\fancyhead[LE]{\sffamily\bfseries\textcolor{darkgray}\thepage\hspace{0.3cm}\sffamily\bfseries\footnotesize\textcolor{gray}\leftmark}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headrule}{%
\vskip-\baselineskip\vskip4pt
\ifodd\count0\hfill\begin{tikzpicture}
\fill[darkgray,path fading=west] (0,0) rectangle (4.98,0.02);
\end{tikzpicture}\else\begin{tikzpicture}
\fill[darkgray,path fading=east] (0,0) rectangle (4.98,0.02);
\end{tikzpicture}\fi}
\parindent0em
\parskip6pt
\setlength{\columnsep}{12pt}
\setlength{\columnseprule}{0pt}
\usepackage[most]{tcolorbox}
\newtcbox{\mylib}{enhanced,nobeforeafter,tcbox raise base,boxrule=0.4pt,top=0mm,bottom=0mm,
right=0mm,left=4mm,arc=1pt,boxsep=2pt,before upper={\vphantom{dlg}},
colframe=green!50!black,coltext=green!25!black,colback=green!10!white,
overlay={\begin{tcbclipinterior}\fill[green!75!blue!50!white] (frame.south west)
rectangle node[text=white,font=\sffamily\bfseries\tiny,rotate=90] {Tema} ([xshift=4mm]frame.north west);\end{tcbclipinterior}}}
\makeatletter
\newcommand{\exercisesidebox}[1]{%
\def\difficulty{#1}%
\stackunder[1pt]{\color{teal}\bfseries\sffamily\large\the\c@tcb@cnt@exercise}{\difbox{\difficulty}}%
}
\makeatother
\newcommand\mySol[1]{\textcolor{cyan!20!blue}{[$#1$]}}
\newtcolorbox[auto counter, number within=section]{exercise}[2][]{%
right skip={20pt},
enhanced jigsaw,
sharp corners,
frame hidden,
colback=white,
overlay={\node[xshift=0.3em,yshift=-1.5em] (A) at (frame.north west) {\exercisesidebox{#2}};} %Change the shift values to place the box more appropiately.
#1
}
\begin{document}
\section*{\mylib{Velocità}}
\begin{multicols}{2}
\begin{exercise}{1}
Un'automobile transita al \SI{25}{\kilo\meter} di un'autostrada alle ore 8:25 e transita al \SI{29}{\kilo\meter} alle ore 8:27. Qual è la sua velocità media in \si{\kilo\meter/\hour}? \hfill\mySol{\SI{120}{\kilo\meter/\hour}}
\end{exercise}
\begin{exercise}{2}
In autostrada ogni kilometro è contrassegnato da un numero. Guardando fuori dal finestrino, ti accorgi che passano \SI{36}{\second} tra un cartello e l'altro. A quale velocità stai procedendo? \hfill\mySol{\SI{100}{\kilo\meter/\hour}}
\end{exercise}
\begin{exercise}{3}
Proof that there is a typesetting system better than \LaTeXe.
\end{exercise}
\end{multicols}
\end{document}