如何在定理,定义和练习中使用tcolorbox

时间:2016-10-23 08:30:33

标签: latex

我在tcolorboxes中编写了一个带有定理和定义的数学模块。使用tcolorbox包中的文档tcolorbox,我能够编写定理和定义,但是我的练习有问题。该文件不清楚如何设置锻炼环境。下面是我的第1部分的mwe,它适用于定理和定义,第3部分(适用于练习)不起作用。 我希望通过tweeking练习环境的序言来工作。

\documentclass[11pt,twoside,fleqn]{report}
\usepackage[listings]{tcolorbox}

\tcbuselibrary{listings,theorems}
\newtcbtheorem[number within=section]{mytheo}{Theorem}%
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries}{th}

\usepackage{cleveref}
\tcbset{
defstyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=blue!5!white,colframe=blue!75!black},
theostyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
colback=red!10!white,colframe=red!75!black},
}
\newtcbtheorem[number within=subsection,crefname={definition}
{definitions}]%
\newtcbtheorem[number within=subsection,crefname={definition}
{definitions}]%

{Definition}{Definition}{defstyle}{def}
\newtcbtheorem[use counter from=Definition,crefname={theorem}{theorems}]%
{Theorem}{Theorem}{theostyle}{theo}
\newtcbtheorem[use counter from=Definition,crefname={corollary}
{corollaries}]%
{Corollary}{Corollary}{theostyle}{cor}

Preamble在这里不起作用(未定义的控制序列)

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

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

\begin{document}
\begin{mytheo}{}{theoexample}
\begin{enumerate}
\item $(A+B)+C=A+(B+C)$
\item $A+0=A$
\item $A+(-A)=0$
\item $A+B=B+A$
\item $k_1(A+B)=k_1A+k_1B$
\item $(k_1+k_2)A=K_1A+K_2A$
\item $(k_1k_2)A=k_1(k_2A)$
\item $1A=A$\quad and\quad $0A=0$
\end{enumerate}
\end{mytheo}

\begin{Definition}{Differenzierbarkeit}{diffbarkeit}
An n-tuple $\displaystyle (x_1, x_2, \dots, x_n)$ which satisfies each of
the m equations in the system is called a solution of the system. Two 
systems of equations are $\textbf{equivalent}$ if every solution of one 
system is a solution of the other system and vice versa. A system of linear
equations is called a $\textbf{homogeneous system}$ if $\displaystyle 
b_i=0(i=1, 2, \dots, m)$. A system with at least one solution is called a
 $\textbf{consistent system}$. The solution $\displaystyle (0, 0, \dots,
0)$ of a homogeneous system is called the $\textbf{trivial solution}$.
\end{Definition}

以下部分不起作用

\begin{exercise}
Find the inverse of $A=\begin{pmatrix*}[r]
2 & 5\\
1 & 3
 \end{pmatrix*}$
\tcblower
We seek a matrix $B=\begin{pmatrix*}[r]
a & b\\
c & d
\end{pmatrix*}$ such that $AB=\begin{pmatrix*}[r]
2 & 5\\
1 & 3\\
\end{pmatrix*}\begin{pmatrix*}[r]
a & b\\
c & d
\end{pmatrix*} =\begin{pmatrix*}[r]
1 & 0\\
0 & 1
\end{pmatrix*}$\par
 $AB=\begin{pmatrix*}[r]
2a+5c & 2b+5d\\
a+3c & b+3d
\end{pmatrix*}$=$\begin{pmatrix*}[r]
1 & 0\\
0 & 1
\end{pmatrix*}$\hspace{10pt} i.e
\systeme{2a+5c=1,a+3c=0}\hspace{1ex}\systeme{2b+5d=0,b+3d=1}\\
Solving for a, b, c, d gives $B=A^{-1}=\begin{pmatrix*}[r]
3 & -5\\
-1 & 1\\
\end{pmatrix*}$
 \end{exercise}
\end{document}

同样,如果有人在tcolorbox中有一个我可以适应的练习例子,我将不胜感激。

0 个答案:

没有答案
相关问题