Browse Source

prepare for latextemplates update

pull/184/head
Federico Marotta 3 years ago
parent
commit
d5aee17b37
  1. 3
      CHANGELOG.rst
  2. 24
      examples/documentation/main.tex
  3. BIN
      examples/machine_learning_project/main.pdf
  4. 4
      examples/machine_learning_project/main.tex
  5. BIN
      examples/minimal_book/main.pdf
  6. 86
      kao.sty
  7. 175
      kaobiblio.sty
  8. 19
      kaobook.cls
  9. 47
      kaohandt.cls
  10. 27
      kaorefs.sty
  11. 36
      kaotheorems.sty

3
CHANGELOG.rst

@ -2,8 +2,9 @@
Changelog for package kaobook
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Work in progress
0.9.8 (2021/08/23)
----------------
* Fix some issues
0.9.7 (2021/06/02)
------------------

24
examples/documentation/main.tex

@ -1,3 +1,25 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% EXAMPLE AND DOCUMENTATION OF THE KAOBOOK CLASS
%----------------------------------------------------------------------------------------
@ -25,7 +47,7 @@
\usepackage[english=british]{csquotes} % English quotes
% Load packages for testing
\usepackage{blindtext}
%\usepackage{blindtext} % Uncomment to have the possibility to print text without any meaning for testing purposes
%\usepackage{showframe} % Uncomment to show boxes around the text area, margin, header and footer
%\usepackage{showlabels} % Uncomment to output the content of \label commands to the document where they are used

BIN
examples/machine_learning_project/main.pdf

Binary file not shown.

4
examples/machine_learning_project/main.tex

@ -14,11 +14,11 @@
\usepackage[english=british]{csquotes} % English quotes
% Load the bibliography package
\usepackage{styles/kaobiblio}
\usepackage{kaobiblio}
\addbibresource{main.bib} % Bibliography file
% Load the package for hyperreferences
\usepackage{styles/kaorefs}
\usepackage{kaorefs}
% Set the paths where to look for images
\usepackage{subcaption}

BIN
examples/minimal_book/main.pdf

Binary file not shown.

86
kao.sty

@ -73,6 +73,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}}{}
@ -187,11 +188,11 @@
\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}{%
\newcommand{\recalchead}{% Command to recalculate the header-related length when needed
\setlength{\headtextwidth}{\textwidth}%
\setlength{\headmarginparsep}{\marginparsep}%
\setlength{\headmarginparwidth}{\marginparwidth}%
@ -202,7 +203,7 @@
\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}%
@ -222,7 +223,7 @@
{}%
}
% Style with neither header nor footer (used for special pages)
% Header style with neither header nor footer (used for special pages)
\renewpagestyle{plain.scrheadings}{%
{}%
{}%
@ -233,7 +234,7 @@
{}%
}
% 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}{%
{}%
{}%
@ -244,7 +245,7 @@
{\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}{%
{}%
{}%
@ -397,11 +398,11 @@
}
% Command to detect whether we are inside an mdframed environment
\newif\ifinfloat
\newif\ifinfloat % First, set this flag whenever we are in an mdframed environment...
\AtBeginEnvironment{mdframed}{\infloattrue}
\AtBeginEnvironment{minipage}{\infloattrue}
\def\IfInFloatingEnvir{%
\def\IfInFloatingEnvir{% Then, detect the flag
\ifinfloat%
\expandafter\@firstoftwo%
\else%
@ -427,7 +428,7 @@
}%
}
% 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 +440,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,6 +454,7 @@
\relax%
}%
% Formatting the sidenote text
\RenewDocumentCommand\sidenotetext{ o o +m }{% number, offset, text
\IfNoValueOrEmptyTF{#1}{%
\marginnote[#2]{\thesidenote:\enskip#3}%
@ -823,7 +818,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}
@ -855,7 +850,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
@ -1025,19 +1020,19 @@
\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}
\setmathfont{Libertinus Math} % Libertinus Math font
\ifluatex
\else
\RequirePackage{morewrites} % Fix some errors related to floats
\RequirePackage{morewrites} % Fix some errors related to floats (not necessary with LuaLaTeX
\fi
\else
\RequirePackage[utf8]{inputenc} % utf8 encoding in the input (.tex) file
@ -1104,6 +1099,7 @@
\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}%
@ -1137,6 +1133,7 @@
%\addtokomafont{captionlabel}{\color{Blue}}
%\addtokomafont{pagenumber}{\color{Maroon}}
% Choose the default colors
\hypersetup{
%anchorcolor=Red,
%citecolor=DarkOrange!70!black,
@ -1153,9 +1150,9 @@
% ITEMS
%----------------------------------------------------------------------------------------
\renewcommand{\labelitemi}{\small$\blacktriangleright$}
\renewcommand{\labelitemii}{\textbullet}
\RequirePackage[inline]{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}
@ -1168,6 +1165,7 @@
\RequirePackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
% Define a new style for mdframed boxes
%\mdfsetup{skipabove=\topskip,skipbelow=0pt}
\mdfdefinestyle{kaoboxstyle}{
skipabove=1.5\topskip,
@ -1193,6 +1191,7 @@
%frametitlebackgroundcolor=LightBlue,
}
% Define a new environment using the style created above
\newmdenv[
style=kaoboxstyle,
backgroundcolor=RoyalBlue!25!White,
@ -1203,6 +1202,7 @@
% ENVIRONMENT WITH A COUNTER
%----------------------------------------------------------------------------------------
% Define an environment titled 'Comment' and numbered incrementally
\newenvironment{kaocounter}{
\refstepcounter{kaocounter}
\begin{kaobox}[frametitle=Comment~\thekaocounter\autodot]
@ -1210,6 +1210,7 @@
\end{kaobox}
}
% Define the commands to manage the counter for the 'kaocounter' environment
\newcounter{kaocounter}
\counterwithin{kaocounter}{section}
\newcommand*{\kaocounterformat}{% Format for the caption
@ -1221,23 +1222,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
@ -1252,11 +1255,13 @@
\RequirePackage{listings} % Code
%\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,
@ -1282,6 +1287,7 @@
tabsize=4,
defaultdialect=[LaTeX]Tex,
}
% Define a plain style as well
\lstdefinestyle{kaolstplain}{
aboveskip=0.6\topskip,
belowskip=-0.1\topskip,
@ -1304,7 +1310,7 @@
tabsize=4,
defaultdialect=[LaTeX]Tex,
}
\lstset{style=kaolst}
\lstset{style=kaolst}% Use the fancy style
% Verbatim
%\RequirePackage{fancyvrb} % Customization of verbatim environments

175
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,13 +12,14 @@
\RequirePackage{hyperref} % Required for hyperlinks
\RequirePackage{kvoptions} % Handle package options
% Set up the package options
\SetupKeyvalOptions{
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.
@ -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

19
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}
@ -50,7 +43,6 @@
\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}
@ -108,6 +100,7 @@
% CHAPTER HEADING STYLES
%----------------------------------------------------------------------------------------
% Command to easily switch between chapter styles
\DeclareDocumentCommand{\setchapterstyle}{m}{%
\ifthenelse{\equal{plain}{#1}}{\chapterstyleplain}{}
\ifthenelse{\equal{bar}{#1}}{\chapterstylebar}{}
@ -227,7 +220,7 @@
\setlength{\mtocshift}{0cm}%
}
% By default start with plain style
% By default start with the plain style
\chapterstyleplain
%----------------------------------------------------------------------------------------
@ -251,6 +244,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 +253,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

47
kaohandt.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,23 +25,13 @@
%----------------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{kaohandt}[2021/06/02 v0.9.7 kaohandt]
\ProvidesClass{kaohandt}[2021/08/23 v0.9.8 kaohandt]
\newcommand{\@classname}{kaohandt} % Class name
\newcommand{\@baseclass}{scrartcl} % Base class name
\RequirePackage{kvoptions} % Manage class key-value options
\SetupKeyvalOptions{
family = kao,
prefix = kao@
}
% Set the default options
\PassOptionsToClass{a4paper}{\@baseclass}
% Define kao-specific options
\DeclareStringOption[1]{secnumdepth}
% Pass through any other options to the base class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@baseclass}}
@ -49,7 +39,18 @@
\ProcessOptions\relax % Process the options
\LoadClass{\@baseclass} % Load the base class
\input{kao.sty} % Load the code common to all classes
% Define kao-specific options
\DefineFamily{kao}
\DefineFamilyMember[kaobook]{kao}
\DefineFamilyKey[kaobook]{kao}{secnumdepth}[1]{\setcounter{secnumdepth}{#1}\FamilyKeyStateProcessed}
\FamilyProcessOptions[kaobook]{kao}
\RequirePackage{kao} % Load the code common to all classes
%----------------------------------------------------------------------------------------
% TITLE-RELATED SETTINGS
%----------------------------------------------------------------------------------------
% Left-align title, authors and date
\xpatchcmd{\@maketitle}{\begin{center}}{\begin{flushleft}}{}{}
@ -62,7 +63,7 @@
% Customise the abstract
\RequirePackage[style]{abstract}
\setlength{\absleftindent}{0pt}% No indent
\setlength{\absleftindent}{0pt}% No indentation in the abstract
\if@abstrt
\renewcommand{\abstitlestyle}[1]{%
\vspace{-0.6cm}%
@ -74,6 +75,17 @@
\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}
@ -82,13 +94,6 @@
\PassOptionsToClass{toc=nolistof}{\@baseclass}
\unsettoc{toc}{totoc}
% Set KOMA fonts for elements common to all classes
\addtokomafont{section}{\normalfont\bfseries}
\addtokomafont{subsection}{\normalfont\bfseries}
\addtokomafont{subsubsection}{\normalfont\bfseries}
\addtokomafont{paragraph}{\normalfont\bfseries}
\setkomafont{descriptionlabel}{\normalfont\bfseries}
%----------------------------------------------------------------------------------------
% NUMBERING
%----------------------------------------------------------------------------------------

27
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
@ -16,7 +20,10 @@
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}
% Language-specific strings
%----------------------------------------------------------------------------------------
% LANGUAGE-SPECIFIC STRINGS
%----------------------------------------------------------------------------------------
% #LANGUAGE
\newcommand{\chapternameshort}{}
\newcommand{\sectionname}{}
@ -100,7 +107,10 @@
% 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 +129,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 +204,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

36
kaotheorems.sty

@ -1,13 +1,19 @@
\ProvidesPackage{kaotheorems}
%----------------------------------------------------------------------------------------
% PACKAGE OPTIONS AND DEPENDENCIES
%----------------------------------------------------------------------------------------
\RequirePackage{kvoptions} % Handle package options
\SetupKeyvalOptions{
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,16 +26,20 @@
\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
%----------------------------------------------------------------------------------------
\ifkaotheorems@framed% Define the style of the mdframed boxes for theorems
\RequirePackage{tikz} % Required by mdframed
\RequirePackage[framemethod=TikZ]{mdframed} % Required for colorful boxes
% Box style
\mdfsetup{skipabove=\topskip,skipbelow=0pt}%-.5\topskip}
@ -131,6 +141,7 @@
%Refname={Theorem,Theorems},
]{kaoexercise}
% Theorems using the 'kaoplain' style
\theoremstyle{kaoplain}
\declaretheorem[
name=Theorem,
@ -182,6 +193,7 @@
},
]{corollary}
% Theorems using the 'kaodefinition' style
\theoremstyle{kaodefinition}
\declaretheorem[
name=Definition,
@ -196,6 +208,7 @@
},
]{definition}
% Theorems using the 'kaoassumption' style
\theoremstyle{kaoassumption}
\declaretheorem[
name=Assumption,
@ -210,6 +223,7 @@
},
]{assumption}
% Theorems using the 'kaoremark' style
\theoremstyle{kaoremark}
\declaretheorem[
name=Remark,
@ -224,6 +238,7 @@
},
]{remark}
% Theorems using the 'kaoexample' style
\theoremstyle{kaoexample}
\declaretheorem[
name=Example,
@ -238,6 +253,7 @@
},
]{example}
% Theorems using the 'kaoexercise' style
\theoremstyle{kaoexercise}
\declaretheorem[
name=Exercise,
@ -255,8 +271,7 @@
%\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
%\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
%\renewcommand{\qedsymbol}{$\blacksquare$}
\else
\else % If not using mdframed
% Theorem styles
\declaretheoremstyle[
spaceabove=.6\thm@preskip,
@ -320,6 +335,7 @@
%Refname={Theorem,Theorems},
]{kaoexercise}
% Theorems using the 'kaoplain' style
\theoremstyle{kaoplain}
\declaretheorem[
name=Theorem,
@ -346,6 +362,7 @@
sibling=theorem,
]{corollary}
% Theorems using the 'kaodefinition' style
\theoremstyle{kaodefinition}
\declaretheorem[
name=Definition,
@ -354,6 +371,7 @@
numberwithin=section,
]{definition}
% Theorems using the 'kaoremark' style
\theoremstyle{kaoremark}
\declaretheorem[
name=Remark,
@ -362,6 +380,7 @@
numberwithin=section,
]{remark}
% Theorems using the 'kaoexample' style
\theoremstyle{kaoexample}
\declaretheorem[
name=Example,
@ -370,6 +389,7 @@
numberwithin=section,
]{example}
% Theorems using the 'kaoexercise' style
\theoremstyle{kaoexercise}
\declaretheorem[
name=Exercise,

Loading…
Cancel
Save