编译期间发生的错误(PDFLatex)

编译期间发生的错误(PDFLatex)

以下是编译过程中出现的错误。

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "xparse/unknown-argument-type"
! 
! Unknown argument type '!' replaced by 'm'.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  
                                                  
l.105 }

在 .tex 文件中,我使用了 tikz&pgf 文档中的模板,其中包含以下代码(在第 105 行结束):

\documentclass[a4paper]{memoir}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{lipsum}


\tcbuselibrary{skins,hooks}
\usetikzlibrary{shadows.blur}



% Ex si solutii fara labeling
\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.northwest)}]
                    (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}
\chapter{Execices}%


%\vspace{-1cm}%

\tcbstartrecording\relax

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

\begin{exercise}[no solution]
It holds:
\begin{equation*}
\frac{d}{dx}\left(\ln|x|\right) = \frac{1}{x}.
\end{equation*}
\end{exercise}

\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)'=2\sin(\sin x)\cos(\sin x)\cos x.
\end{align*}
\end{exercise}

\tcbstoprecording

\newpage
\tcbinputrecords


\end{document} 

这个问题该如何解决?

答案1

应用以下更改后,您的示例即可编译。

  • 要使用\NewTColorBox命令,您需要tcolorboxxparse
  • 要使用equations*环境,您需要amsmath包。
  • 要将 tcolorbox 的下半部分保存到子目录中的文件中solutions,如下所示
    savelowerto=solutions/exercise-\thetcbcounter.tex,
    
    您需要创建子目录solutions
  • 替换northwest为一行
    \draw[help lines,step=5mm,yellow!80!black,shift={(interior.northwest)}]
    
    north west。注意空格。

输出

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

相关内容