仅使用 tcolorbox 在下部显示帮助行

仅使用 tcolorbox 在下部显示帮助行

使用 tcolorbox 包为教科书制作练习,我使用选项invisible为学生留出空间来写他们的解决方案。现在我想help lines只在下半部分使用覆盖命令,而不是在上半部分,这样就可以得到一个背景为空白的上半部分。我该怎么做?

help lines另外,我可以在下部使用更通用的命令吗?该命令仅插入水平线,而不插入垂直线?

编辑:当练习中断时,首先给出的解决方案没有用,我们会收到错误消息:! Package pgf Error: No shape named segmentation is known.

我举一个打破这个练习的例子:

\documentclass{book}

\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\NewTColorBox[auto counter,number within=chapter]{exercise}{m+O{}}{%
    enhanced,
    breakable,
    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:#1},
    attach title to upper=\quad,
    segmentation style={double=white,draw=green!20!black,double distance=1pt,solid},
    lowerbox=invisible,
    savelowerto=solutions/exercise-\thetcbcounter.tex,
    record={\string\solution{#1}{solutions/exercise-\thetcbcounter.tex}},
    #2
}

\begin{document}
\pagestyle{empty}
\tcbstartrecording
\begin{exercise}{Ex1}[coltitle=cyan!80!black]
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
Compute the derivative of the following function:
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}
\tcblower
The derivative is:
\[f^\prime(x) = \cos((\sin x)^2) 2\sin x \cos x.\]
\end{exercise}

\tcbstoprecording
\end{document}

及其汇编: 在此处输入图片描述

答案1

只需(interior.south west) grid (interior.north east)替换(interior.south west) grid (segmentation.east)

重新编辑如下:

  1. \myunderlay定义了一个名为的新命令
  2. 彩色盒子选项:underlay unbroken=\myunderlayunderlay last=\myunderlay被添加来代替underlay={...}

\documentclass{book}

\usepackage{etoolbox,lipsum}
\usepackage[most]{tcolorbox}

\newcommand{\myunderlay}{
  \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 (segmentation.east); % modified
          \end{tcbclipinterior}
        }

\NewTColorBox[auto counter,number within=chapter]{exercise}{m+O{}}{%
    enhanced,
    breakable,
    colframe=green!20!black,
    colback=yellow!10!white,
    coltitle=green!40!black,
    fonttitle=\bfseries,
    underlay unbroken=\myunderlay,
    underlay last=\myunderlay,
    title={Exercise~ \thetcbcounter:},
    label={exercise:#1},
    attach title to upper=\quad,
    segmentation style={double=white,draw=green!20!black,double distance=1pt,solid},
    lowerbox=invisible,
    %savelowerto=solutions/exercise-\thetcbcounter.tex,
    record={\string\solution{#1}{solutions/exercise-\thetcbcounter.tex}},
    #2,
}

\begin{document}
\pagestyle{empty} 
\tcbstartrecording
\begin{exercise}{Ex1}[coltitle=cyan!80!black]
Compute the derivative of the following function: 
\begin{equation*}
f(x)=\sin((\sin x)^2)
\end{equation*}

\lipsum[1-3] 
\tcblower
The derivative is:
\[f^\prime(x) = \cos((\sin x)^2) 2\sin x \cos x.\]
\end{exercise}




\tcbstoprecording


\end{document}

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

相关内容