5 请问下在tcolorbox的说明文档中,我想实现151-155的exercise和solution,弄了半天还是不行,麻烦大佬帮忙看一下

发布于 2024-07-24 20:23:19

6fe28fb46b7321a7d4c69541fb96b0b7.png
请问下在tcolorbox的说明文档中,我想实现151-155的exercise和solution,弄了半天还是不行,麻烦大佬帮助看一下11.tex

查看更多

关注者
0
被浏览
472
2 个回答
Sagittarius Rover
Sagittarius Rover 2024-07-24
我要成为TikZ糕手/(ㄒoㄒ)/~~

文档其实写的很详细了
使用命令行编译后可以发现需要在当前目录下新建一个solutions文件夹,tbc会将solution写入该文件夹
这是由savelowerto命令指定的
image.png
你不能编译的一大原因是找不到solutions文件夹

你还有其他一些问题
例如没有引入amsmath,调用skins和xparse库的方式都不对等原因

目录结构应如下【注意应自己建一个solutions文件夹】
image.png

下面是实测可以运行的MWE

\documentclass{ctexart}
\usepackage[margin=1.5cm]{geometry}
\usepackage{amsmath}
\usepackage{tcolorbox}
\usepackage{xcolor}
\tcbuselibrary{skins,xparse}

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

\tcbstartrecording\relax
\begin{document}
\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}
\begin{exercise}
    Compute the derivative of the following function:
    \begin{equation*}
        f(x)=\sqrt{x^3-6x^2+2x}
    \end{equation*}
    \tcblower
    The derivative is:
    \begin{align*}
        f'(x) & = \left( \sqrt{x^3-6x^2+2x} \right)'
        = \frac{3x^2-12x+2}{2\sqrt{x^3-6x^2+2x}}.
    \end{align*}
\end{exercise}
\begin{exercise}
    Compute the derivative of the following function:
    \begin{equation*}
        f(x)=\left(\frac{2+3x}{1-2x}\right)^3
    \end{equation*}
    \tcblower
    The derivative is:
    \begin{align*}
        f'(x) & = \left( \left(\frac{2+3x}{1-2x}\right)^3 \right)'
        = 3 \left(\frac{2+3x}{1-2x}\right)^2 \frac{(1-2x)3-(2+3x)(-2)}{(1-2x)^2}
        = \frac{21(2+3x)^2}{(1-2x)^4}.
    \end{align*}
\end{exercise}
\begin{exercise}
    Compute the derivative of the following function:
    \begin{equation*}
        f(x)=\frac{\cos x}{(\tan 2x)^2}
    \end{equation*}
    \tcblower
    The derivative is:
    \begin{align*}
        f'(x) & = \left( \frac{\cos x}{(\tan 2x)^2} \right)'
        = \left( \frac{\cos x (\cos 2x)^2}{(\sin 2x)^2} \right)'                       \\
              & = \frac{(\sin 2x)^2 [(-\sin x)(\cos 2x)^2+(\cos x)4\cos 2x (-\sin 2x)]
        - \cos x (\cos 2x)^2 4\sin 2x \cos 2x}{(\sin 2x)^4}                            \\
              & = -\frac{\cos(2x) [\sin x \sin 2x \cos 2x+ 4\cos x(\sin 2x)^2
        + 4 \cos x (\cos 2x)^2]}{(\sin 2x)^3}                                          \\
              & = -\frac{\cos(2x) [\sin x \sin 2x \cos 2x+ 4\cos x]}{(\sin 2x)^3}.
        152
    \end{align*}
\end{exercise}
\begin{exercise}
    Compute the derivative of the following function:
    \begin{equation*}
        f(x)=\cos((2x^2+3)^3)
    \end{equation*}
    \tcblower
    The derivative is:
    \begin{align*}
        f'(x) & = \left( \cos((2x^2+3)^3) \right)'
        =-\sin((2x^2+3)^3) 3(2x^2+3)^2 2\cdot 2x   \\
              & =-12x(2x^2+3)^2\sin((2x^2+3)^3).
    \end{align*}
\end{exercise}
\begin{exercise}
    Compute the derivative of the following function:
    \begin{equation*}
        f(x)=(x^2+1)\sqrt{x^4+1}
    \end{equation*}
    \tcblower
    The derivative is:
    \begin{align*}
        f'(x) & = \left( (x^2+1)\sqrt{x^4+1} \right)'
        = 2x\sqrt{x^4+1} + \frac{2x^3(x^2+1)}{\sqrt{x^4+1}}.
    \end{align*}
\end{exercise}
\tcbstoprecording

\tcbinputrecords

\end{document}

多看看文档,多看看lshort,你给的MWE实际上还有一些自己乱添加的东西,注意MWE的定义
MWE.jpg

同时还要注意要得到page的索引还得至少进行两次xelatex的编译....
以及尽量避免 弄了半天还是不行 这种信息量很低的话,具体是哪里不行?命令行运行的报错是什么?你的期望效果是什么?
下面是压缩包文件,Happy Texing!

mmmwe.zip

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览