Browse Source

Replace mdframed with tcolorbox

pull/253/head
Kazuhiko Sakaguchi 2 years ago
parent
commit
71f38366a9
  1. 2
      examples/documentation/chapters/layout.tex
  2. 4
      examples/documentation/chapters/mathematics.tex
  3. 2
      examples/documentation/chapters/options.tex
  4. 2
      examples/documentation/chapters/textnotes.tex
  5. 62
      kao.sty
  6. 135
      kaotheorems.sty

2
examples/documentation/chapters/layout.tex

@ -82,7 +82,7 @@ for chapter titles.
\section{\Option{twoside} mode}
\begin{kaobox}[frametitle=To Do]
\begin{kaobox}[title=To Do]
The \Option{twoside} class option is still unstable and may lead to
unexpected behaviours. Great strides have been done since the first
version of \Class{kaobook}, but some work still needs to be done. As

4
examples/documentation/chapters/mathematics.tex

@ -138,7 +138,7 @@ a box in these cases. We used \Package{mdframed} to construct the ones
shown below. You can create and modify such environments by editing the
provided file \href{kao.sty}{kao.sty}.
\begin{kaobox}[frametitle=Title of the box]
\begin{kaobox}[title=Title of the box]
\blindtext
\end{kaobox}
@ -156,7 +156,7 @@ are encouraged to try their own experiments and let me know the
outcomes.
\marginnote[-2.2cm]{
\begin{kaobox}[frametitle=title of margin note]
\begin{kaobox}[title=title of margin note]
Margin note inside a kaobox.\\
(Actually, kaobox inside a marginnote!)
\end{kaobox}

2
examples/documentation/chapters/options.tex

@ -36,7 +36,7 @@ encouraged to add features or reimplement existing ones, and to send me
the results. You can find the GitHub repository at
\url{https://github.com/fmarotta/kaobook}.
\begin{kaobox}[frametitle=To Do]
\begin{kaobox}[title=To Do]
Implement the \Option{justified} and \Option{margin} options. To be
consistent with the \KOMAScript\xspace style, they should accept a
simple switch as a parameter, where the simple switch should be

2
examples/documentation/chapters/textnotes.tex

@ -55,7 +55,7 @@ everything more consistent, so that you have to remember less things!}
\marginnote[-12pt]{Text} or \marginnote[*-3]{Text}
\end{lstlisting}
\begin{kaobox}[frametitle=To Do]
\begin{kaobox}[title=To Do]
A small thing that needs to be done is to renew the \Command{sidenote}
command so that it takes only one optional argument, the offset. The
special mark argument can go somewhere else. In other words, we want the

62
kao.sty

@ -1198,42 +1198,34 @@
% SIMPLE BOXED ENVIRONMENT
%----------------------------------------------------------------------------------------
% kaobox (while tcolorbox may be more rich, I find it too complicated so I prefer mdframed)
\RequirePackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
% Define a new style for mdframed boxes
%\mdfsetup{skipabove=\topskip,skipbelow=0pt}
\mdfdefinestyle{kaoboxstyle}{
skipabove=1.5\topskip,
skipbelow=.5\topskip,
rightmargin=0pt,
leftmargin=0pt,
%innertopmargin=3pt,
%innerbottommargin=3pt,
innerrightmargin=7pt,
innerleftmargin=7pt,
topline=false,
bottomline=false,
rightline=false,
leftline=false,
%linewidth=1pt,
%roundcorner=0pt,
%font={},
%frametitlefont={},
frametitlerule=true,
linecolor=black,
%backgroundcolor=LightBlue,
fontcolor=black,
%frametitlebackgroundcolor=LightBlue,
}
% kaobox
\RequirePackage[most]{tcolorbox}
% Define a new environment using the style created above
\newmdenv[
style=kaoboxstyle,
backgroundcolor=RoyalBlue!25!White,
frametitlebackgroundcolor=RoyalBlue!25!White,
]{kaobox}
\newtcolorbox{kaobox}[1][]{
breakable,
before skip=1.5\topskip,
after skip=1.5\topskip,
left skip=0pt,
right skip=0pt,
left=4pt,
right=4pt,
top=2pt,
bottom=2pt,
lefttitle=4pt,
righttitle=4pt,
toptitle=2pt,
bottomtitle=2pt,
sharp corners,
boxrule=0pt,
titlerule=.4pt,
colback=RoyalBlue!25!White,
colbacktitle=RoyalBlue!25!White,
coltitle=black,
colframe=black,
fonttitle=\bfseries,
#1
}
%----------------------------------------------------------------------------------------
% ENVIRONMENT WITH A COUNTER
@ -1242,7 +1234,7 @@
% Define an environment titled 'Comment' and numbered incrementally
\newenvironment{kaocounter}{
\refstepcounter{kaocounter}
\begin{kaobox}[frametitle=Comment~\thekaocounter\autodot]
\begin{kaobox}[title=Comment~\thekaocounter\autodot]
}{
\end{kaobox}
}

135
kaotheorems.sty

@ -38,34 +38,23 @@
%----------------------------------------------------------------------------------------
\ifkaotheorems@framed% Define the style of the mdframed boxes for theorems
\RequirePackage{tikz} % Required by mdframed
\RequirePackage[framemethod=TikZ]{mdframed} % Required for colorful boxes
\RequirePackage[most]{tcolorbox}
% Box style
\mdfsetup{skipabove=\topskip,skipbelow=0pt}%-.5\topskip}
\mdfdefinestyle{mdfkao}{
skipabove=\topskip,
skipbelow=\topskip, % Does not work :(
rightmargin=0pt,
leftmargin=0pt,
innertopmargin=7pt,
innerbottommargin=3pt,
innerrightmargin=5pt,
innerleftmargin=5pt,
topline=false,
bottomline=false,
rightline=false,
leftline=false,
%linewidth=1pt,
%roundcorner=0pt,
%font={},
%frametitlefont={},
frametitlerule=true,
%linecolor=black,
%backgroundcolor=LightBlue,
%fontcolor=black,
%frametitlebackgroundcolor=LightBlue,
}
\tcbset{tcbkao/.style={
breakable,
before skip=\topskip,
after skip=\topskip,
left skip=0pt,
right skip=0pt,
top=5pt,
bottom=3pt,
left=2pt,
right=2pt,
sharp corners,
boxrule=0pt,
frame hidden,
}}
% Theorem styles
\declaretheoremstyle[
@ -150,48 +139,40 @@
refname={Theorem,Theorems},
Refname={Theorem,Theorems},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@theorembackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{theorem}
\tcolorboxenvironment{theorem}{
colback=\kaotheorems@theorembackground,tcbkao
}
\declaretheorem[
name=Proposition,
%refname={proposition,propositions},
refname={Proposition,Propositions},
Refname={Proposition,Propositions},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@propositionbackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{proposition}
\tcolorboxenvironment{proposition}{
colback=\kaotheorems@propositionbackground,tcbkao
}
\declaretheorem[
name=Lemma,
%refname={lemma,lemmas},
refname={Lemma,Lemmas},
Refname={Lemma,Lemmas},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@lemmabackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{lemma}
\tcolorboxenvironment{lemma}{
colback=\kaotheorems@lemmabackground,tcbkao
}
\declaretheorem[
name=Corollary,
%refname={corollary,corollaries},
refname={Corollary,Corollaries},
Refname={Corollary,Corollaries},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@corollarybackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{corollary}
\tcolorboxenvironment{corollary}{
colback=\kaotheorems@corollarybackground,tcbkao
}
% Theorems using the 'kaodefinition' style
\theoremstyle{kaodefinition}
@ -201,12 +182,10 @@
refname={Definition,Definitions},
Refname={Definition,Definitions},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@definitionbackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{definition}
\tcolorboxenvironment{definition}{
colback=\kaotheorems@definitionbackground,tcbkao
}
% Theorems using the 'kaoassumption' style
\theoremstyle{kaoassumption}
@ -216,12 +195,10 @@
refname={Assumption,Assumptions},
Refname={Assumption,Assumptions},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@assumptionbackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{assumption}
\tcolorboxenvironment{assumption}{
colback=\kaotheorems@assumptionbackground,tcbkao
}
% Theorems using the 'kaoremark' style
\theoremstyle{kaoremark}
@ -231,12 +208,10 @@
refname={Remark,Remarks},
Refname={Remark,Remarks},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@remarkbackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{remark}
\tcolorboxenvironment{remark}{
colback=\kaotheorems@remarkbackground,tcbkao
}
% Theorems using the 'kaoexample' style
\theoremstyle{kaoexample}
@ -246,27 +221,23 @@
refname={Example,Examples},
Refname={Example,Examples},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@examplebackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{example}
\tcolorboxenvironment{example}{
colback=\kaotheorems@examplebackground,tcbkao
}
% Theorems using the 'kaoexercise' style
\theoremstyle{kaoexercise}
\declaretheorem[
name=Exercise,
%refname={example,examples},
%refname={exercise,exercises},
refname={Exercise,Exercises},
Refname={Exercise,Exercises},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\kaotheorems@exercisebackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{exercise}
\tcolorboxenvironment{exercise}{
colback=\kaotheorems@exercisebackground,tcbkao
}
%\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
%\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
@ -350,25 +321,25 @@
\theoremstyle{kaoplain}
\declaretheorem[
name=Theorem,
refname={theorem,theorems},
refname={Theorem,Theorems},
Refname={Theorem,Theorems},
numberwithin=section,
]{theorem}
\declaretheorem[
name=Proposition,
refname={proposition,propositions},
refname={Proposition,Propositions},
Refname={Proposition,Propositions},
sibling=theorem,
]{proposition}
\declaretheorem[
name=Lemma,
refname={lemma,lemmas},
refname={Lemma,Lemmas},
Refname={Lemma,Lemmas},
sibling=theorem,
]{lemma}
\declaretheorem[
name=Corollary,
refname={corollary,corollaries},
refname={Corollary,Corollaries},
Refname={Corollary,Corollaries},
sibling=theorem,
]{corollary}
@ -377,7 +348,7 @@
\theoremstyle{kaodefinition}
\declaretheorem[
name=Definition,
refname={definition,definitions},
refname={Definition,Definitions},
Refname={Definition,Definitions},
numberwithin=section,
]{definition}
@ -395,7 +366,7 @@
\theoremstyle{kaoremark}
\declaretheorem[
name=Remark,
refname={remark,remarks},
refname={Remark,Remarks},
Refname={Remark,Remarks},
numberwithin=section,
]{remark}
@ -404,7 +375,7 @@
\theoremstyle{kaoexample}
\declaretheorem[
name=Example,
refname={example,examples},
refname={Example,Examples},
Refname={Example,Examples},
numberwithin=section,
]{example}
@ -413,15 +384,9 @@
\theoremstyle{kaoexercise}
\declaretheorem[
name=Exercise,
%refname={example,examples},
refname={Exercise,Exercises},
Refname={Exercise,Exercises},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=\@exercisebackground,
%frametitlebackgroundcolor=\@theorembackground,
},
]{exercise}
%\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}

Loading…
Cancel
Save