답변1
여기서 핵심은 다음과 같다고 생각합니다.
example
예제 자체가 다음과 같이 되도록 상자를 정의할 수 있습니다.높은솔루션은 상자의 일부인 반면낮추다부분. 그런 다음 상자 내부에서\tcblower
솔루션으로 전환하는 데 사용할 수 있습니다.- 키를 사용하여
before lower
상자의 솔루션 부분 제목을 설정할 수 있습니다. - 예제에 번호를 매기는 옵션을 원할 경우 라이브러리를 사용하여
theorems
으로 상자를 정의 할 수 있습니다\newtcbtheorem
. 이렇게 하면 별표 표시된 버전의 상자 환경에 번호가 지정되지 않습니다.
그래서 나는 이런 것을 사용할 것입니다
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem{example}{Example}{
theorem style=plain,
arc=2mm,
boxrule=.2mm,
coltitle=black,
colframe=blue!50!black,
colback=blue!5!white,
fonttitle=\sffamily\bfseries,
coltitle=blue!50!black,
before lower={\textcolor{blue!50!black}{\textsf{\textbf{Solution:}}}\ },
}{}
\begin{document}
\begin{example*}{}
The result (1.40) can be obtained by direct Taylor series expansion of \(1/\lvert\mathbf{x} - \mathbf{x}'\rvert\). Try to finish it by yourself.
\tcblower
From the Taylor series:
\[
\Phi(\mathbf{x}) = \Phi(0) + \mathbf{x} \cdot \nabla\Phi(0) + \frac{1}{2} \sum_{i=1}^3 \sum_{j=1}^3 x_i x_j \frac{\partial^2\Phi}{\partial x_i \partial x_j} + \cdots
\]
\end{example*}
\end{document}
답변2
내 생각엔 내가 해야 할 일에 대답하면 안 된다고 생각합니다.
문제를 일으키는 원인에 대한 코드나 표시는 제공하지 않으며 표시된 상자의 어떤 기능이 귀하에게 중요한지에 대한 힌트도 제공하지 않습니다. 다음은 시작점으로 유용할 수도 있고 그렇지 않을 수도 있습니다. (그러나 패키지 문서에서 더 나은 설명과 함께 최소한 유용한 예제를 얻을 수 있습니다.)
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{xparse,skins,hooks}
\colorlet{bcol}{blue!50!black}
\NewTColorBox
{egbox}{ O {\linewidth} O {} }
{
bocs,
before upper app={\textsf{\textcolor{bcol}{Example: }}},
before lower app={\textsf{\textcolor{bcol}{Solution: }}},
halign lower=left,
width=#1,
#2,
}
\tcbset{%
bocs/.style={%
colframe=bcol,
colback=gray!20,
boxrule=.75mm,
boxsep=.25mm,
toptitle=.75mm,
bottomtitle=.75mm,
fonttitle=\sffamily,
},
}
\begin{document}
\begin{egbox}
Some stuff.
\tcblower
Some more stuff.
\end{egbox}
\begin{egbox}[.5\linewidth]
Some stuff.
\tcblower
Some more stuff.
\end{egbox}
\begin{egbox}[.4\linewidth][colframe=red]
Some stuff.
\tcblower
Some more stuff.
\end{egbox}
\end{document}