5 下列代码是从tcolorbox宏包的官方说明文档中复制,但是编译时会报错如下图所示,请求解决方案。

发布于 2023-03-31 21:17:45

代码如下

\documentclass{article}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable}

\NewTColorBox[auto counter,number within=section]{exercise}{+O{}}{%
enhanced,
colframe=green!20!black,colback=yellow!10!white,coltitle=green!40!black,
fonttitle=\bfseries,
underlay={
\begin{tcbclipinterior}
\shade[inner color=green!80!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}
},
title={Exercise~ \thetcbcounter:},
label={exercise@\thetcbcounter},
attach title to upper=\quad,
after upper={\par\hfill\textcolor{green!40!black}%
{\itshape Solution on page~\pageref{solution@\thetcbcounter}}},
lowerbox=ignored,
savelowerto=solutions/exercise-\thetcbcounter.tex,
record={\string\solution{\thetcbcounter}{solutions/exercise-\thetcbcounter.tex}},
#1
}

\NewTotalTColorBox{\solution}{mm}{%
enhanced,
colframe=red!20!black,colback=yellow!10!white,coltitle=red!40!black,
fonttitle=\bfseries,
underlay={
\begin{tcbclipinterior}
\shade[inner color=red!50!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}
},
title={Solution of Exercise~\ref{exercise@#1} on page~\pageref{exercise@#1}:},
phantomlabel={solution@#1},
attach title to upper=\par,
}{\input{#2}}

\tcbset{no solution/.style={no recording,after upper=}}

\begin{document}

\section{Exercises}

\tcbstartrecording
\begin{exercise}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
\tcblower
The derivative is:
\begin{align*}
f ' (x) &= \left( \sin((\sin x)^2) \right) '
=\cos((\sin x)^2) 2\sin x \cos x.
\end{align*}
\end{exercise}
\tcbstoprecording

\newpage

\section{Solutions}

\tcbinputrecords

\end{document}

报错信息如下图所示。
image.png

查看更多

关注者
1
被浏览
1.2k
latex业余爱好者
这家伙很懒,什么也没写!

您缺少了一个文件夹solutions,将该文件夹和您的源文件放在一起编译即可solutions.zip

1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览