| 1 |
% http://tex.stackexchange.com/q/350028/ |
| 2 |
\documentclass{book} |
| 3 |
\usepackage[T1]{fontenc} |
| 4 |
\usepackage{xsim} |
| 5 |
\usepackage[most]{tcolorbox} |
| 6 |
\tcbuselibrary{skins,breakable} |
| 7 |
|
| 8 |
\DeclareExerciseEnvironmentTemplate{tcolorbox}{% |
| 9 |
\tcolorbox[ |
| 10 |
enhanced, |
| 11 |
colframe=green!20!black, |
| 12 |
colback=yellow!10!white, |
| 13 |
coltitle=green!40!black, |
| 14 |
fonttitle=\bfseries, |
| 15 |
underlay={% |
| 16 |
\begin{tcbclipinterior} |
| 17 |
\shade[ |
| 18 |
inner color=\IfInsideSolutionTF{red!50!yellow}{green!80!yellow}, |
| 19 |
outer color=yellow!10!white] |
| 20 |
(interior.north west) circle (2cm); |
| 21 |
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}] |
| 22 |
(interior.south west) grid (interior.north east); |
| 23 |
\end{tcbclipinterior}% |
| 24 |
}, |
| 25 |
attach title to upper=\quad, |
| 26 |
title = \XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter} |
| 27 |
\IfExercisePropertySetT{points}{% |
| 28 |
(\GetExerciseProperty{points} |
| 29 |
\IfExerciseGoalSingularTF{points} |
| 30 |
{\XSIMtranslate{point}} |
| 31 |
{\XSIMtranslate{points}})% |
| 32 |
}]% |
| 33 |
\IfInsideSolutionT{\label{solution:\ExerciseID}}% |
| 34 |
}{% |
| 35 |
\endtcolorbox |
| 36 |
\vspace*{\baselineskip} |
| 37 |
\IfInsideSolutionTF{% |
| 38 |
\noindent Exercise~\GetExerciseProperty{counter} is on |
| 39 |
page~\GetExerciseProperty{page}.% |
| 40 |
}{% |
| 41 |
\noindent The solution of this exercise is on |
| 42 |
page~\pageref{solution:\ExerciseID}.% |
| 43 |
}% |
| 44 |
\vspace{\baselineskip} |
| 45 |
} |
| 46 |
|
| 47 |
\xsimsetup{ |
| 48 |
exercise/template = tcolorbox , |
| 49 |
solution/template = tcolorbox |
| 50 |
} |
| 51 |
|
| 52 |
\usepackage{fmtcount,etoolbox} |
| 53 |
\newrobustcmd*\mystringnum[2]{\csname#1stringnum\endcsname{#2}} |
| 54 |
\renewcommand*\thechapter{\mystringnum{number}{\value{chapter}}} |
| 55 |
\renewcommand*\thesection{\arabic{chapter}.\arabic{section}} |
| 56 |
|
| 57 |
% for the header: \MakeUppercase{\mystringnum{number}{1}} |
| 58 |
% => \mystringnum{NUMBER}{1} |
| 59 |
% => \NUMBERstringnum{1} |
| 60 |
% elsewhere: \mystringnum{number}{1} |
| 61 |
% => \numberstringnum{1} |
| 62 |
|
| 63 |
\usepackage{totcount} |
| 64 |
\regtotcounter{chapter} |
| 65 |
|
| 66 |
\newcounter{chapters} |
| 67 |
\setcounter{chapters}{1} |
| 68 |
\newcommand*\printsolutionsperchapter{% |
| 69 |
\whileboolexpr |
| 70 |
{ test { \ifnumless {\value{chapters}} {\totvalue{chapter}+1} } } |
| 71 |
{% |
| 72 |
\printsolutions[chapter=\value{chapters},headings-template=per-chapter] |
| 73 |
\stepcounter{chapters}% |
| 74 |
}% |
| 75 |
} |
| 76 |
|
| 77 |
\begin{document} |
| 78 |
|
| 79 |
\chapter{The First Chapter} |
| 80 |
|
| 81 |
\begin{exercise} |
| 82 |
Compute the derivative of the following function: |
| 83 |
\begin{equation*} |
| 84 |
f(x) = \sin((\sin x)^2) |
| 85 |
\end{equation*} |
| 86 |
\end{exercise} |
| 87 |
\begin{solution} |
| 88 |
The derivative is: |
| 89 |
\begin{align*} |
| 90 |
f’(x) &= ( \sin((\sin x)^2) )' |
| 91 |
= \cos((\sin x)^2) \cdot 2\sin x \cos x |
| 92 |
\end{align*} |
| 93 |
\end{solution} |
| 94 |
|
| 95 |
\begin{exercise} |
| 96 |
Compute the derivative of the following function: |
| 97 |
\begin{equation*} |
| 98 |
f(x) = \sin((\sin x)^2) |
| 99 |
\end{equation*} |
| 100 |
\end{exercise} |
| 101 |
\begin{solution} |
| 102 |
The derivative is: |
| 103 |
\begin{align*} |
| 104 |
f’(x) &= ( \sin((\sin x)^2) )' |
| 105 |
= \cos((\sin x)^2) \cdot 2\sin x \cos x |
| 106 |
\end{align*} |
| 107 |
\end{solution} |
| 108 |
|
| 109 |
\chapter{The Second Chapter} |
| 110 |
|
| 111 |
\begin{exercise} |
| 112 |
Compute the derivative of the following function: |
| 113 |
\begin{equation*} |
| 114 |
f(x) = (x^2+1) \sqrt{x^4+1} |
| 115 |
\end{equation*} |
| 116 |
\end{exercise} |
| 117 |
\begin{solution} |
| 118 |
The derivative is: |
| 119 |
\begin{align*} |
| 120 |
f’(x) &= ( (x^2+1) \sqrt{x^4+1} )' |
| 121 |
= 2x\sqrt{x^4+1} + \frac{2x^3(x^2+1)}{\sqrt{x^4+1}} |
| 122 |
\end{align*} |
| 123 |
\end{solution} |
| 124 |
|
| 125 |
\clearpage |
| 126 |
\section{Solutions of the Exercices} |
| 127 |
|
| 128 |
\printsolutionsperchapter |
| 129 |
|
| 130 |
\end{document} |