commit 7220de39990f8d8036fe8531d20e9959eaa90fc2
parent 587719b6e8ea33feaaa65d67b49b278c01f5b270
Author: Silas Brack <s174433@student.dtu.dk>
Date: Mon, 2 Jan 2023 00:45:45 +0100
Updated kaobook.
Diffstat:
| M | kao.sty | | | 698 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- |
| M | kaobiblio.sty | | | 413 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | kaobook.cls | | | 146 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- |
| A | kaohandt.cls | | | 96 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | kaorefs.sty | | | 156 | +++++++++++++++++++++++++++++++++++++++++++++++++------------------------------- |
| M | kaotheorems.sty | | | 703 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
6 files changed, 1222 insertions(+), 990 deletions(-)
diff --git a/kao.sty b/kao.sty
@@ -1,13 +1,23 @@
\ProvidesPackage{kao}
%----------------------------------------------------------------------------------------
+% DECLARE KAO
+%----------------------------------------------------------------------------------------
+
+\DefineFamily{kao}% Define the family name
+\DefineFamilyMember{kao}% Add a member to the family
+\DefineFamilyKey{kao}{secnumdepth}[1]{\setcounter{secnumdepth}{#1}\FamilyKeyStateProcessed}% Define a key and a default value
+\FamilyProcessOptions{kao}% Process the options
+
+%----------------------------------------------------------------------------------------
% USEFUL PACKAGES AND COMMANDS
%----------------------------------------------------------------------------------------
+\RequirePackage{kvoptions} % Handle package options
\RequirePackage{etoolbox} % Easy programming to modify TeX stuff
\RequirePackage{calc} % Make calculations
\RequirePackage[usenames,dvipsnames,table]{xcolor} % Colours
-\RequirePackage{iftex} % Check wether XeTeX is being used
+\RequirePackage{iftex} % Check whether XeTeX is being used
\RequirePackage{xifthen} % Easy conditionals
\RequirePackage{options} % Manage class options
\RequirePackage{xparse} % Parse arguments for macros
@@ -16,13 +26,48 @@
\RequirePackage{afterpage} % Run commands after specific pages
\RequirePackage{imakeidx} % For the index; must be loaded before the 'caption' and 'hyperref' packages
\RequirePackage{varioref} % For the cross-references; must be loaded before the 'hyperref' and 'cleveref' packages
+\AtEndPreamble{\RequirePackage{scrhack}} % Make some packages compatible with KOMAScript
% Define \Ifthispageodd (with a capital 'i') to make kaobook compatible with older KOMAScript versions
\@ifpackagelater{scrbase}{2019/12/22}{%
}{%
- \let\Ifthispageodd\ifthispageodd%
+ \let\Ifthispageodd\ifthispageodd%
+}
+
+%----------------------------------------------------------------------------------------
+% KAO-SPECIFIC OPTIONS
+%----------------------------------------------------------------------------------------
+
+% Set up the package options
+\SetupKeyvalOptions{
+ family = kao,
+ prefix = kao@
}
+% https://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation
+% Introduce a command to find out whether the compiler is XeTeX or LuaTeX
+\newif\ifxetexorluatex
+\ifxetex
+ \xetexorluatextrue
+\else
+ \ifluatex
+ \xetexorluatextrue
+ \else
+ \xetexorluatexfalse
+ \fi
+\fi
+
+\ifxetexorluatex
+ \newcommand{\kao@defaultfontmethod}{modern}
+\else
+ \newcommand{\kao@defaultfontmethod}{tex}
+\fi
+
+% Set default based on rendering engine
+\DeclareStringOption[\kao@defaultfontmethod]{fontmethod}
+
+\ProcessKeyvalOptions{kao}
+
%----------------------------------------------------------------------------------------
% TITLE AND AUTHOR MACROS
%----------------------------------------------------------------------------------------
@@ -47,7 +92,7 @@
\gdef\@author{#2} % Store the full author in @author
\ifthenelse{\isempty{#1}}{ % If there is no plain author
\renewcommand{\@plainauthor}{\@author}% Use full author
- }{ % If there is a plain author
+ }{ % If there is a plain author
\renewcommand{\@plainauthor}{#1}% Use provided plain-text author
}%
\hypersetup{pdfauthor={\@plainauthor}} % Set the PDF metadata author
@@ -72,6 +117,7 @@
\setlength{\hscale}{1mm}
\setlength{\vscale}{1mm}
+% Define hscale and vscale for all types of paper
\@ifclasswith{\@baseclass}{a0paper}{\setlength{\hscale}{4mm}\setlength{\vscale}{4mm}}{}
\@ifclasswith{\@baseclass}{a1paper}{\setlength{\hscale}{2.828mm}\setlength{\vscale}{2.828mm}}{}
\@ifclasswith{\@baseclass}{a2paper}{\setlength{\hscale}{2mm}\setlength{\vscale}{2mm}}{}
@@ -118,6 +164,7 @@
\@ifclasswith{\@baseclass}{illustratedpaper}{\setlength{\hscale}{0.905mm}\setlength{\vscale}{0.909mm}}{}
\@ifclasswith{\@baseclass}{f24paper}{\setlength{\hscale}{0.762mm}\setlength{\vscale}{0.808mm}}{}
\@ifclasswith{\@baseclass}{a4paperlandscape}{\setlength{\hscale}{1.414mm}\setlength{\vscale}{0.707mm}}{}
+\@ifclasswith{\@baseclass}{169paperlandscape}{\setlength{\hscale}{1.414mm}\setlength{\vscale}{0.562mm}}{}
% Set the default page layout
\RequirePackage[
@@ -132,6 +179,15 @@
\ifthenelse{\equal{fullwidth}{#1}}{\fullwidthlayout\widefloatsetup}{}%
}
+\newif\ifwidelayout%
+\def\IfWideLayout{%
+ \ifwidelayout%
+ \expandafter\@firstoftwo%
+ \else%
+ \expandafter\@secondoftwo%
+ \fi%
+}
+
% Layout #1: large margins
\newcommand{\marginlayout}{%
\newgeometry{
@@ -139,10 +195,11 @@
bottom=27.4\vscale,
inner=24.8\hscale,
textwidth=107\hscale,
- marginparsep=6.2\hscale,
+ marginparsep=6.2\hscale,
marginparwidth=47.7\hscale,
- }%
- \recalchead%
+ }%
+ \recalchead%
+ \widelayoutfalse%
}
% Layout #2: small, symmetric margins
@@ -155,7 +212,8 @@
marginparsep=0mm,
marginparwidth=0mm,
}%
- \recalchead%
+ \recalchead%
+ \widelayouttrue%
}
% Layout #3: no margins and no space above or below the body
@@ -168,7 +226,8 @@
marginparwidth=0mm,
marginparsep=0mm,
}%
- \recalchead%
+ \recalchead%
+ \widelayouttrue%
}
% Set the default page layout
@@ -186,25 +245,27 @@
\setlength{\headsep}{11\vscale}
% Define some LaTeX lengths used in the page headers
-\newlength{\headtextwidth}
-\newlength{\headmarginparsep}
-\newlength{\headmarginparwidth}
+\newlength{\headtextwidth} % This is the width of the text
+\newlength{\headmarginparsep} % This is the width of the whitespace between text and margin
+\newlength{\headmarginparwidth} % This is the width of the margin
\newlength{\headtotal} % This is the total width of the header
-\newcommand{\recalchead}{%
- \setlength{\headtextwidth}{\textwidth}%
+\newlength{\contentwidth} % An alias for \headtotal
+\newcommand{\recalchead}{% Command to recalculate the header-related length when needed
+ \setlength{\headtextwidth}{\textwidth}%
\setlength{\headmarginparsep}{\marginparsep}%
\setlength{\headmarginparwidth}{\marginparwidth}%
\setlength{\headtotal}{\headtextwidth+\headmarginparsep+\headmarginparwidth}%
+ \setlength{\contentwidth}{\headtotal}%
}
\AtBeginDocument{% Recalculate the header-related lengths
- \recalchead%
+ \recalchead%
}
-% Style with chapter number, chapter title, and page in the header (used throughout the document)
+% Header style with chapter number, chapter title, and page in the header (used throughout the document)
\renewpagestyle{scrheadings}{%
- {\smash{\hspace{-\headmarginparwidth}\hspace{-\headmarginparsep}\makebox[\headtotal][l]{%
- \makebox[7\hscale][r]{\thepage}%
+ {\smash{\hspace{-\headmarginparwidth}\hspace{-\headmarginparsep}\makebox[\headtotal][l]{%
+ \makebox[7\hscale][r]{\thepage}%
\makebox[3\hscale]{}\rule[-1mm]{0.5pt}{19\vscale-1mm}\makebox[3\hscale]{}%
\makebox[\headtextwidth][l]{\leftmark}}}}%
{\smash{\makebox[0pt][l]{\makebox[\headtotal][r]{%
@@ -216,12 +277,12 @@
\makebox[3\hscale]{}\rule[-1mm]{0.5pt}{19\vscale-1mm}\makebox[3\hscale]{}%
\makebox[7\hscale][l]{\thepage}}}}}%
}{%
- {}%
+ {}%
{}%
{}%
}
-% Style with neither header nor footer (used for special pages)
+% Header style with neither header nor footer (used for special pages)
\renewpagestyle{plain.scrheadings}{%
{}%
{}%
@@ -232,26 +293,26 @@
{}%
}
-% Style with an empty header and the page number in the footer
+% Header style with an empty header and the page number in the footer
\newpagestyle{pagenum.scrheadings}{%
- {}%
- {}%
- {}%
+ {}%
+ {}%
+ {}%
}{%
- {\makebox[\textwidth][r]{\thepage}}%
- {\makebox[\textwidth][l]{\thepage}}%
- {\makebox[\textwidth][l]{\thepage}}%
+ {\makebox[\textwidth][r]{\thepage}}%
+ {\makebox[\textwidth][l]{\thepage}}%
+ {\makebox[\textwidth][l]{\thepage}}%
}
-% Style with an empty header and the page number in the footer
+% Header style with an empty header and the page number in the footer
\newpagestyle{centeredpagenum.scrheadings}{%
- {}%
- {}%
- {}%
+ {}%
+ {}%
+ {}%
}{%
- {\hspace{-\headmarginparwidth}\hspace{-\headmarginparsep}\makebox[\headtotal][l]{\hfill\thepage\hfill}}
- {\makebox[0pt][l]{\makebox[\headtotal][r]{\hfill\thepage\hfill}}}%
- {\makebox[0pt][l]{\makebox[\headtotal][r]{\hfill\thepage\hfill}}}%
+ {\hspace{-\headmarginparwidth}\hspace{-\headmarginparsep}\makebox[\headtotal][l]{\hfill\thepage\hfill}}
+ {\makebox[0pt][l]{\makebox[\headtotal][r]{\hfill\thepage\hfill}}}%
+ {\makebox[0pt][l]{\makebox[\headtotal][r]{\hfill\thepage\hfill}}}%
}
% Command to print a blank page
@@ -308,41 +369,41 @@
% Environment for a wide paragraph
\NewDocumentEnvironment{widepar}{}{%
- \if@twoside%
+ \if@twoside%
\Ifthispageodd{%
- \begin{addmargin}[0cm]{-\marginparwidth-\marginparsep}%
+ \begin{addmargin}[0cm]{-\marginparwidth-\marginparsep}%
}{%
- \begin{addmargin}[-\marginparwidth-\marginparsep]{0cm}%
+ \begin{addmargin}[-\marginparwidth-\marginparsep]{0cm}%
}%
- \else%
+ \else%
\begin{addmargin}[0cm]{-\marginparwidth-\marginparsep}%
- \fi%
+ \fi%
}{%
\end{addmargin}%
}
% Environment for a full width paragraph
\NewDocumentEnvironment{fullwidthpar}{}{%
- \if@twoside%
- \Ifthispageodd{%
- \begin{addmargin}[-1in-\hoffset-\oddsidemargin]{-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth}%
- }{%
- \begin{addmargin}[-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth]{-\paperwidth+1in+\hoffset+\oddsidemargin+\marginparsep+\marginparwidth+\textwidth}%
- }%
- \else%
- \begin{addmargin}[-1in-\hoffset-\oddsidemargin]{-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth}%
- \fi%
+ \if@twoside%
+ \Ifthispageodd{%
+ \begin{addmargin}[-1in-\hoffset-\oddsidemargin]{-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth}%
+ }{%
+ \begin{addmargin}[-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth]{-\paperwidth+1in+\hoffset+\oddsidemargin+\marginparsep+\marginparwidth+\textwidth}%
+ }%
+ \else%
+ \begin{addmargin}[-1in-\hoffset-\oddsidemargin]{-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth}%
+ \fi%
}{%
- \end{addmargin}%
+ \end{addmargin}%
}
% Environment for a wide equation
\NewDocumentEnvironment{wideequation}{}{%
- \begin{widepar}%
+ \begin{widepar}%
\begin{equation}%
}{%
\end{equation}%
- \end{widepar}%
+ \end{widepar}%
}
%----------------------------------------------------------------------------------------
@@ -353,7 +414,7 @@
\extrafloats{100} % Require more floats
\RequirePackage{marginnote} % Provides options for margin notes
-\RequirePackage{marginfix} % Make marginpars float freely
+% \RequirePackage{marginfix} % Make marginpars float freely; it should not be loaded as it prevents the marginnotes to stay aligned with the main text
\RequirePackage{sidenotes} % Use sidenotes
\RequirePackage{chngcntr} % Reset counters at sections
@@ -383,8 +444,8 @@
\renewcommand*{\raggedrightmarginnote}{} % Suppress right margin
\renewcommand*{\marginfont}{\@margin@par} % Format marginnotes according to \@marginpar (see above)
\renewcommand{\marginnotevadjust}{0.8\vscale} % Bring all marginnotes downwards a bit
-\marginposadjustment=0.1mm % Bring downwards also the marginpars
-\marginheightadjustment=.5cm % Bring downwards also the marginpars
+%\marginposadjustment=1\vscale % Bring downwards also the marginpars
+%\marginheightadjustment=10cm % Adjust the height of the margins for each page
%\RequirePackage[marginnote=true]{snotez} % Provides options for sidenotes
% Copied from snotez's \sidenote
@@ -396,17 +457,17 @@
\fi%
}
-% Command to detect whether we are inside an mdframed environment
-\newif\ifinfloat
-\AtBeginEnvironment{mdframed}{\infloattrue}
+% Command to detect whether we are inside a tcolorbox environment
+\newif\ifinfloat % First, set this flag whenever we are in a tcolorbox environment...
+\AtBeginEnvironment{tcolorbox}{\infloattrue\renewcommand{\marginnotevadjust}{-1.4\vscale}}
\AtBeginEnvironment{minipage}{\infloattrue}
-\def\IfInFloatingEnvir{%
- \ifinfloat%
- \expandafter\@firstoftwo%
- \else%
- \expandafter\@secondoftwo%
- \fi%
+\def\IfInFloatingEnvir{% ...Then, detect the flag
+ \ifinfloat%
+ \expandafter\@firstoftwo%
+ \else%
+ \expandafter\@secondoftwo%
+ \fi%
}
@@ -420,14 +481,14 @@
\IfInFloatingEnvir{%
\oldmarginnote{#2}%
}{%
- \marginpar{\@margin@par#2}%
- }%
+ \marginpar{\@margin@par#2}%
+ }%
}{%
\oldmarginnote{#2}[\kao@if@nblskip{#1}{\@cdr#1\@nil\baselineskip}{#1}]%
}%
}
-% Initially set the counter to zero instead of 1, and update it before printing the sidenote.
+% Initially set the sidenote counter to zero instead of 1, and update it before printing the sidenote.
\setcounter{sidenote}{0}%
\RenewDocumentCommand\sidenote{ o o +m }{%
\IfNoValueOrEmptyTF{#1}{%
@@ -439,15 +500,8 @@
\@sidenotes@multimarker%
}
-% % Formatting sidenotes
-% \setsidenotes{
-% text-mark-format=\textsuperscript{\normalfont#1}, % Use a superscript for the marker in the text
-% note-mark-format=#1:, % Use a normal font for the marker in the margin; use a colon after the sidenote number
-% note-mark-sep=\enskip, % Set the space after the marker
-% }
-
-% Formatting sidenotes
-\RenewDocumentCommand\@sidenotes@thesidenotemark{ m }{%
+% Formatting sidenote markers
+\RenewDocumentCommand\@sidenotes@thesidenotemark{ m }{% Format the marker
\leavevmode%
\ifhmode%
\edef\@x@sf{\the\spacefactor}%
@@ -460,12 +514,13 @@
\relax%
}%
+% Formatting the sidenote text
\RenewDocumentCommand\sidenotetext{ o o +m }{% number, offset, text
\IfNoValueOrEmptyTF{#1}{%
- \marginnote[#2]{\thesidenote:\enskip#3}%
- }{%
- \marginnote[#2]{#1:\enskip#3}%
- }%
+ \marginnote[#2]{\thesidenote:\enskip#3}%
+ }{%
+ \marginnote[#2]{#1:\enskip#3}%
+ }%
}
%----------------------------------------------------------------------------------------
@@ -489,7 +544,6 @@
% \newcommand{\pp@g@sidenote}{}
\RequirePackage{floatrow} % Set up captions of floats
%\RequirePackage{dblfloatfix} % Better positioning of wide figures and tables
-\AtEndPreamble{\RequirePackage{scrhack}} % Make packages compatible with KOMA Script (must be loaded last: https://tex.stackexchange.com/questions/156240/latex-packages-minted-and-scrhack)
% Improve the figure placing (see https://www.overleaf.com/learn/latex/Tips)
\def\topfraction{.9}%
@@ -510,6 +564,11 @@
\setlength\columnseprule{.4pt} % Set the width of vertical rules in tables
+% The marginfix package prevents the margin notes to stay aligned with the main text, so it cannot be used. However, we define the \marginskip command, which is the only command we need from that package.
+\newcommand\marginskip[1]{%
+ \marginpar{\@margin@par\vspace{#1 - \baselineskip}}% We subtract the \baselineskip that we have in margin pars.
+}
+
\newlength{\kaomarginskipabove} % Specify the space above a marginfigure, margintable or marginlisting
\newlength{\kaomarginskipbelow} % Specify the space below a marginfigure, margintable or marginlisting
\setlength{\kaomarginskipabove}{3mm plus 2pt minus 2pt}
@@ -518,45 +577,45 @@
% Environment to hold a margin figure (from the sidenotes package)
% We redefine it here because we want to use our own caption formatting.
\RenewDocumentEnvironment{marginfigure}{o}{%
- \FloatBarrier%
- \marginskip{\kaomarginskipabove}%
- \begin{lrbox}{\@sidenotes@marginfigurebox}%
+ \FloatBarrier%
+ \marginskip{\kaomarginskipabove}%
+ \begin{lrbox}{\@sidenotes@marginfigurebox}%
\begin{minipage}{\marginparwidth}%
- \captionsetup{type=figure}%
+ \captionsetup{type=figure}%
}{%
- \end{minipage}%
- \end{lrbox}%
- \marginnote[#1]{\usebox{\@sidenotes@marginfigurebox}}%
- \marginskip{\kaomarginskipbelow}%
+ \end{minipage}%
+ \end{lrbox}%
+ \marginnote[#1]{\usebox{\@sidenotes@marginfigurebox}}%
+ \marginskip{\kaomarginskipbelow}%
}
% Environment to hold a margin table (from the sidenotes package)
\RenewDocumentEnvironment{margintable}{o}{%
- \FloatBarrier%
- \marginskip{\kaomarginskipabove}%
- \begin{lrbox}{\@sidenotes@margintablebox}%
+ \FloatBarrier%
+ \marginskip{\kaomarginskipabove}%
+ \begin{lrbox}{\@sidenotes@margintablebox}%
\begin{minipage}{\marginparwidth}%
- \captionsetup{type=table}%
+ \captionsetup{type=table}%
}{%
- \end{minipage}%
- \end{lrbox}%
- \marginnote[#1]{\usebox{\@sidenotes@margintablebox}}%
- \marginskip{\kaomarginskipbelow}%
+ \end{minipage}%
+ \end{lrbox}%
+ \marginnote[#1]{\usebox{\@sidenotes@margintablebox}}%
+ \marginskip{\kaomarginskipbelow}%
}
% Environment to hold a margin listing
\newsavebox{\@sidenotes@marginlistingbox}%
\NewDocumentEnvironment{marginlisting}{o}{% The optional parameter is the vertical offset
- \FloatBarrier%
- \marginskip{\kaomarginskipabove}%
- \begin{lrbox}{\@sidenotes@marginlistingbox}%
+ \FloatBarrier%
+ \marginskip{\kaomarginskipabove}%
+ \begin{lrbox}{\@sidenotes@marginlistingbox}%
\begin{minipage}{\marginparwidth}%
- \captionsetup{type=lstlisting}%
+ \captionsetup{type=lstlisting}%
}{%
\end{minipage}%
- \end{lrbox}%
- \marginnote[#1]{\usebox{\@sidenotes@marginlistingbox}}%
- \marginskip{\kaomarginskipbelow}%
+ \end{lrbox}%
+ \marginnote[#1]{\usebox{\@sidenotes@marginlistingbox}}%
+ \marginskip{\kaomarginskipbelow}%
}
% Change the position of the captions
@@ -608,7 +667,7 @@
\RawFloats%
\centering%
}%
- \togglefalse{kaocaption}%
+ \togglefalse{kaocaption}%
}
% Change the formatting of the captions
@@ -676,10 +735,10 @@
facing=yes,%
capposition=above%
}%
- \floatsetup[longtable]{% Captions for longtables
- margins=raggedright,% Overwrite the hangright setting from the `table' environment
- %LTcapwidth=table,% Set the width of the caption equal to the table's
- }%
+ \floatsetup[longtable]{% Captions for longtables
+ margins=raggedright,% Overwrite the hangright setting from the `table' environment
+ %LTcapwidth=table,% Set the width of the caption equal to the table's
+ }%
\floatsetup[lstlisting]{% Captions for lstlistings
margins=hangoutside,% Put captions in the margin
facing=yes,%
@@ -740,10 +799,10 @@
facing=no,%
capposition=above%
}%
- \floatsetup[longtable]{% Captions for longtables
- margins=raggedright,% Overwrite the hangright setting from the `table' environment
- %LTcapwidth=table,% Set the width of the caption equal to the table's
- }%
+ \floatsetup[longtable]{% Captions for longtables
+ margins=raggedright,% Overwrite the hangright setting from the `table' environment
+ %LTcapwidth=table,% Set the width of the caption equal to the table's
+ }%
\floatsetup[lstlisting]{% Captions for lstlisting
margins=hangright,% Put captions in the margin
facing=yes,%
@@ -814,7 +873,7 @@
singlelinecheck=false,%
indention=0pt,%
parindent=0pt,%
- aboveskip=6pt,%
+ aboveskip=6pt,%
belowskip=6pt,%
belowskip=-0.1cm%
}
@@ -824,7 +883,7 @@
% TOC, LOF & LOT
%----------------------------------------------------------------------------------------
-\RequirePackage{tocbasic}
+\RequirePackage{tocbasic} % Required to customise the TOC
% Show an entry for the TOC in the TOC
\setuptoc{toc}{totoc}
@@ -832,15 +891,21 @@
% Choose the levels in table of contents
\setcounter{tocdepth}{\subsectiontocdepth}
+% Customise the list of listings
+\renewcommand{\lstlistlistingname}{List of Listings}% Change the title
+\newcommand{\lstlistingtocdepth}{\sectiontocdepth}% Set the depth
+\newcommand{\listoflistings}{\lstlistoflistings}% Provide the alias \listoflistings
+\newcommand{\listoflstlistings}{\lstlistoflistings}% Provide the alias \listoflstlistings
+
% Define the style for toc entries
\@ifpackagelater{scrbase}{2019/10/11}{%
- \DeclareTOCStyleEntries[indent=0em,numwidth=2em,dynnumwidth=yes,pagenumberwidth=2.1em]{tocline}{figure,table}%
- \DeclareTOCStyleEntries[dynnumwidth=yes]{tocline}{subsubsection,subsection,section,chapter,part}%
- \DeclareTOCStyleEntries[pagenumberwidth=2.5em]{tocline}{chapter,part}%
- \DeclareTOCStyleEntries[pagenumberwidth=2.1em]{tocline}{subsubsection,subsection,section}%
+ \DeclareTOCStyleEntries[indent=0em,numwidth=2em,dynnumwidth=yes,pagenumberwidth=2.1em]{tocline}{figure,table,lstlisting}%
+ \DeclareTOCStyleEntries[dynnumwidth=yes]{tocline}{subsubsection,subsection,section,chapter,part}%
+ \DeclareTOCStyleEntries[pagenumberwidth=2.5em]{tocline}{chapter,part}%
+ \DeclareTOCStyleEntries[pagenumberwidth=2.1em]{tocline}{subsubsection,subsection,section}%
}{%
- \DeclareTOCStyleEntries[indent=0em,numwidth=2em,dynnumwidth=yes]{tocline}{figure,table}%
- \DeclareTOCStyleEntries[dynnumwidth=yes]{tocline}{subsubsection,subsection,section,chapter,part}%
+ \DeclareTOCStyleEntries[indent=0em,numwidth=2em,dynnumwidth=yes]{tocline}{figure,table,lstlisting}%
+ \DeclareTOCStyleEntries[dynnumwidth=yes]{tocline}{subsubsection,subsection,section,chapter,part}%
}
% Define the names for the headings
@@ -856,7 +921,7 @@
\RequirePackage{etoc} % Required to insert local tables of contents
\newcounter{margintocdepth} % Set the depth of the margintoc
-\setcounter{margintocdepth}{\subsectiontocdepth}
+\setcounter{margintocdepth}{\subsectiontocdepth} % By default to subsections
\newlength{\mtocshift} % Length of the vertical offset used for margin tocs
\setlength{\mtocshift}{1\vscale}% \mtocshift is overridden by \setchapterstyle
@@ -866,16 +931,16 @@
% We want to create an additional entries in the toc which is to be used for the margintoc
% We define these as mtocsection and mtocsubsection for section and subsection`
\newcommand{\mtocsection}[1]{
- \addcontentsline{toc}{mtocsection}{%
- \ifnum\value{secnumdepth}>0 \protect\numberline{\thesection}%
- \else \protect\nonumberline%
- \fi #1}%
+ \etoctoccontentsline{mtocsection}{%
+ \ifnum\value{secnumdepth}>0 \protect\numberline{\thesection}%
+ \else \protect\nonumberline%
+ \fi #1}%
}
\newcommand{\mtocsubsection}[1]{
- \addcontentsline{toc}{mtocsubsection}{%
- \ifnum\value{secnumdepth}>1 \protect\numberline{\thesubsection}%
- \else \protect\nonumberline%
- \fi #1}%
+ \etoctoccontentsline{mtocsubsection}{%
+ \ifnum\value{secnumdepth}>1 \protect\numberline{\thesubsection}%
+ \else \protect\nonumberline%
+ \fi #1}%
}
% Next, we redefine \section and \subsection so that they accept an additional parameter
@@ -883,47 +948,56 @@
% Adapted from Frank Mittelbach's answer at Stackexchange
% https://tex.stackexchange.com/a/109560/226693
-\let\oldsection\section % save the old command
-\let\oldsubsection\subsection % save the old command
+\let\oldsection\section % save the old command
+\let\oldsubsection\subsection % save the old command
\RenewDocumentCommand\section{s o m o}{%
- \IfBooleanTF{#1}{%
- \oldsection*{#3}
- \IfNoValueF{#2}{% if TOC arg is given create a TOC entry
- \addxcontentsline{toc}{section}[\thesection]{#2}%
- }%
- }{% no star given
- \IfNoValueTF{#2}{%
- \oldsection{#3}%
- }{% no TOC arg
- \oldsection[#2]{#3}%
- }%
- \IfNoValueTF{#4}{% optional label given, if not we do nothing
- \mtocsection{#3}%
- }{%
- \mtocsection{#4}%
- }%
- }%
+ \IfBooleanTF{#1}{%
+ \oldsection*{#3}
+ \IfNoValueF{#2}{% if TOC arg is given create a TOC entry
+ \addxcontentsline{toc}{section}[\thesection]{#2}%
+ }%
+ }{% no star given
+ \IfNoValueTF{#2}{%
+ \oldsection{#3}%
+ }{% no TOC arg
+ \oldsection[#2]{#3}%
+ }%
+ \IfNoValueTF{#4}{% optional label given, if not we do nothing
+ % \mtocsection{#3}%
+ \IfNoValueTF{#2}{%
+ \mtocsection{#3}% when no optional toc title, use main title
+ }{% no TOC arg
+ \mtocsection{#2}% when toc optional title is given, use it
+ }%
+ }{%
+ \mtocsection{#4}%
+ }%
+ }%
}
-\RenewDocumentCommand\subsection{s o m o}{
- \IfBooleanTF{#1}{%
- \oldsubsection*{#3}%
- \IfNoValueF{#2}{% if TOC arg is given create a TOC entry
- \addxcontentsline{toc}{subsection}[\thesubsection]{#2}%
- }%
- }{% no star given
- \IfNoValueTF{#2}{%
- \oldsubsection{#3}%
- }{% no TOC arg
- \oldsubsection[#2]{#3}%
- }%
- \IfNoValueTF{#4}{% optional label given, if not we do nothing
- \mtocsubsection{#3}%
- }{%
- \mtocsubsection{#4}%
- }%
- }%
+\RenewDocumentCommand\subsection{s o m o}{%
+ \IfBooleanTF{#1}{%
+ \oldsubsection*{#3}%
+ \IfNoValueF{#2}{% if TOC arg is given create a TOC entry
+ \addxcontentsline{toc}{subsection}[\thesubsection]{#2}%
+ }%
+ }{% no star given
+ \IfNoValueTF{#2}{%
+ \oldsubsection{#3}%
+ }{% no TOC arg
+ \oldsubsection[#2]{#3}%
+ }%
+ \IfNoValueTF{#4}{% optional label given, if not we do nothing
+ \IfNoValueTF{#2}{%
+ \mtocsubsection{#3}% when no optional toc title, use main title
+ }{% no TOC arg
+ \mtocsubsection{#2}% when toc optional title is given, use it
+ }%
+ }{%
+ \mtocsubsection{#4}%
+ }%
+ }%
}
\etocsetlevel{mtocsection}{6}% dummy sectioning level
@@ -931,123 +1005,126 @@
% Command to print a table of contents in the margin
\NewDocumentCommand{\margintoc}{O{\mtocshift}}{ % The first parameter is the vertical offset; by default it is \mtocshift
- \begingroup%
- % Move regular section and subsection to level 6 so that they won't be included and instead set let the mtoc versions take their place.
- % Adapted from https://tex.stackexchange.com/a/133559/226693
- \etocsetlevel{section}{6}
- \etocsetlevel{subsection}{6}
- \etocsetlevel{mtocsection}{1}
- \etocsetlevel{mtocsubsection}{2}
-
- % Define default widths
- \def\margintocnumwidth{-.8mm}%
- \def\margintocpagenumwidth{8pt}%
- \setlength{\RaggedRightParfillskip}{0pt}
-
- % Dry run to get the needed widths
- \etocsetstyle{mtocsection}%
- {}%
- {\setbox0\hbox{\usekomafont{section}\small\etocthenumber\kern.8mm}%%
- \setbox1\hbox{\usekomafont{section}\small\etocthepage}}%
- {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%%
- \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
- {}%
- \etocsetstyle{mtocsubsection}%
- {}%
- {\setbox0\hbox{\usekomafont{section}\small\etocthenumber\kern.8mm}%
- \setbox1\hbox{\usekomafont{section}\small\etocthepage}}%
- {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%
- \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
- {}%
- \etocsetstyle{subsubsection}%
- {}%
- {}%
- {}%
- {}%
- \etocsetstyle{paragraph}%
- {}%
- {}%
- {}%
- {}%
- \etocsettocstyle{}{%
- \global\let\margintocnumwidth\margintocnumwidth%
- \global\let\margintocpagenumwidth\margintocpagenumwidth%
- }%
- \localtableofcontents%
-
- % Set the style for section entries
- \etocsetstyle{mtocsection}%
- {\parindent 0pt \parskip 2.5pt \parfillskip 0pt \RaggedRight}%
- {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth} %
- {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\etocnumber}}\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\etocpage}}\par}%
- {}%
+ \begingroup%
+ % Move regular section and subsection to level 6 so that they won't be included and instead set let the mtoc versions take their place.
+ % Adapted from https://tex.stackexchange.com/a/133559/226693
+ \etocsetlevel{section}{6}
+ \etocsetlevel{subsection}{6}
+ \etocsetlevel{mtocsection}{1}
+ \etocsetlevel{mtocsubsection}{2}
+
+ % Define default widths
+ \def\margintocnumwidth{-.8mm}%
+ \def\margintocpagenumwidth{8pt}%
+ \setlength{\RaggedRightParfillskip}{0pt}
+
+ % Dry run to get the needed widths
+ \etocsetstyle{mtocsection}%
+ {}%
+ {\setbox0\hbox{{\usekomafont{section}\small\etocthenumber\kern.8mm}}%%
+ \setbox1\hbox{{\usekomafont{section}\small\etocthepage}}}%
+ {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%%
+ \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
+ {}%
+ \etocsetstyle{mtocsubsection}%
+ {}%
+ {\setbox0\hbox{{\usekomafont{section}\small\mdseries\etocthenumber\kern.8mm}}%
+ \setbox1\hbox{{\usekomafont{section}\small\mdseries\etocthepage}}}%
+ {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%
+ \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
+ {}%
+ \etocsetstyle{subsubsection}%
+ {}%
+ {}%
+ {}%
+ {}%
+ \etocsetstyle{paragraph}%
+ {}%
+ {}%
+ {}%
+ {}%
+ \etocsettocstyle{}{%
+ \global\let\margintocnumwidth\margintocnumwidth%
+ \global\let\margintocpagenumwidth\margintocpagenumwidth%
+ }%
+ \localtableofcontents%
+
+ % Set the style for section entries
+ \etocsetstyle{mtocsection}%
+ {\parindent 0pt \parskip 2.5pt \parfillskip 0pt \RaggedRight}%
+ {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
+ {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\etocnumber}}\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\etocpage}}\par}%
+ {}%
% Set the style for subsection entries
- \etocsetstyle{mtocsubsection}%
- {\parindent 0pt \parskip 0pt \parfillskip 0pt \RaggedRight}%
- {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
- {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\etocnumber}}\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\etocpage}}\par}%
- {\parskip 2.5pt}%
+ \etocsetstyle{mtocsubsection}%
+ {\parindent 0pt \parskip 0pt \parfillskip 0pt \RaggedRight}%
+ {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
+ {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\mdseries\etocnumber}}{\mdseries\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\mdseries\etocpage}}}\par}%
+ {\parskip 2.5pt}%
% Set the global style of the toc
- \etocsettocstyle{\usekomafont{section}\small}{}%
+ \etocsettocstyle{\usekomafont{section}\small}{}%
\etocsetnexttocdepth{\themargintocdepth}%
- % Print the table of contents in the margin
- \marginnote[#1]{\localtableofcontents}%
- \FloatBarrier%
- \endgroup%
+ % Print the table of contents in the margin
+ \marginnote[#1]{\localtableofcontents}%
+ \FloatBarrier%
+ \endgroup%
}
%----------------------------------------------------------------------------------------
% ENCODING AND FONTS
%----------------------------------------------------------------------------------------
-% https://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation
-% Introduce a command to find out whether the compiler is XeTeX or LuaTeX
-\newif\ifxetexorluatex
-\ifxetex
- \xetexorluatextrue
-\else
- \ifluatex
- \xetexorluatextrue
- \else
- \xetexorluatexfalse
- \fi
-\fi
-
-\ifxetexorluatex
+\newcommand{\kao@fontmethodModern}{%
\RequirePackage{amssymb} % Must be loaded before unicode-math
\RequirePackage[force]{filehook} % Fixes an error
\RequirePackage{unicode-math} % Math fonts in xetexorluatex
- \setromanfont[
+ \setromanfont[ % Libertinus Serif font
Scale=1.04
]{Libertinus Serif}
- \setsansfont[
+ \setsansfont[ % Libertinus Sans font
Scale=1
]{Libertinus Sans}
- \setmonofont[
+ \setmonofont[ % Libertinus Mono font
Scale=.89
]{Liberation Mono}
- \setmathfont{Libertinus Math}
- \ifluatex
- \else
- \RequirePackage{morewrites} % Fix some errors related to floats
- \fi
-\else
+ \setmathfont{Libertinus Math} % Libertinus Math font
+ \ifluatex
+ \else
+ \RequirePackage{morewrites} % Fix some errors related to floats (not necessary with LuaLaTeX
+ \fi%
+}
+\newcommand{\kao@fontmethodTex}{%
\RequirePackage[utf8]{inputenc} % utf8 encoding in the input (.tex) file
\RequirePackage[T1]{fontenc} % utf8 encoding in the output (.pdf) file
\RequirePackage{amssymb} % Math symbols, including \blacktriangleright, used for bullets
\RequirePackage[scaled=.97,helvratio=.93,p,theoremfont]{newpxtext} % Serif palatino font
- % \RequirePackage[vvarbb,smallerops,bigdelims]{newpxmath} % Math palatino font
+ \RequirePackage[vvarbb,smallerops,bigdelims]{newpxmath} % Math palatino font
\RequirePackage[scaled=.85]{beramono} % Monospace font
- % \RequirePackage[scr=rsfso,cal=boondoxo]{mathalfa} % Mathcal from STIX, unslanted a bit
- \RequirePackage{morewrites} % Fix some errors related to floats
-\fi
+ \RequirePackage[scr=rsfso,cal=boondoxo]{mathalfa} % Mathcal from STIX, unslanted a bit
+ \RequirePackage{morewrites} % Fix some errors related to floats
+}
+
+\ifthenelse%
+ {\equal{modern}{\kao@fontmethod}}{\kao@fontmethodModern}%
+{\ifthenelse%
+ {\equal{tex}{\kao@fontmethod}}{\kao@fontmethodTex}%
+{
+ \PackageError{kao}{%
+ Invalid fontmethod choice \kao@fontmethod.%
+ }{%
+ Should be one of "modern" or "tex"%
+ }
+}}
% When using the Palatino (newpxtext) font, it is better to use a
% slightly larger stretch.
%\setstretch{1.10}
\linespread{1.07} % Give Palatino more leading (space between lines)
+% Fix for the subequation environment (https://tex.stackexchange.com/questions/27053/too-much-space-between-full-paragraph-and-subequations-env)
+\preto\subequations{\ifhmode\unskip\fi}
+
%----------------------------------------------------------------------------------------
% HYPERREFERENCES
%----------------------------------------------------------------------------------------
@@ -1057,6 +1134,7 @@
\PassOptionsToPackage{hyphens}{url} % Break long URLs and use hyphens to separate the pieces
+% Color settings should be done in the next \hypersetup
\hypersetup{ % Set up hyperref options
unicode, % Use unicode for links
pdfborder={0 0 0}, % Suppress border around pdf
@@ -1069,11 +1147,6 @@
linktoc=all, % Toc entries and numbers links to pages
breaklinks=true,
colorlinks=true,
- %allcolors=DarkGreen,
- citecolor = DarkOrange,
- linkcolor = Blue,
- %pagecolor = Blue,
- urlcolor = OliveGreen,
}
% Define a new color for the footnote marks
@@ -1096,10 +1169,11 @@
\relax
}
+% Redefine the \thanks command to allow users to use \label within \thanks without getting warnings
\let\oldthanks\thanks
\renewcommand\thanks[1]{%
- \label{bhfn:0}%
- \oldthanks{#1}%
+ \label{bhfn:0}%
+ \oldthanks{#1}%
}
% Adjust the colour of the footnotes marks using the colour defined above
@@ -1114,9 +1188,6 @@
\BHFN@OldMakefntext{#1}%
}
-\providecommand*{\toclevel@mtocsection}{0}
-\providecommand*{\toclevel@mtocsubsection}{0}
-
%----------------------------------------------------------------------------------------
% COLOURS
%----------------------------------------------------------------------------------------
@@ -1132,13 +1203,16 @@
%\addtokomafont{captionlabel}{\color{Blue}}
%\addtokomafont{pagenumber}{\color{Maroon}}
+% Choose the default colors
\hypersetup{
+ %allcolors=DarkGreen,
%anchorcolor=Red,
%citecolor=DarkOrange!70!black,
citecolor=OliveGreen,
filecolor=OliveGreen,
- %linkcolor=Blue,
+ %linkcolor=Blue,
linkcolor=Black,
+ %pagecolor = Blue,
%menucolor=Red,
%runcolor=Red,
urlcolor=OliveGreen,
@@ -1148,9 +1222,9 @@
% ITEMS
%----------------------------------------------------------------------------------------
-\renewcommand{\labelitemi}{\small$\blacktriangleright$}
-\renewcommand{\labelitemii}{\textbullet}
-\RequirePackage{enumitem}
+\renewcommand{\labelitemi}{\small$\blacktriangleright$} % Use a black triangle for the first level of \item's
+\renewcommand{\labelitemii}{\textbullet} % Use a bullet for the second level of \item's
+\RequirePackage[inline]{enumitem} % Used to customise lists (in particular, we don't want to put whitespace between items)
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\setlist[description]{noitemsep}
@@ -1159,52 +1233,48 @@
% 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}
-
-%\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
+\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
}
-\newmdenv[
- style=kaoboxstyle,
- backgroundcolor=RoyalBlue!25!White,
- frametitlebackgroundcolor=RoyalBlue!25!White,
-]{kaobox}
-
%----------------------------------------------------------------------------------------
% ENVIRONMENT WITH A COUNTER
%----------------------------------------------------------------------------------------
+% 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}
}
+% Define the commands to manage the counter for the 'kaocounter' environment
\newcounter{kaocounter}
\counterwithin{kaocounter}{section}
\newcommand*{\kaocounterformat}{% Format for the caption
@@ -1216,23 +1286,25 @@
% FLOATING ENVIRONMENT WITH TOC ENTRIES
%----------------------------------------------------------------------------------------
+% Define a floating environment
\newenvironment{kaofloating}{%
\@float{kaofloating}%
}{%
\end@float%
}
-\newcommand*{\fps@floatingbox}{tbph}
-\newcommand*{\ftype@floatingbox}{5}
-\newcommand*{\floatingboxformat}{%
+% Configure the 'kaofloating' environment
+\newcommand*{\fps@floatingbox}{tbph}% Allowed positions for the environment (top, bottom, own page, here)
+\newcommand*{\ftype@floatingbox}{5}% Set the type of float (floats of the same type cannot change their order; figures and tables are type 1 and 2 respectively)
+\newcommand*{\floatingboxformat}{% Set a title of the environment
Insight~\thefloatingbox\csname autodot\endcsname}
-\newcommand*{\fnum@floatingbox}{\floatingboxformat}
-\newcommand*{\ext@floatingbox}{loi}
+\newcommand*{\fnum@floatingbox}{\floatingboxformat}% Use the environment title
+\newcommand*{\ext@floatingbox}{loi}% Choose the extension of the auxiliary file for this environment
-\addtotoclist[float]{loi}
-\newcommand*{\listofloiname}{List of Insights}
-\newcommand*{\l@floatingbox}{\l@figure}
-\newcommand*{\listofinsights}{\listoftoc{loi}}
+\addtotoclist[float]{loi}% Keep track of 'kaofloating' environments for a "List of Insights"
+\newcommand*{\listofloiname}{List of Insights}% Choose the title for the "List of Insights"
+\newcommand*{\l@floatingbox}{\l@figure}% Format the LOI
+\newcommand*{\listofinsights}{\listoftoc{loi}}% User-friendly command to print the LOI
%----------------------------------------------------------------------------------------
% ADDITIONAL PACKAGES
@@ -1245,13 +1317,15 @@
% Listings code
\RequirePackage{listings} % Code
-%\RequirePackage{minted}
+%\RequirePackage{minted} (must be loaded before scrhack)
+% Configure the listings
\definecolor{listingkeywords}{rgb}{0.0, 0.5, 0.0}
\definecolor{listingidentifiers}{rgb}{0, 0, 0}
\definecolor{listingcomments}{rgb}{0.25, 0.5, 0.5}
\definecolor{listingstrings}{rgb}{0.73, 0.13, 0.13}
\definecolor{listingnumbers}{rgb}{0.25, 0.25, 0.25}
+% Define a fancy style
\lstdefinestyle{kaolst}{
aboveskip=0.7\topskip,
belowskip=0.1\topskip,
@@ -1277,6 +1351,7 @@
tabsize=4,
defaultdialect=[LaTeX]Tex,
}
+% Define a plain style as well
\lstdefinestyle{kaolstplain}{
aboveskip=0.6\topskip,
belowskip=-0.1\topskip,
@@ -1299,7 +1374,7 @@
tabsize=4,
defaultdialect=[LaTeX]Tex,
}
-\lstset{style=kaolst}
+\lstset{style=kaolst}% Use the fancy style
% Verbatim
%\RequirePackage{fancyvrb} % Customization of verbatim environments
@@ -1312,7 +1387,6 @@
% Special gliphs
\RequirePackage{ccicons} % Creative Commons icons
-\RequirePackage{metalogo} % XeTeX logo
% Index, glossary and nomenclature
\RequirePackage{imakeidx}
diff --git a/kaobiblio.sty b/kaobiblio.sty
@@ -1,5 +1,9 @@
\ProvidesPackage{kaobiblio}
+%----------------------------------------------------------------------------------------
+% PACKAGE OPTIONS AND DEPENDENCIES
+%----------------------------------------------------------------------------------------
+
\RequirePackage{etoolbox} % Easy programming to modify TeX stuff
\RequirePackage{perpage} % Reset counters
\RequirePackage{iflang} % Check the document language
@@ -8,43 +12,44 @@
\RequirePackage{hyperref} % Required for hyperlinks
\RequirePackage{kvoptions} % Handle package options
+% Set up the package options
\SetupKeyvalOptions{
- family = kaobiblio,
- prefix = kaobiblio@
+ family = kaobiblio,
+ prefix = kaobiblio@
}
-\DeclareBoolOption{addspace}
-\DeclareBoolOption{linkeverything}
+\DeclareBoolOption{addspace}% If true, automatically add a space before printing the citation marker
+\DeclareBoolOption{linkeverything}% If true, the author name is a hyperlink in citation styles that support it
% Choose the default options, which will be overwritten by the options
% passed to this package.
\PassOptionsToPackage{
- %style=numeric-comp,
- %citestyle=authortitle-icomp,
- citestyle=numeric-comp,
- %bibstyle=authoryear,
- bibstyle=numeric,
- sorting=none,
- %sorting=nyt,
- %sortcites=true,
- %autocite=footnote,
- backend=biber, % Compile the bibliography with biber
- hyperref=true,
- backref=true,
- citecounter=true,
- pagetracker=true,
- citetracker=true,
- ibidtracker=context,
- autopunct=true,
- autocite=plain,
+ %style=numeric-comp,
+ %citestyle=authortitle-icomp,
+ citestyle=numeric-comp,
+ %bibstyle=authoryear,
+ bibstyle=numeric,
+ sorting=none,
+ %sorting=nyt,
+ %sortcites=true,
+ %autocite=footnote,
+ backend=biber, % Compile the bibliography with biber
+ hyperref=true,
+ backref=true,
+ citecounter=true,
+ pagetracker=true,
+ citetracker=true,
+ ibidtracker=context,
+ autopunct=true,
+ autocite=plain,
}{biblatex}
% Pass the unknown options to biblatex, overwriting the previous settings. Avoid passing the kao-specific options.
\DeclareDefaultOption{%
- \IfBeginWith{\CurrentOption}{addspace}{}{%
- \IfBeginWith{\CurrentOption}{linkeverything}{}{%
- \PassOptionsToPackage{\CurrentOption}{biblatex}%
- }}%
+ \IfBeginWith{\CurrentOption}{addspace}{}{%
+ \IfBeginWith{\CurrentOption}{linkeverything}{}{%
+ \PassOptionsToPackage{\CurrentOption}{biblatex}%
+ }}%
}
% Process the options
@@ -67,22 +72,22 @@
% Convert months to integers
\DeclareSourcemap{
- \maps[datatype=bibtex]{
- \map[overwrite]{
- \step[fieldsource=month, match={jan}, replace=${1}]
- \step[fieldsource=month, match={feb}, replace=${2}]
- \step[fieldsource=month, match={mar}, replace=${3}]
- \step[fieldsource=month, match={apr}, replace=${4}]
- \step[fieldsource=month, match={may}, replace=${5}]
- \step[fieldsource=month, match={jun}, replace=${6}]
- \step[fieldsource=month, match={jul}, replace=${7}]
- \step[fieldsource=month, match={aug}, replace=${8}]
- \step[fieldsource=month, match={sep}, replace=${9}]
- \step[fieldsource=month, match={oct}, replace=${10}]
- \step[fieldsource=month, match={nov}, replace=${11}]
- \step[fieldsource=month, match={dec}, replace=${12}]
- }
- }
+ \maps[datatype=bibtex]{
+ \map[overwrite]{
+ \step[fieldsource=month, match={jan}, replace=${1}]
+ \step[fieldsource=month, match={feb}, replace=${2}]
+ \step[fieldsource=month, match={mar}, replace=${3}]
+ \step[fieldsource=month, match={apr}, replace=${4}]
+ \step[fieldsource=month, match={may}, replace=${5}]
+ \step[fieldsource=month, match={jun}, replace=${6}]
+ \step[fieldsource=month, match={jul}, replace=${7}]
+ \step[fieldsource=month, match={aug}, replace=${8}]
+ \step[fieldsource=month, match={sep}, replace=${9}]
+ \step[fieldsource=month, match={oct}, replace=${10}]
+ \step[fieldsource=month, match={nov}, replace=${11}]
+ \step[fieldsource=month, match={dec}, replace=${12}]
+ }
+ }
}
%----------------------------------------------------------------------------------------
@@ -142,25 +147,25 @@
% Command to format the marginnote created for cited items
\NewDocumentCommand{\formatmargincitation}{m}{% The parameter is a single citation key
- \parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}%
+ \parencite{#1}: \citeauthor*{#1} (\iffieldundef{year}{\bibsstring{nodate}}{\printfield{year}}), \citefield{#1}[emph]{title}%
}
% Command to format the marginnote created for supercited items
\NewDocumentCommand{\formatmarginsupercitation}{m}{% The parameter is a single citation key
- \supercite{#1} \citeauthor*{#1} (\citeyear{#1})%
+ \supercite{#1} \citeauthor*{#1} (\iffieldundef{year}{\bibsstring{nodate}}{\printfield{year}})%
}
% The following command needs to be redefined every time \sidecite is called in order for \DeclareCiteCommand's wrapper to work correctly
\NewDocumentCommand{\kaobiblio@marginnote}{m}{%
- \marginnote{#1}%
+ \marginnote{#1}%
}
% biblatex-like commands that also print a citation in the margin
% Usage:
- % First optional argument is always vertical shift and must be given as an (empty) argument when using following a postnote and/or prenote
- % Second optional argument is always the postnote if the third argument isn't specified or is the prenote if the third argument is specified (same pattern as the biblatex commands)
- % Third optional argument is always the postnote
- % Mandatory argument is always the citation key(s)
+ % First optional argument is always vertical shift and must be given as an (empty) argument when using following a postnote and/or prenote
+ % Second optional argument is always the postnote if the third argument isn't specified or is the prenote if the third argument is specified (same pattern as the biblatex commands)
+ % Third optional argument is always the postnote
+ % Mandatory argument is always the citation key(s)
% Command to \cite and print a citation in the margin
% First optional argument: vertical shift
@@ -168,9 +173,9 @@
% Third optional argument: postnote
% Mandatory argument: citation key
\NewDocumentCommand{\sidecite}{o o o m}{%
- \RenewDocumentCommand{\kaobiblio@marginnote}{m}{%
- \marginnote[#1]{##1}%
- }%
+ \RenewDocumentCommand{\kaobiblio@marginnote}{m}{%
+ \marginnote[#1]{##1}%
+ }%
\DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{%
}{%
\formatmargincitation{\thefield{entrykey}}%
@@ -178,21 +183,21 @@
\\% separator between multiple citations
}{%
}%
- % With this we print the marker in the text and add the item to the bibliography at the end
- \IfNoValueOrEmptyTF{#2}%
- {\def\@tempa{\cite{#4}\kaobiblio@sidecite{#4}}}%
- {\IfNoValueOrEmptyTF{#3}%
- {\IfNoValueTF{#3}%
- {\def\@tempa{\cite[#2]{#4}\kaobiblio@sidecite{#4}}}%
- {\def\@tempa{\cite[#2][]{#4}\kaobook@sidecite{#4}}}% postnote is empty, so pass empty postnote
- }%
- {\def\@tempa{\cite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}%
- }%
- \ifkaobiblio@addspace%
- \unskip~\@tempa%
- \else%
- \@tempa%
- \fi%
+ % With this we print the marker in the text and add the item to the bibliography at the end
+ \IfNoValueOrEmptyTF{#2}%
+ {\def\@tempa{\cite{#4}\kaobiblio@sidecite{#4}}}%
+ {\IfNoValueOrEmptyTF{#3}%
+ {\IfNoValueTF{#3}%
+ {\def\@tempa{\cite[#2]{#4}\kaobiblio@sidecite{#4}}}%
+ {\def\@tempa{\cite[#2][]{#4}\kaobiblio@sidecite{#4}}}% postnote is empty, so pass empty postnote
+ }%
+ {\def\@tempa{\cite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}%
+ }%
+ \ifkaobiblio@addspace%
+ \unskip~\@tempa%
+ \else%
+ \@tempa%
+ \fi%
}
% Command to \supercite and print a citation in the margin
@@ -201,27 +206,27 @@
% Third optional argument: postnote
% Mandatory argument: citation key
\NewDocumentCommand{\sidesupercite}{o o o m}{%
- \RenewDocumentCommand{\kaobiblio@marginnote}{m}{%
- \marginnote[#1]{##1}%
- }%
- \DeclareCiteCommand{\kaobiblio@sidesupercite}[\kaobiblio@marginnote]{%
+ \RenewDocumentCommand{\kaobiblio@marginnote}{m}{%
+ \marginnote[#1]{##1}%
+ }%
+ \DeclareCiteCommand{\kaobiblio@sidesupercite}[\kaobiblio@marginnote]{%
}{%
- \formatmarginsupercitation{\thefield{entrykey}}%
+ \formatmarginsupercitation{\thefield{entrykey}}%
}{%
\\% separator between multiple citations
}{%
}%
- % With this we print the marker in the text and add the item to the bibliography at the end
- \IfNoValueOrEmptyTF{#2}%
- {\def\@tempa{\supercite{#4}\kaobiblio@sidesupercite{#4}}}%
- {\IfNoValueOrEmptyTF{#3}%
- {\IfNoValueTF{#3}%
- {\def\@tempa{\supercite[#2]{#4}\kaobiblio@sidesupercite{#4}}}%
- {\def\@tempa{\supercite[#2][]{#4}\kaobook@sidesupercite{#4}}}% postnote is empty, so pass empty postnote
- }%
- {\def\@tempa{\supercite[#2][#3]{#4}\kaobiblio@sidesupercite{#4}}}%
- }%
- \@tempa%
+ % With this we print the marker in the text and add the item to the bibliography at the end
+ \IfNoValueOrEmptyTF{#2}%
+ {\def\@tempa{\supercite{#4}\kaobiblio@sidesupercite{#4}}}%
+ {\IfNoValueOrEmptyTF{#3}%
+ {\IfNoValueTF{#3}%
+ {\def\@tempa{\supercite[#2]{#4}\kaobiblio@sidesupercite{#4}}}%
+ {\def\@tempa{\supercite[#2][]{#4}\kaobook@sidesupercite{#4}}}% postnote is empty, so pass empty postnote
+ }%
+ {\def\@tempa{\supercite[#2][#3]{#4}\kaobiblio@sidesupercite{#4}}}%
+ }%
+ \@tempa%
}
% Command to \textcite and print a citation in the margin
@@ -240,21 +245,21 @@
\\% separator between multiple citations
}{%
}%
- % With this we print the marker in the text and add the item to the bibliography at the end
+ % With this we print the marker in the text and add the item to the bibliography at the end
\IfNoValueOrEmptyTF{#2}%
- {\def\@tempa{\textcite{#4}\kaobiblio@sidecite{#4}}}%
+ {\def\@tempa{\textcite{#4}\kaobiblio@sidecite{#4}}}%
{\IfNoValueOrEmptyTF{#3}%
{\IfNoValueTF{#3}%
- {\def\@tempa{\textcite[#2]{#4}\kaobiblio@sidecite{#4}}}%
- {\def\@tempa{\textcite[#2][]{#4}\kaobook@sidecite{#4}}}% postnote is empty, so pass empty postnote
+ {\def\@tempa{\textcite[#2]{#4}\kaobiblio@sidecite{#4}}}%
+ {\def\@tempa{\textcite[#2][]{#4}\kaobook@sidecite{#4}}}% postnote is empty, so pass empty postnote
}%
- {\def\@tempa{\textcite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}%
- }%
- \ifkaobiblio@addspace%
- \unskip~\@tempa%
- \else%
- \@tempa%
- \fi%
+ {\def\@tempa{\textcite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}%
+ }%
+ \ifkaobiblio@addspace%
+ \unskip~\@tempa%
+ \else%
+ \@tempa%
+ \fi%
}
% Command to \parencite or \parencite* and print a citation in the margin
@@ -274,33 +279,33 @@
\\% separator between multiple citations
}{%
}%
- % With this we print the marker in the text and add the item to the bibliography at the end
- \IfBooleanTF#1%
- {\IfNoValueOrEmptyTF{#3}%
- {\parencite*{#5}}%
- {\IfNoValueOrEmptyTF{#4}%
- {\IfNoValueTF{#4}%
- {\def\@tempa{\parencite*[#3]{#5}}}%
- {\def\@tempa{\parencite*[#3][]{#5}}}% postnote is empty, so pass empty postnote
- }%
- {\def\@tempa{\parencite*[#3][#4]{#5}}}%
- }%
- }%
- {\IfNoValueOrEmptyTF{#3}%
- {\def\@tempa{\parencite{#5}}}%
- {\IfNoValueOrEmptyTF{#4}%
- {\IfNoValueTF{#4}%
- {\def\@tempa{\parencite[#3]{#5}}}%
- {\def\@tempa{\parencite[#3][]{#5}}}% postnote is empty, so pass empty postnote
- }%
- {\def\@tempa{\parencite[#3][#4]{#5}}}%
- }%
- }%
- \ifkaobiblio@addspace%
- \unskip~\@tempa%
- \else%
- \@tempa%
- \fi%
+ % With this we print the marker in the text and add the item to the bibliography at the end
+ \IfBooleanTF#1%
+ {\IfNoValueOrEmptyTF{#3}%
+ {\parencite*{#5}\kaobiblio@sidecite{#5}}%
+ {\IfNoValueOrEmptyTF{#4}%
+ {\IfNoValueTF{#4}%
+ {\def\@tempa{\parencite*[#3]{#5}\kaobiblio@sidecite{#5}}}%
+ {\def\@tempa{\parencite*[#3][]{#5}\kaobiblio@sidecite{#5}}}% postnote is empty, so pass empty postnote
+ }%
+ {\def\@tempa{\parencite*[#3][#4]{#5}\kaobiblio@sidecite{#5}}}%
+ }%
+ }%
+ {\IfNoValueOrEmptyTF{#3}%
+ {\def\@tempa{\parencite{#5}\kaobiblio@sidecite{#5}}}%
+ {\IfNoValueOrEmptyTF{#4}%
+ {\IfNoValueTF{#4}%
+ {\def\@tempa{\parencite[#3]{#5}\kaobiblio@sidecite{#5}}}%
+ {\def\@tempa{\parencite[#3][]{#5}\kaobiblio@sidecite{#5}}}% postnote is empty, so pass empty postnote
+ }%
+ {\def\@tempa{\parencite[#3][#4]{#5}\kaobiblio@sidecite{#5}}}%
+ }%
+ }%
+ \ifkaobiblio@addspace%
+ \unskip~\@tempa%
+ \else%
+ \@tempa%
+ \fi%
}
@@ -308,91 +313,91 @@
% LINKING THE AUTHOR'S NAME
%----------------------------------------------------------------------------------------
-% In biblatex, when citing with the style authoryear or using \textcite, only the year is linked to the reference in the bibliography. Despite the arguments of one of the mantainers of the biblatex package (https://github.com/plk/biblatex/issues/428), some users think that in the author* style the author name should be a link as well. The `linkname' option provides an easy way to activate this behaviour.
+% In biblatex, when citing with the style authoryear or using \textcite, only the year is linked to the reference in the bibliography. Despite the arguments of one of the mantainers of the biblatex package (https://github.com/plk/biblatex/issues/428), some users think that in the author* style the author name should be a link as well. The `linkeverything' option provides an easy way to activate this behaviour.
\ifkaobiblio@linkeverything
- \xpatchbibmacro{cite}
- {\usebibmacro{cite:label}%
- \setunit{\printdelim{nonameyeardelim}}%
- \usebibmacro{cite:labeldate+extradate}}
- {\printtext[bibhyperref]{%
- \DeclareFieldAlias{bibhyperref}{default}%
- \usebibmacro{cite:label}%
- \setunit{\printdelim{nonameyeardelim}}%
- \usebibmacro{cite:labeldate+extradate}}}
- {}
- {\PackageWarning{biblatex-patch}
- {Failed to patch cite bibmacro}}
-
- % Include labelname in labelyear link
- \xpatchbibmacro{cite}
- {\printnames{labelname}%
- \setunit{\printdelim{nameyeardelim}}%
- \usebibmacro{cite:labeldate+extradate}}
- {\printtext[bibhyperref]{%
- \DeclareFieldAlias{bibhyperref}{default}%
- \printnames{labelname}%
- \setunit{\printdelim{nameyeardelim}}%
- \usebibmacro{cite:labeldate+extradate}}}
- {}
- {\PackageWarning{biblatex-patch}
- {Failed to patch cite bibmacro}}
-
- % Access hyperref's citation link start/end commands
- \makeatletter
- \protected\def\blx@imc@biblinkstart{%
- \@ifnextchar[%]
- {\blx@biblinkstart}
- {\blx@biblinkstart[\abx@field@entrykey]}}
- \def\blx@biblinkstart[#1]{%
- \blx@sfsave\hyper@natlinkstart{\the\c@refsection @#1}\blx@sfrest}
- \protected\def\blx@imc@biblinkend{%
- \blx@sfsave\hyper@natlinkend\blx@sfrest}
- \blx@regimcs{\biblinkstart \biblinkend}
- \makeatother
-
- \newbool{cbx:link}
-
- % Include parentheses around labelyear in \textcite only in
- % single citations without pre- and postnotes
- \def\iflinkparens{%
- \ifboolexpr{ test {\ifnumequal{\value{multicitetotal}}{0}} and
- test {\ifnumequal{\value{citetotal}}{1}} and
- test {\iffieldundef{prenote}} and
- test {\iffieldundef{postnote}} }}
-
- \xpatchbibmacro{textcite}
- {\printnames{labelname}}
- {\iflinkparens
- {\DeclareFieldAlias{bibhyperref}{default}%
- \global\booltrue{cbx:link}\biblinkstart%
- \printnames{labelname}}
- {\printtext[bibhyperref]{\printnames{labelname}}}}
- {}
- {\PackageWarning{biblatex-patch}
- {Failed to patch textcite bibmacro}}
-
- \xpatchbibmacro{textcite}
- {\usebibmacro{cite:label}}
- {\iflinkparens
- {\DeclareFieldAlias{bibhyperref}{default}%
- \global\booltrue{cbx:link}\biblinkstart%
- \usebibmacro{cite:label}}
- {\usebibmacro{cite:label}}}
- {}
- {\PackageWarning{biblatex-patch}
- {Failed to patch textcite bibmacro}}
-
- \xpretobibmacro{textcite:postnote}
- {\ifbool{cbx:link}
- {\ifbool{cbx:parens}
- {\bibcloseparen\global\boolfalse{cbx:parens}}
- {}%
- \biblinkend\global\boolfalse{cbx:link}}
- {}}
- {}
- {\PackageWarning{biblatex-patch}
- {Failed to patch textcite:postnote bibmacro}}
+ \xpatchbibmacro{cite}
+ {\usebibmacro{cite:label}%
+ \setunit{\printdelim{nonameyeardelim}}%
+ \usebibmacro{cite:labeldate+extradate}}
+ {\printtext[bibhyperref]{%
+ \DeclareFieldAlias{bibhyperref}{default}%
+ \usebibmacro{cite:label}%
+ \setunit{\printdelim{nonameyeardelim}}%
+ \usebibmacro{cite:labeldate+extradate}}}
+ {}
+ {\PackageWarning{biblatex-patch}
+ {Failed to patch cite bibmacro}}
+
+ % Include labelname in labelyear link
+ \xpatchbibmacro{cite}
+ {\printnames{labelname}%
+ \setunit{\printdelim{nameyeardelim}}%
+ \usebibmacro{cite:labeldate+extradate}}
+ {\printtext[bibhyperref]{%
+ \DeclareFieldAlias{bibhyperref}{default}%
+ \printnames{labelname}%
+ \setunit{\printdelim{nameyeardelim}}%
+ \usebibmacro{cite:labeldate+extradate}}}
+ {}
+ {\PackageWarning{biblatex-patch}
+ {Failed to patch cite bibmacro}}
+
+ % Access hyperref's citation link start/end commands
+ \makeatletter
+ \protected\def\blx@imc@biblinkstart{%
+ \@ifnextchar[%]
+ {\blx@biblinkstart}
+ {\blx@biblinkstart[\abx@field@entrykey]}}
+ \def\blx@biblinkstart[#1]{%
+ \blx@sfsave\hyper@natlinkstart{\the\c@refsection @#1}\blx@sfrest}
+ \protected\def\blx@imc@biblinkend{%
+ \blx@sfsave\hyper@natlinkend\blx@sfrest}
+ \blx@regimcs{\biblinkstart \biblinkend}
+ \makeatother
+
+ \newbool{cbx:link}
+
+ % Include parentheses around labelyear in \textcite only in
+ % single citations without pre- and postnotes
+ \def\iflinkparens{%
+ \ifboolexpr{ test {\ifnumequal{\value{multicitetotal}}{0}} and
+ test {\ifnumequal{\value{citetotal}}{1}} and
+ test {\iffieldundef{prenote}} and
+ test {\iffieldundef{postnote}} }}
+
+ \xpatchbibmacro{textcite}
+ {\printnames{labelname}}
+ {\iflinkparens
+ {\DeclareFieldAlias{bibhyperref}{default}%
+ \global\booltrue{cbx:link}\biblinkstart%
+ \printnames{labelname}}
+ {\printtext[bibhyperref]{\printnames{labelname}}}}
+ {}
+ {\PackageWarning{biblatex-patch}
+ {Failed to patch textcite bibmacro}}
+
+ \xpatchbibmacro{textcite}
+ {\usebibmacro{cite:label}}
+ {\iflinkparens
+ {\DeclareFieldAlias{bibhyperref}{default}%
+ \global\booltrue{cbx:link}\biblinkstart%
+ \usebibmacro{cite:label}}
+ {\usebibmacro{cite:label}}}
+ {}
+ {\PackageWarning{biblatex-patch}
+ {Failed to patch textcite bibmacro}}
+
+ \xpretobibmacro{textcite:postnote}
+ {\ifbool{cbx:link}
+ {\ifbool{cbx:parens}
+ {\bibcloseparen\global\boolfalse{cbx:parens}}
+ {}%
+ \biblinkend\global\boolfalse{cbx:link}}
+ {}}
+ {}
+ {\PackageWarning{biblatex-patch}
+ {Failed to patch textcite:postnote bibmacro}}
\else
\fi
diff --git a/kaobook.cls b/kaobook.cls
@@ -1,7 +1,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% kaobook
% LaTeX Class
-% Version 0.9.7 (2021/06/02)
+% Version 0.9.8 (2021/08/23)
%
% This template originates from:
% https://www.LaTeXTemplates.com
@@ -25,16 +25,9 @@
%----------------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{kaobook}[2021/06/02 v0.9.7 kaobook]
+\ProvidesClass{kaobook}[2021/08/23 v0.9.8 kaobook]
\newcommand{\@baseclass}{scrbook} % Base class name
-%\RequirePackage{kvoptions} % Manage class key-value options
-
-%\SetupKeyvalOptions{
-% family = kao,
-% prefix = kao@
-%}
-
% Set the default options
\PassOptionsToClass{a4paper}{\@baseclass}
\PassOptionsToClass{fontsize=10pt}{\@baseclass}
@@ -44,18 +37,10 @@
% Pass through any other options to the base class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@baseclass}}
-%\ProcessKeyvalOptions*
\ProcessOptions\relax % Process the options
\LoadClass{\@baseclass} % Load the base class
-% Define kao-specific options
-%\DeclareStringOption[1]{secnumdepth}
-\DefineFamily{kao}
-\DefineFamilyMember[kaobook]{kao}
-\DefineFamilyKey[kaobook]{kao}{secnumdepth}[1]{\setcounter{secnumdepth}{#1}\FamilyKeyStateProcessed}
-% \FamilyProcessOptions[kaobook]{kao} % I COMMENTED THIS
-
\RequirePackage{kao} % Load the code common to all classes
%----------------------------------------------------------------------------------------
@@ -77,7 +62,7 @@
% Main matter
\let\oldmainmatter\mainmatter % Store the old command
\renewcommand{\mainmatter}{%
- \oldmainmatter% Call the old command
+ \oldmainmatter% Call the old command
\pagestyle{scrheadings}% Use a fancy style for the header and the footer
\pagelayout{margin}% Use a 1.5 column layout
\setchapterstyle{kao} % Choose the default chapter heading style
@@ -108,11 +93,12 @@
% CHAPTER HEADING STYLES
%----------------------------------------------------------------------------------------
+% Command to easily switch between chapter styles
\DeclareDocumentCommand{\setchapterstyle}{m}{%
\ifthenelse{\equal{plain}{#1}}{\chapterstyleplain}{}
- \ifthenelse{\equal{bar}{#1}}{\chapterstylebar}{}
+ \ifthenelse{\equal{bar}{#1}}{\chapterstylebar}{}
\ifthenelse{\equal{lines}{#1}}{\chapterstylelines}{}
- \ifthenelse{\equal{kao}{#1}}{\chapterstylekao}{}
+ \ifthenelse{\equal{kao}{#1}}{\chapterstylekao}{}
}
% The default definition in KOMA script
@@ -122,7 +108,7 @@
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\thechapter%
\autodot\IfUsePrefixLine{}{\enskip}}}
- \RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}
+ \RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}
}
@@ -148,7 +134,7 @@
]{\@hangfrom{##2}{##3}};
\end{tikzpicture}
}
- \RedeclareSectionCommand[beforeskip=-55\vscale,afterskip=6\vscale]{chapter}
+ \RedeclareSectionCommand[beforeskip=-55\vscale,afterskip=6\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}
}
@@ -161,22 +147,22 @@
\chapappifchapterprefix{\nobreakspace}\scalebox{3.5}{\thechapter\autodot}%
}%
\renewcommand\chapterlinesformat[3]{%
- %\vspace*{-1cm}%
- \leavevmode%
- \makebox[0pt][l]{%
+ %\vspace*{-1cm}%
+ \leavevmode%
+ \makebox[0pt][l]{%
\makebox[\textwidth][l]{\hrulefill[1pt]##2}%\hfill%\par%\bigskip
\makebox[\marginparsep][l]{}%
\makebox[\marginparwidth][l]{}%
- }\\
- %\vspace{.5cm}
- \makebox[0pt][l]{%
+ }\\
+ %\vspace{.5cm}
+ \makebox[0pt][l]{%
\makebox[\textwidth][l]{##3}%
\makebox[\marginparsep][l]{}%
\makebox[\marginparwidth][l]{}%
- }\\
- \makebox[0pt][l]{%
+ }\\
+ \makebox[0pt][l]{%
\makebox[\textwidth+\marginparsep+\marginparwidth][l]{\hrulefill[1.1pt]}%
- }%
+ }%
}%
\RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}%
@@ -184,35 +170,65 @@
% The Kao style
\DeclareDocumentCommand{\chapterstylekao}{}{%
- \renewcommand*{\chapterformat}{%
- \mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}%
- }%
- \renewcommand\chapterlinesformat[3]{%
- \vspace{3.5\vscale}%
- \if@twoside%
- \Ifthispageodd{%
- \smash{\makebox[0pt][l]{%
- \parbox[b]{\textwidth}{\flushright{##3}}%
- \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
- \parbox[b]{\marginparwidth}{##2}%
- }}%
- }{
- \smash{\makebox[\textwidth][r]{%
- \parbox[b]{\marginparwidth}{\flushright{##2}}%
- \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
- \parbox[b]{\textwidth}{\flushleft{##3}}%
- }}%
- }
- \else%
- \smash{\makebox[0pt][l]{%
- \parbox[b]{\textwidth}{\flushright{##3}}%
- \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
- \parbox[b]{\marginparwidth}{##2}%
- }}%
- \fi%
- }%
+ \IfWideLayout{%
+ \renewcommand*{\chapterformat}{%
+ \mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}%
+ }%
+ \renewcommand\chapterlinesformat[3]{%
+ \vspace{3.5\vscale}%
+ \if@twoside%
+ \Ifthispageodd{%
+ \smash{\makebox[0pt][l]{%
+ \parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}%
+ \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\marginparwidth}{##2}%
+ }}%
+ }{
+ \smash{\makebox[\textwidth + 6.2\hscale][r]{%
+ \parbox[b]{47.7\hscale + 6.2\hscale}{\flushright{##2}}%
+ \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\textwidth}{\flushleft{##3}}%
+ }}%
+ }
+ \else%
+ \smash{\makebox[0pt][l]{%
+ \parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}%
+ \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\marginparwidth}{##2}%
+ }}%
+ \fi%
+ }%
+ }{%
+ \renewcommand*{\chapterformat}{%
+ \mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}%
+ }%
+ \renewcommand\chapterlinesformat[3]{%
+ \vspace{3.5\vscale}%
+ \if@twoside%
+ \Ifthispageodd{%
+ \smash{\makebox[0pt][l]{%
+ \parbox[b]{\textwidth}{\flushright{##3}}%
+ \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\marginparwidth}{##2}%
+ }}%
+ }{
+ \smash{\makebox[\textwidth][r]{%
+ \parbox[b]{\marginparwidth}{\flushright{##2}}%
+ \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\textwidth}{\flushleft{##3}}%
+ }}%
+ }
+ \else%
+ \smash{\makebox[0pt][l]{%
+ \parbox[b]{\textwidth}{\flushright{##3}}%
+ \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
+ \parbox[b]{\marginparwidth}{##2}%
+ }}%
+ \fi%
+ }%
+ }%
\RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}%
- \setlength{\mtocshift}{-3\vscale}%
+ \setlength{\mtocshift}{-3.5\vscale}%
}
% Takes as input the image path and optionally the "beforeskip"
@@ -221,13 +237,13 @@
\vspace*{-27\vscale}\hspace*{\dimexpr - \hoffset - \oddsidemargin - 1in}%
\includegraphics[width=\paperwidth,height=#1+27\vscale,keepaspectratio=false]{#2}%
}%
- \chapterstylebar%
+ \chapterstylebar%
% beforeskip=-(figure_height-top_margin)
- \RedeclareSectionCommand[beforeskip=-#1, afterskip=6\vscale]{chapter}%
- \setlength{\mtocshift}{0cm}%
+ \RedeclareSectionCommand[beforeskip=-#1, afterskip=6\vscale]{chapter}%
+ \setlength{\mtocshift}{0cm}%
}
-% By default start with plain style
+% By default start with the plain style
\chapterstyleplain
%----------------------------------------------------------------------------------------
@@ -251,6 +267,7 @@
% TOC, LOF & LOT
%----------------------------------------------------------------------------------------
+% Set default options regarding the table of contents
\PassOptionsToClass{toc=listof}{\@baseclass}
\PassOptionsToClass{toc=index}{\@baseclass}
\PassOptionsToClass{toc=bibliography}{\@baseclass}
@@ -259,8 +276,7 @@
% NUMBERING
%----------------------------------------------------------------------------------------
-%\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering
-%depth
+%\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering depth
\counterwithin*{sidenote}{chapter} % Uncomment to reset the sidenote counter at each chapter
%\counterwithout{sidenote}{chapter} % Uncomment to have one sidenote counter for the whole document
diff --git a/kaohandt.cls b/kaohandt.cls
@@ -0,0 +1,96 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% kaobook
+% LaTeX Class
+% Version 0.9.8 (2021/08/23)
+%
+% This template originates from:
+% https://www.LaTeXTemplates.com
+%
+% For the latest template development version and to make contributions:
+% https://github.com/fmarotta/kaobook
+%
+% Authors:
+% Federico Marotta (federicomarotta@mail.com)
+% Based on the doctoral thesis of Ken Arroyo Ohori (https://3d.bk.tudelft.nl/ken/en)
+% and on the Tufte-LaTeX class.
+% Modified for LaTeX Templates by Vel (vel@latextemplates.com)
+%
+% License:
+% LPPL (see included MANIFEST.md file)
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%----------------------------------------------------------------------------------------
+% CLASS CONFIGURATION
+%----------------------------------------------------------------------------------------
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{kaohandt}[2021/08/23 v0.9.8 kaohandt]
+\newcommand{\@baseclass}{scrartcl} % Base class name
+
+% Set the default options
+\PassOptionsToClass{a4paper}{\@baseclass}
+
+% Pass through any other options to the base class
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@baseclass}}
+
+\ProcessOptions\relax % Process the options
+
+\LoadClass{\@baseclass} % Load the base class
+
+\RequirePackage{kao} % Load the code common to all classes
+
+%----------------------------------------------------------------------------------------
+% TITLE-RELATED SETTINGS
+%----------------------------------------------------------------------------------------
+
+% Left-align title, authors and date
+\xpatchcmd{\@maketitle}{\begin{center}}{\begin{flushleft}}{}{}
+ \xpatchcmd{\@maketitle}{\end{center}}{\end{flushleft}}{}{}
+\xpatchcmd{\@maketitle}{\begin{tabular}[t]{c}}{\begin{tabular}[t]{@{}l@{}}}{}{}
+
+% Set the font for the title
+\addtokomafont{title}{\normalfont\bfseries}
+
+% Customise the abstract
+\RequirePackage[style]{abstract}
+
+\setlength{\absleftindent}{0pt}% No indentation in the abstract
+\if@abstrt
+ \renewcommand{\abstitlestyle}[1]{%
+ \vspace{-0.6cm}%
+ \begin{center}%
+ {\normalfont\bfseries\hspace{-3em} \abstractname\vspace{-.5em}\vspace{\z@}}%
+ \end{center}%
+ }
+\else
+ \renewcommand{\abstitlestyle}[1]{\vspace{-.5em}\vspace{\z@}}%
+\fi
+
+% Set KOMA fonts
+\addtokomafont{section}{\normalfont\bfseries}
+\addtokomafont{subsection}{\normalfont\bfseries}
+\addtokomafont{subsubsection}{\normalfont\bfseries}
+\addtokomafont{paragraph}{\normalfont\bfseries}
+\setkomafont{descriptionlabel}{\normalfont\bfseries}
+
+%----------------------------------------------------------------------------------------
+% TOC
+%----------------------------------------------------------------------------------------
+
+% Adjust the positions of margintoc and marginnotes
+\setlength{\mtocshift}{-0.6cm}
+\renewcommand{\marginnotevadjust}{-4pt}
+
+% Do not add lists to the TOC
+\PassOptionsToClass{toc=nolistof}{\@baseclass}
+\unsettoc{toc}{totoc}
+
+%----------------------------------------------------------------------------------------
+% NUMBERING
+%----------------------------------------------------------------------------------------
+
+%\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering depth
+
+\counterwithin*{sidenote}{section} % Uncomment to reset the sidenote counter at each section
+%\counterwithout{sidenote}{section} % Uncomment to have one sidenote counter for the whole document
diff --git a/kaorefs.sty b/kaorefs.sty
@@ -1,7 +1,11 @@
\ProvidesPackage{kaorefs}
-% Easily label and reference elements
-% Note that \label must appear after \caption
+%----------------------------------------------------------------------------------------
+% PACKAGE OPTIONS AND DEPENDENCIES
+%----------------------------------------------------------------------------------------
+
+% Easily label and reference elements with this package
+% Note that, in figures and tables, \label must appear after \caption
% Load this package last
% Pass this package's options to hyperref and varioref
@@ -11,12 +15,16 @@
\ProcessOptions\relax
\let\thmname\relax % Workaround to get rid of an annoying error
+\RequirePackage{amsthm} % Needed by cleveref
\RequirePackage{varioref}
\RequirePackage{hyperref}
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}
-% Language-specific strings
+%----------------------------------------------------------------------------------------
+% LANGUAGE-SPECIFIC STRINGS
+%----------------------------------------------------------------------------------------
+
% #LANGUAGE
\newcommand{\chapternameshort}{}
\newcommand{\sectionname}{}
@@ -37,70 +45,93 @@
\newcommand{\examplename}{}
\newcommand{\exercisename}{}
+\addto\captionsgerman{%
+ \renewcommand{\chapternameshort}{Kap.}
+ \renewcommand{\sectionname}{Abschnitt}
+ \renewcommand{\sectionnameshort}{Abschn.}
+ \renewcommand{\subsectionname}{Unterabschnitt}
+ \renewcommand{\subsectionnameplural}{Unterabschnitte}
+ \renewcommand{\subsectionnameshort}{Unterabschn.}
+ \renewcommand{\figurenameshort}{Abb.}
+ \renewcommand{\tablenameshort}{Tab.}
+ \renewcommand{\eqname}{Gleichung}
+ \renewcommand{\eqnameshort}{Gl.}
+ \renewcommand{\defname}{Definition}
+ \renewcommand{\assumname}{Hypothese}
+ \renewcommand{\thmname}{Satz}
+ \renewcommand{\propname}{Proposition}
+ \renewcommand{\lemmaname}{Lemma}
+ \renewcommand{\remarkname}{Bemerkung}
+ \renewcommand{\examplename}{Beispiel}
+ \renewcommand{\exercisename}{Übung}
+}
\addto\captionsdanish{%
- \renewcommand{\chapternameshort}{Kap.}
- \renewcommand{\sectionname}{Sektion}
- \renewcommand{\sectionnameshort}{Sek.}
- \renewcommand{\subsectionname}{Undersektion}
- \renewcommand{\subsectionnameplural}{Undersectioner}
- \renewcommand{\subsectionnameshort}{Undersek.}
- \renewcommand{\figurenameshort}{Fig.}
- \renewcommand{\tablenameshort}{Tab.}
- \renewcommand{\eqname}{Formel}
- \renewcommand{\eqnameshort}{Frml.}
- \renewcommand{\defname}{Definition}
- \renewcommand{\assumname}{Hypotese}
- \renewcommand{\thmname}{Sætning}
- \renewcommand{\propname}{Postulat}
- \renewcommand{\lemmaname}{Hjælpesætning}
- \renewcommand{\remarkname}{Bemærkning}
- \renewcommand{\examplename}{Eksempel}
- \renewcommand{\exercisename}{Øvelse}
+ \renewcommand{\chapternameshort}{Kap.}
+ \renewcommand{\sectionname}{Sektion}
+ \renewcommand{\sectionnameshort}{Sek.}
+ \renewcommand{\subsectionname}{Undersektion}
+ \renewcommand{\subsectionnameplural}{Undersectioner}
+ \renewcommand{\subsectionnameshort}{Undersek.}
+ \renewcommand{\figurenameshort}{Fig.}
+ \renewcommand{\tablenameshort}{Tab.}
+ \renewcommand{\eqname}{Formel}
+ \renewcommand{\eqnameshort}{Frml.}
+ \renewcommand{\defname}{Definition}
+ \renewcommand{\assumname}{Hypotese}
+ \renewcommand{\thmname}{Sætning}
+ \renewcommand{\propname}{Postulat}
+ \renewcommand{\lemmaname}{Hjælpesætning}
+ \renewcommand{\remarkname}{Bemærkning}
+ \renewcommand{\examplename}{Eksempel}
+ \renewcommand{\exercisename}{Øvelse}
}
\addto\captionsenglish{%
- \renewcommand{\chapternameshort}{Chap.}
- \renewcommand{\sectionname}{Section}
- \renewcommand{\sectionnameshort}{Sec.}
- \renewcommand{\subsectionname}{Subsection}
- \renewcommand{\subsectionnameplural}{Subsections}
- \renewcommand{\subsectionnameshort}{Subsec.}
- \renewcommand{\figurenameshort}{Fig.}
- \renewcommand{\tablenameshort}{Tab.}
- \renewcommand{\eqname}{Equation}
- \renewcommand{\eqnameshort}{Eq.}
- \renewcommand{\defname}{Definition}
- \renewcommand{\assumname}{Assumption}
- \renewcommand{\thmname}{Theorem}
- \renewcommand{\propname}{Proposition}
- \renewcommand{\lemmaname}{Lemma}
- \renewcommand{\remarkname}{Remark}
- \renewcommand{\examplename}{Example}
- \renewcommand{\exercisename}{Exercise}
+ \renewcommand{\chapternameshort}{Chap.}
+ \renewcommand{\sectionname}{Section}
+ \renewcommand{\sectionnameshort}{Sec.}
+ \renewcommand{\subsectionname}{Subsection}
+ \renewcommand{\subsectionnameplural}{Subsections}
+ \renewcommand{\subsectionnameshort}{Subsec.}
+ \renewcommand{\figurenameshort}{Fig.}
+ \renewcommand{\tablenameshort}{Tab.}
+ \renewcommand{\eqname}{Equation}
+ \renewcommand{\eqnameshort}{Eq.}
+ \renewcommand{\defname}{Definition}
+ \renewcommand{\assumname}{Assumption}
+ \renewcommand{\thmname}{Theorem}
+ \renewcommand{\propname}{Proposition}
+ \renewcommand{\lemmaname}{Lemma}
+ \renewcommand{\remarkname}{Remark}
+ \renewcommand{\examplename}{Example}
+ \renewcommand{\exercisename}{Exercise}
}
\addto\captionsitalian{%
- \renewcommand{\chapternameshort}{Cap.}
- \renewcommand{\sectionname}{Sezione}
- \renewcommand{\sectionnameshort}{Sez.}
- \renewcommand{\subsectionname}{Sottosezione}
- \renewcommand{\subsectionnameplural}{Sottosezioni}
- \renewcommand{\subsectionnameshort}{Sottosezione}
- \renewcommand{\figurenameshort}{Fig.}
- \renewcommand{\tablenameshort}{Tab.}
- \renewcommand{\eqname}{Equazione}
- \renewcommand{\eqnameshort}{Eq.}
- \renewcommand{\defname}{Definizione}
- \renewcommand{\assumname}{Assunzione}
- \renewcommand{\thmname}{Teorema}
- \renewcommand{\propname}{Proposizione}
- \renewcommand{\lemmaname}{Lemma}
- \renewcommand{\remarkname}{Osservazione}
- \renewcommand{\examplename}{Esempio}
- \renewcommand{\exercisename}{Esercizio}
+ \renewcommand{\chapternameshort}{Cap.}
+ \renewcommand{\sectionname}{Sezione}
+ \renewcommand{\sectionnameshort}{Sez.}
+ \renewcommand{\subsectionname}{Sottosezione}
+ \renewcommand{\subsectionnameplural}{Sottosezioni}
+ \renewcommand{\subsectionnameshort}{Sottosezione}
+ \renewcommand{\figurenameshort}{Fig.}
+ \renewcommand{\tablenameshort}{Tab.}
+ \renewcommand{\eqname}{Equazione}
+ \renewcommand{\eqnameshort}{Eq.}
+ \renewcommand{\defname}{Definizione}
+ \renewcommand{\assumname}{Assunzione}
+ \renewcommand{\thmname}{Teorema}
+ \renewcommand{\propname}{Proposizione}
+ \renewcommand{\lemmaname}{Lemma}
+ \renewcommand{\remarkname}{Osservazione}
+ \renewcommand{\examplename}{Esempio}
+ \renewcommand{\exercisename}{Esercizio}
}
% Do you speak other languages? Please, feel free to add the captions!
-% Labelling commands
+%----------------------------------------------------------------------------------------
+% LABELLING COMMANDS
+%----------------------------------------------------------------------------------------
+
\newcommand{\labpage}[1]{\label{page:#1}}
\newcommand{\labpart}[1]{\label{part:#1}}
\newcommand{\labch}[1]{\label{ch:#1}}
@@ -119,7 +150,10 @@
\newcommand{\labexercise}[1]{\label{exercise:#1}}
-% Referencing commands
+%----------------------------------------------------------------------------------------
+% REFERENCING COMMANDS
+%----------------------------------------------------------------------------------------
+
\newcommand{\refpage}[1]{\hyperref[#1]{\pagename}\xspace\pageref{page:#1}} % Page 84
\newcommand{\vrefpage}[1]{\vpageref*{page:#1}} % on the following page, on page 84
@@ -191,7 +225,9 @@
\newcommand{\vrefexercise}[1]{\hyperref[exercise:#1]\exercisename\xspace\vref{exercise:#1}}
-% cleveref customisation
+%----------------------------------------------------------------------------------------
+% CLEVEREF CUSTOMISATION
+%----------------------------------------------------------------------------------------
% Hyperlink the page reference as well
\let\oldvpageref\vpageref
diff --git a/kaotheorems.sty b/kaotheorems.sty
@@ -1,13 +1,19 @@
\ProvidesPackage{kaotheorems}
+%----------------------------------------------------------------------------------------
+% PACKAGE OPTIONS AND DEPENDENCIES
+%----------------------------------------------------------------------------------------
+
\RequirePackage{kvoptions} % Handle package options
\SetupKeyvalOptions{
- family = kaotheorems,
- prefix = kaotheorems@
+ family = kaotheorems,
+ prefix = kaotheorems@
}
-\DeclareBoolOption{framed}
+\DeclareBoolOption{framed}% If true, put theorems into colorful boxes, otherwise write them like normal text
+% Define the options to finely tune the background color of each element.
+% If only the 'background' option is specified, all types of theorem will have that background. If more specific options are set, the previous option will be overwritten.
\newcommand{\kaotheorems@defaultbg}{Goldenrod!45!white}
\DeclareStringOption[\kaotheorems@defaultbg]{background}
\DeclareStringOption[\kaotheorems@defaultbg]{theorembackground}
@@ -20,372 +26,371 @@
\DeclareStringOption[\kaotheorems@defaultbg]{examplebackground}
\DeclareStringOption[\kaotheorems@defaultbg]{exercisebackground}
-\ProcessKeyvalOptions{kaotheorems}
+\ProcessKeyvalOptions{kaotheorems} % Process the options
-\let\openbox\relax
+\let\openbox\relax % Workaround to avoid a nasty error
\RequirePackage{amsmath} % Improved mathematics
\RequirePackage{amsthm} % Mathematical environments
\RequirePackage{thmtools} % Theorem styles
-\ifkaotheorems@framed%
- \RequirePackage{tikz} % Colorful boxes
- \RequirePackage[framemethod=TikZ]{mdframed}
+%----------------------------------------------------------------------------------------
+% STYLE DEFINITIONS
+%----------------------------------------------------------------------------------------
- % 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,
- }
+\ifkaotheorems@framed% Define the style of the mdframed boxes for theorems
+ \RequirePackage[most]{tcolorbox}
- % Theorem styles
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,%\scshape,
- %notefont=\normalfont, notebraces={ (}{)},
- bodyfont=\normalfont\itshape,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- %postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- ]{kaoplain}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,%\scshape,
- %notefont=\normalfont, notebraces={ (}{)},
- bodyfont=\normalfont\itshape,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- ]{kaodefinition}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,%\scshape,
- %notefont=\normalfont, notebraces={ (}{)},
- bodyfont=\normalfont\itshape,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- ]{kaoassumption}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\normalfont,
- %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoremark}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\normalfont,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoexample}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\small,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoexercise}
+ % Box style
+ \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,
+ }}
- \theoremstyle{kaoplain}
- \declaretheorem[
- name=Theorem,
- style=kaoplain,
- %refname={theorem,theorems},
- refname={Theorem,Theorems},
- Refname={Theorem,Theorems},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@theorembackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{theorem}
- \declaretheorem[
- name=Proposition,
- %refname={proposition,propositions},
- refname={Proposition,Propositions},
- Refname={Proposition,Propositions},
- sibling=theorem,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@propositionbackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{proposition}
- \declaretheorem[
- name=Lemma,
- %refname={lemma,lemmas},
- refname={Lemma,Lemmas},
- Refname={Lemma,Lemmas},
- sibling=theorem,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@lemmabackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{lemma}
- \declaretheorem[
- name=Corollary,
- %refname={corollary,corollaries},
- refname={Corollary,Corollaries},
- Refname={Corollary,Corollaries},
- sibling=theorem,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@corollarybackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{corollary}
+ % Theorem styles
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaoplain}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaodefinition}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaoassumption}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\normalfont,
+ %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoremark}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\normalfont,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoexample}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\small,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoexercise}
- \theoremstyle{kaodefinition}
- \declaretheorem[
- name=Definition,
- %refname={definition,definitions},
- refname={Definition,Definitions},
- Refname={Definition,Definitions},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@definitionbackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{definition}
+ % Theorems using the 'kaoplain' style
+ \theoremstyle{kaoplain}
+ \declaretheorem[
+ name=Theorem,
+ style=kaoplain,
+ %refname={theorem,theorems},
+ refname={Theorem,Theorems},
+ Refname={Theorem,Theorems},
+ numberwithin=section,
+ ]{theorem}
+ \tcolorboxenvironment{theorem}{
+ colback=\kaotheorems@theorembackground,tcbkao
+ }
+ \declaretheorem[
+ name=Proposition,
+ %refname={proposition,propositions},
+ refname={Proposition,Propositions},
+ Refname={Proposition,Propositions},
+ sibling=theorem,
+ ]{proposition}
+ \tcolorboxenvironment{proposition}{
+ colback=\kaotheorems@propositionbackground,tcbkao
+ }
+ \declaretheorem[
+ name=Lemma,
+ %refname={lemma,lemmas},
+ refname={Lemma,Lemmas},
+ Refname={Lemma,Lemmas},
+ sibling=theorem,
+ ]{lemma}
+ \tcolorboxenvironment{lemma}{
+ colback=\kaotheorems@lemmabackground,tcbkao
+ }
+ \declaretheorem[
+ name=Corollary,
+ %refname={corollary,corollaries},
+ refname={Corollary,Corollaries},
+ Refname={Corollary,Corollaries},
+ sibling=theorem,
+ ]{corollary}
+ \tcolorboxenvironment{corollary}{
+ colback=\kaotheorems@corollarybackground,tcbkao
+ }
- \theoremstyle{kaoassumption}
- \declaretheorem[
- name=Assumption,
- %refname={assumption,assumptions},
- refname={Assumption,Assumptions},
- Refname={Assumption,Assumptions},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@assumptionbackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{assumption}
+ % Theorems using the 'kaodefinition' style
+ \theoremstyle{kaodefinition}
+ \declaretheorem[
+ name=Definition,
+ %refname={definition,definitions},
+ refname={Definition,Definitions},
+ Refname={Definition,Definitions},
+ numberwithin=section,
+ ]{definition}
+ \tcolorboxenvironment{definition}{
+ colback=\kaotheorems@definitionbackground,tcbkao
+ }
- \theoremstyle{kaoremark}
- \declaretheorem[
- name=Remark,
- %refname={remark,remarks},
- refname={Remark,Remarks},
- Refname={Remark,Remarks},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@remarkbackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{remark}
+ % Theorems using the 'kaoassumption' style
+ \theoremstyle{kaoassumption}
+ \declaretheorem[
+ name=Assumption,
+ %refname={assumption,assumptions},
+ refname={Assumption,Assumptions},
+ Refname={Assumption,Assumptions},
+ numberwithin=section,
+ ]{assumption}
+ \tcolorboxenvironment{assumption}{
+ colback=\kaotheorems@assumptionbackground,tcbkao
+ }
- \theoremstyle{kaoexample}
- \declaretheorem[
- name=Example,
- %refname={example,examples},
- refname={Example,Examples},
- Refname={Example,Examples},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@examplebackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{example}
+ % Theorems using the 'kaoremark' style
+ \theoremstyle{kaoremark}
+ \declaretheorem[
+ name=Remark,
+ %refname={remark,remarks},
+ refname={Remark,Remarks},
+ Refname={Remark,Remarks},
+ numberwithin=section,
+ ]{remark}
+ \tcolorboxenvironment{remark}{
+ colback=\kaotheorems@remarkbackground,tcbkao
+ }
- \theoremstyle{kaoexercise}
- \declaretheorem[
- name=Exercise,
- %refname={example,examples},
- refname={Exercise,Exercises},
- Refname={Exercise,Exercises},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\kaotheorems@exercisebackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{exercise}
+ % Theorems using the 'kaoexample' style
+ \theoremstyle{kaoexample}
+ \declaretheorem[
+ name=Example,
+ %refname={example,examples},
+ refname={Example,Examples},
+ Refname={Example,Examples},
+ numberwithin=section,
+ ]{example}
+ \tcolorboxenvironment{example}{
+ colback=\kaotheorems@examplebackground,tcbkao
+ }
- %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
- %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
- %\renewcommand{\qedsymbol}{$\blacksquare$}
-\else
+ % Theorems using the 'kaoexercise' style
+ \theoremstyle{kaoexercise}
+ \declaretheorem[
+ name=Exercise,
+ %refname={exercise,exercises},
+ refname={Exercise,Exercises},
+ Refname={Exercise,Exercises},
+ numberwithin=section,
+ ]{exercise}
+ \tcolorboxenvironment{exercise}{
+ colback=\kaotheorems@exercisebackground,tcbkao
+ }
- % Theorem styles
- \declaretheoremstyle[
- spaceabove=.6\thm@preskip,
- spacebelow=.1\thm@postskip,
- %headfont=\normalfont\bfseries,%\scshape,
- %notefont=\normalfont, notebraces={ (}{)},
- bodyfont=\normalfont\itshape,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- %postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- ]{kaoplain}
- \declaretheoremstyle[
- spaceabove=.6\thm@preskip,
- spacebelow=.1\thm@postskip,
- %headfont=\normalfont\bfseries,%\scshape,
- %notefont=\normalfont, notebraces={ (}{)},
- bodyfont=\normalfont\itshape,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- %postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- ]{kaodefinition}
- \declaretheoremstyle[
- spaceabove=.6\thm@preskip,
- spacebelow=.1\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\normalfont,
- %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- %postheadspace={.5em plus .1em minus .1em},
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoremark}
- \declaretheoremstyle[
- spaceabove=.6\thm@preskip,
- spacebelow=.1\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\normalfont,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- %postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoexample}
- \declaretheoremstyle[
- %spaceabove=.5\thm@preskip,
- %spacebelow=.5\thm@postskip,
- %headfont=\normalfont\bfseries,
- %notefont=\normalfont, notebraces={ (}{)},
- %bodyfont=\normalfont,
- %headformat={\NAME\space\NUMBER\space\NOTE},
- headpunct={},
- postheadspace={.5em plus .1em minus .1em},
- %prefoothook={\hfill\qedsymbol}
- %refname={theorem,theorems},
- %Refname={Theorem,Theorems},
- ]{kaoexercise}
+ %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
+ %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
+ %\renewcommand{\qedsymbol}{$\blacksquare$}
+\else % If not using mdframed
+ % Theorem styles
+ \declaretheoremstyle[
+ spaceabove=.6\thm@preskip,
+ spacebelow=.1\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaoplain}
+ \declaretheoremstyle[
+ spaceabove=.6\thm@preskip,
+ spacebelow=.1\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaodefinition}
+ \declaretheoremstyle[
+ spaceabove=.6\thm@preskip,
+ spacebelow=.1\thm@postskip,
+ %headfont=\normalfont\bfseries,%\scshape,
+ %notefont=\normalfont, notebraces={ (}{)},
+ bodyfont=\normalfont\itshape,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ ]{kaoassumption}
+ \declaretheoremstyle[
+ spaceabove=.6\thm@preskip,
+ spacebelow=.1\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\normalfont,
+ %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoremark}
+ \declaretheoremstyle[
+ spaceabove=.6\thm@preskip,
+ spacebelow=.1\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\normalfont,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ %postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoexample}
+ \declaretheoremstyle[
+ %spaceabove=.5\thm@preskip,
+ %spacebelow=.5\thm@postskip,
+ %headfont=\normalfont\bfseries,
+ %notefont=\normalfont, notebraces={ (}{)},
+ %bodyfont=\normalfont,
+ %headformat={\NAME\space\NUMBER\space\NOTE},
+ headpunct={},
+ postheadspace={.5em plus .1em minus .1em},
+ %prefoothook={\hfill\qedsymbol}
+ %refname={theorem,theorems},
+ %Refname={Theorem,Theorems},
+ ]{kaoexercise}
- \theoremstyle{kaoplain}
- \declaretheorem[
- name=Theorem,
- refname={theorem,theorems},
- Refname={Theorem,Theorems},
- numberwithin=section,
- ]{theorem}
- \declaretheorem[
- name=Proposition,
- refname={proposition,propositions},
- Refname={Proposition,Propositions},
- sibling=theorem,
- ]{proposition}
- \declaretheorem[
- name=Lemma,
- refname={lemma,lemmas},
- Refname={Lemma,Lemmas},
- sibling=theorem,
- ]{lemma}
- \declaretheorem[
- name=Corollary,
- refname={corollary,corollaries},
- Refname={Corollary,Corollaries},
- sibling=theorem,
- ]{corollary}
+ % Theorems using the 'kaoplain' style
+ \theoremstyle{kaoplain}
+ \declaretheorem[
+ name=Theorem,
+ refname={Theorem,Theorems},
+ Refname={Theorem,Theorems},
+ numberwithin=section,
+ ]{theorem}
+ \declaretheorem[
+ name=Proposition,
+ refname={Proposition,Propositions},
+ Refname={Proposition,Propositions},
+ sibling=theorem,
+ ]{proposition}
+ \declaretheorem[
+ name=Lemma,
+ refname={Lemma,Lemmas},
+ Refname={Lemma,Lemmas},
+ sibling=theorem,
+ ]{lemma}
+ \declaretheorem[
+ name=Corollary,
+ refname={Corollary,Corollaries},
+ Refname={Corollary,Corollaries},
+ sibling=theorem,
+ ]{corollary}
- \theoremstyle{kaodefinition}
- \declaretheorem[
- name=Definition,
- refname={definition,definitions},
- Refname={Definition,Definitions},
- numberwithin=section,
- ]{definition}
+ % Theorems using the 'kaodefinition' style
+ \theoremstyle{kaodefinition}
+ \declaretheorem[
+ name=Definition,
+ refname={Definition,Definitions},
+ Refname={Definition,Definitions},
+ numberwithin=section,
+ ]{definition}
+
+ % Theorems using the 'kaoassumption' style
+ \theoremstyle{kaoassumption}
+ \declaretheorem[
+ name=Assumption,
+ refname={Assumption,Assumptions},
+ Refname={Assumption,Assumptions},
+ numberwithin=section,
+ ]{assumption}
- \theoremstyle{kaoremark}
- \declaretheorem[
- name=Remark,
- refname={remark,remarks},
- Refname={Remark,Remarks},
- numberwithin=section,
- ]{remark}
+ % Theorems using the 'kaoremark' style
+ \theoremstyle{kaoremark}
+ \declaretheorem[
+ name=Remark,
+ refname={Remark,Remarks},
+ Refname={Remark,Remarks},
+ numberwithin=section,
+ ]{remark}
- \theoremstyle{kaoexample}
- \declaretheorem[
- name=Example,
- refname={example,examples},
- Refname={Example,Examples},
- numberwithin=section,
- ]{example}
+ % Theorems using the 'kaoexample' style
+ \theoremstyle{kaoexample}
+ \declaretheorem[
+ name=Example,
+ refname={Example,Examples},
+ Refname={Example,Examples},
+ numberwithin=section,
+ ]{example}
- \theoremstyle{kaoexercise}
- \declaretheorem[
- name=Exercise,
- %refname={example,examples},
- refname={Exercise,Exercises},
- Refname={Exercise,Exercises},
- numberwithin=section,
- mdframed={
- style=mdfkao,
- backgroundcolor=\@exercisebackground,
- %frametitlebackgroundcolor=\@theorembackground,
- },
- ]{exercise}
+ % Theorems using the 'kaoexercise' style
+ \theoremstyle{kaoexercise}
+ \declaretheorem[
+ name=Exercise,
+ refname={Exercise,Exercises},
+ Refname={Exercise,Exercises},
+ numberwithin=section,
+ ]{exercise}
- %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
- %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
- %\renewcommand{\qedsymbol}{$\blacksquare$}
+ %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
+ %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
+ %\renewcommand{\qedsymbol}{$\blacksquare$}
\fi