Example and Documentation of The Class: Kaobook
Example and Documentation of The Class: Kaobook
Federico Marotta ∗
An Awesome Publisher
∗ A LAT X lover
E
The kaobook class
Disclaimer
You can edit this page to suit your needs. For instance, here we have a no copyright state-
ment, a colophon and some other information. This page is based on the corresponding
page of Ken Arroyo Ohori’s thesis, with minimal changes.
No copyright
c z This book is released into the public domain using the CC0 code. To the extent
possible under law, I waive all copyright and related or neighbouring rights to this work.
To view a copy of the CC0 code, visit:
http://creativecommons.org/publicdomain/zero/1.0/
Colophon
This document was typeset with the help of KOMA-Script and LATEX using the kaobook
class.
The source code of this book is available at:
https://github.com/fmarotta/kaobook
(You are welcome to contribute!)
Publisher
First printed in May 2019 by An Awesome Publisher
The harmony of the world is made manifest in Form and
Number, and the heart and soul and all the poetry of
Natural Philosophy are embodied in the concept of
mathematical beauty.
I am of the opinion that every LATEX geek, at least once during his life, feels the need to
create his or her own class: this is what happened to me and here is the result, which,
however, should be seen as a work still in progress. Actually, this class is not completely
original, but it is a blend of all the best ideas that I have found in a number of guides,
tutorials, blogs and tex.stackexchange.com posts. In particular, the main ideas come from
two sources:
I Ken Arroyo Ohori’s Doctoral Thesis, which served, with the author’s permission,
as a backbone for the implementation of this class;
I The Tufte-Latex Class, which was a model for the style.
The first chapter of this book is introductory and covers the most essential features of the
class. Next, there is a bunch of chapters devoted to all the commands and environments
that you may use in writing a book; in particular, it will be explained how to add notes,
figures and tables, and references. The second part deals with the page layout and design,
as well as additional features like coloured boxes and theorem environments.
I started writing this class as an experiment, and as such it should be regarded. Since it
has always been intended for my personal use, it may not be perfect but I find it quite
satisfactory for the use I want to make of it. I share this work in the hope that someone
might find here the inspiration for writing his or her own class.
Federico Marotta
Contents
Preface v
1 Introduction 1
1.1 The Main Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What This Class Does . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 What This Class Does Not Do . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 How to Use This Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Margin Stuff 7
3.1 Sidenotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Marginnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 Margintoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 Marginlisting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 References 15
5.1 Citations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Glossaries and Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Hyperreferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.4 A Final Note on Compilation . . . . . . . . . . . . . . . . . . . . . . . . . 18
Appendix 28
A Heading on Level 0 (chapter) 29
A.1 Heading on Level 1 (section) . . . . . . . . . . . . . . . . . . . . . . . . . 29
Heading on Level 2 (subsection) . . . . . . . . . . . . . . . . . . . . . . . 29
A.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Example for list (itemize) . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Example for list (enumerate) . . . . . . . . . . . . . . . . . . . . . . . . . 30
Example for list (description) . . . . . . . . . . . . . . . . . . . . . . . . . 31
B Fonts Testing 32
B.1 Font Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
B.2 Font Families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Bibliography 34
List of Figures
List of Tables
The kaobook class focuses more about the document structure than about
the style. Indeed, it is a well-known LATEX principle that structure and
style should be separated as much as possible (see also Section Section 1.3
on the following page). This means that this class will only provide
commands, environments and in general, the opportunity to do things,
which the user may or may not use. Actually, some stylistic matters are
embedded in the class, but the user is able to customise them with ease.
The main features are the following:
Page Layout The text width is reduced to improve readability and make
space for the margins, where any sort of elements can be displayed.
Chapter Headings As opposed to Tufte-Latex, we provide a variety of
chapter headings among which to choose; examples will be seen in
later chapters.
1 Introduction 2
Page Headers They span the whole page, margins included, and, in
twoside mode, display alternatively the chapter and the section
name.2 2: This is another departure from Tufte’s
Matters The commands \frontmatter, \mainmatter and \backmatter design.
have been redefined in order to have automatically wide margins in
the main matter, and narrow margins in the front and back matters.
However, the page style can be changed at any moment, even in
the middle of the document.
Margin text We provide commands \sidenote and \marginnote to put
text in the margins.3 3: Sidenotes (like this!) are numbered
Margin figs/tabs A couple of useful environments is marginfigure and while marginnotes are not
margintable, which, not surprisingly, allow you to put figures and
tables in the margins (cfr. Figure 1.1).
Margin toc Finally, since we have wide margins, why don’t add a little
table of contents in them? See \margintoc for that.
Hyperref hyperref is loaded and by default we try to add bookmarks in
a sensible way; in particular, the bookmarks levels are automatically
reset at \appendix and \backmatter. Moreover, we also provide a
small package to ease the hyperreferencing of other parts of the
text.
Bibliography We want the reader to be able to know what has been
cited without having to go to the end of the document every time,
so citations go in the margins as well as at the end, as in Tufte-Latex.
Unlike that class, however, you are free to customise the citations
as you wish.
The order of the title pages, table of contents and preface can be easily
changed, as in any LATEX document. In addition, the class is based on
KOMA-Script’s scrbook, therefore it inherits all the goodies of that.
that they are endowed with a counter, floating and can be put in a
special table of contents.4 4: See Chapter Chapter 7 on page 25 for
theorems.sty The style of mathematical environments. Actually, there some examples.
are two such packages: one is for plain theorems, i. e. the theorems
are printed in plain text; the other uses mdframed to draw a box
around theorems. You can plug the most appropriate style into its
document.
In the rest of the book, I shall assume that the reader is not a novice in The audacious users might feel tempted
the use of LATEX, and refer to the documentation of the packages used in to edit some of these packages. I’d be im-
mensely happy if they sent me examples
this class for things that are already explained there. Moreover, I assume of what they have been able to do!
that the reader is willing to make minor edits to the provided packages
for styles, environments and commands, if he or she does not like the
default settings.
Either if you are using the template from latextemplates, or if you cloned
the GitHub repository, there are infinite ways to use the kaobook class
in practice, but we will discuss only two of them. The first is to find the
main.tex file which I used to write this book, and edit it; this will probably
involve a lot of text-deleting, copying-and-pasting, and rewriting. The
second way is to start almost from scratch and use the skeleton.tex file,
which is a cleaned-up version of the main.tex; even if you choose the
second way, you may find it useful to draw inspiration from the main.tex
file.
To compile the document, assuming that its name is main.tex, you will
have to run the following sequence of commands:
pdflatex main # Compile template
makeindex main.nlo -s nomencl.ist -o main.nls # Compile nomenclature
makeindex main # Compile index
biber main # Compile bibliography
makeglossaries main # Compile glossary
pdflatex main # Compile template again
pdflatex main # Compile template again
You may need to compile the template some more times in order for
some errors to disappear. For any support requests, please ask a question
on tex.stackexchange.org with the tag ‘kaobook’, open an issue on
GitHub, or contact the author via e-mail.
Class Options, Commands and
Environments
Class Options 2
In this chapter I will describe the most common options used, both the 2.1 KOMA Options . . . . . . . . . 5
ones inherited from scrbook and the kao-specific ones. Options passed 2.2 kao Options . . . . . . . . . . 5
to the class modifies its default behaviour; beware though that some 2.3 Other Things Worth Know-
options may lead to unexpected results. . . ing . . . . . . . . . . . . . . . 5
2.4 Document Structure . . . . . 6
In the future I plan to add more options to set the paragraph formatting
(justified or ragged) and the position of the margins (inner or outer in
twoside mode, left or right in oneside mode).3 3: As of now, paragraphs are justified, for-
matted with \singlespacing (from the
I take this opportunity to renew the call for help: everyone is encouraged setspace package) and \frenchspacing.
to add features or reimplement existing ones, and to send me the results.
You can find the GitHub repository at https://github.com/fmarotta/
kaobook.
To Do
Implement the justified and margin options. To be consistent with
the KOMA-Script style, they should accept a simple switch as a
parameter, where the simple switch should be true or false, or one
of the other standard values for simple switches supported by KOMA-
Script. See the KOMA-Script documentation for further information.
A bunch of packages are already loaded in the class because they are
needed for the implementation. These include:
2 Class Options 6
I etoolbox
I calc
I xifthen
I xkeyval
I xparse
I xstring
Many more packages are loaded, but they will be discussed in due time.
Here, we will mention only one more set of packages, needed to change
the paragraph formatting (recall that in the future there will be options
to change this). In particular, the packages we load are:
I ragged2e
I setspace
I hyphenat
I microtype
I needspace
I xspace
I xcolor (with options usenames,dvipsnames)
3.1 Sidenotes
Sidenotes are like footnotes, except that they go in the margin, where
they are more readable. To insert a sidenote, just use the command
\sidenote{Text of the note}. You can specify a markO with O: This sidenote has a special mark, a big
\sidenote[mark]{Text}, but you can also specify an offset, which moves O!
If you use an offset, you always have to add the brackets for the mark,
but they can be empty.1 1: If you want to know more about the us-
age of the \sidenote command, read the
In kaobook we copied a feature from the snotez package: the possibility documentation of the sidenotes package.
to specify a multiple of \baselineskip as an offset. For example, if you
want to enter a sidenote with the normal mark and move it upwards one
line, type:
\sidenote[][*-1]{Text of the sidenote.}
3.2 Marginnotes
This command is very similar to the previous one. You can create a margin- While the command for margin notes
comes from the marginnote package, it
note with \marginnote[offset]{Text}, where the offset argument can has been redefined in order to change the
be left out, or it can be a multiple of \baselineskip, e. g. position of the optional offset argument,
which now precedes the text of the note,
\marginnote[-12pt]{Text} or \marginnote[*-3]{Text} whereas in the original version it was at
the end. We have also added the possi-
bility to use a multiple of \baselineskip
To Do as offset. These things were made only to
A small thing that needs to be done is to renew the \sidenote make everything more consistent, so that
you have to remember less things!
command so that it takes only one optional argument, the offset. The
special mark argument can go somewhere else. In other words, we
want the syntax of \sidenote to resemble that of \marginnote.
3.3 Footnotes
Even though they are not displayed in the margin, we will discuss about
footnotes here, since sidenotes are mainly intended to be a replacement
of them. Footnotes force the reader to constantly move from one area
of the page to the other. Arguably, marginnotes solve this issue, so you
should not use footnotes. Nevertheless, for completeness, we have left the
standard command \footnote, just in case you want to put a footnote
once in a while.∗
3.4 Margintoc
3.5 Marginlisting
On some occasions it may happen that you have a very short piece of
code that doesn’t look good in the body of the text because it breaks the
flow of narration: for that occasions, you can use a marginlisting. The Listing 3.1: An example of a margin list-
support for this feature is still limited, especially for the captions, but ing.
you can try the following code: print("Hello World!")
\begin{marginlisting}[-0.5cm]
\caption{My caption}
\vspace{0.2cm}
\begin{lstlisting}[language=Python,style=kaolstplain]
... code ...
\end{lstlisting}
∗ And this is how they look like. Notice that in the PDF file there is a back reference to the
text; pretty cool, uh?
3 Margin Stuff 9
\end{marginlisting}
Unfortunately, the space between the caption and the listing must be
adjusted manually; if you find a better way, please let me know.
Not only textual stuff can be displayed in the margin, but also figures.
Those will be the focus of the next chapter.
4 Figures and Tables
Figures and tables can be inserted just like in any standard LATEX document. 4.3 Wide Figures and Tables . . 12
The graphicx package is already loaded and configured in such a way
that the figure width is equal to the textwidth and the height is adjusted
in order to maintain the original aspect ratio. As you may have imagined,
the captions will be positioned. . . well, in the margins. This is achieved
with the help of the floatrow package.
Here is a picture of Mona Lisa (Figure 4.1), as an example. The captions
are formatted as the margin- and the side-notes; If you want to change
something about captions you can use the command \captsetup from
the caption package. Remember that if you want to reference a figure,
the label must come after the caption!
The credits for the image above the chapter title go to: Bushra Feroz, CC BY-SA 4.0,
https://commons.wikimedia.org/w/index.php?curid=68724647
4 Figures and Tables 11
I don’t have much else to say, so I will just insert some blind text. Hello,
here is some text without a meaning. This text should show what a
printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
With the environments figure* and table* you can insert figures which
span the whole page width. For example, here are a wide figure and a
wide table.
Figure 4.2: A wide seaside, and a wide caption. Credits: By Bushra Feroz, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?
curid=68724647
Table 4.3: A wide table with invented data about three people living in the UK. Note that wide figures and tables are centered and their
caption also extends into the margin.
You may have noticed the full width image at the very beginning of this
chapter: that, however, is set up in an entirely different way, which you’ll
read about in Chapter Chapter 6 on page 20.
kaobook also supports paginated tables (have a look at the longtable
package). The longtable1 environment behaves a bit differently from 1: Interestingly, longtables may require
table, in that longtable encompasses both table and tabular, so that up to four rounds of compilation before
they are typeset correctly.
you can write, e. g.,
To cite someone [1, 2] is very simple: just use the \sidecite command. It [1]: Visscher et al. (2008), ‘Heritability in
does not have an offset argument yet, but it probably will in the future. the genomics era–concepts and miscon-
ceptions.’
This command supports multiple entries, as you can see, and by default it [2]: James et al. (2013), An Introduction to
prints the reference on the margin as well as adding it to the bibliography Statistical Learning
at the end of the document. Note that the citations have nothing to do
with the text,[2] but they are completely random as they only serve the [2]: James et al. (2013), An Introduction to
purpose to illustrate the feature. Statistical Learning
For this setup I wrote a separate package, kaobiblio, which you can find
in the styles directory and include in your main tex file. This package
accepts all the options that you can pass to biblatex, and actually it
passes them to biblatex under the hood. Moreover, it also defines some
commands, like \sidecite, and environments that can be used within a
kao book.1 1: For this reason you should always use
kaobiblio instead of biblatex, but the
If you want to use bibtex instead of biblatex, pass the option backend=bibtex syntax and the options are exactly the
same.
to kaobiblio.
As you have seen, the \sidecite command will print a citation in the
margin. However, this command would be useless without a way to
customise the format of the citation, so the kaobook provides also the
\formatmargincitation command. By ‘renewing’ that command, you
can choose which items will be printed in the margins. The best way to
understand how it works is to see the actual definition of this command.
\newcommand{\formatmargincitation}[1]{%
\parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}%
}
The above code results in citations that look like the following.[4] Of 2005, Zou et al.: ‘Regularization and vari-
course, changing the format is most useful when you also change the able selection via the elastic-net’; very in-
teresting!
default bibliography style. For instance, if you want to use the ‘philosophy-
modern’ style for your bibliography, you might have something like this
in the preamble:
\usepackage[style=philosophy-modern]{styles/kaobiblio}
\renewcommand{\formatmargincitation}[1]{%
\sdcite{#1}%
}
\addbibresource{main.bib}
5 References 16
The commands like \citeyear, \parencite and \sdcite are just exam-
ples. A full reference of the available commands can be found in this
cheatsheet, under the ‘Citations’ section.
Finally, to compile a document containing citations, you need to use an
external tool, which for this class is biber. You need to run the following
(assuming that your tex file is called main.tex):
$ pdflatex main
$ biber main
$ pdflatex main
The kaobook class loads the packages glossaries and imakeidx, with
which you can add glossaries and indices to your book. For instance, I
previously defined some glossary entries and now I am going to use
them, like this: computer. glossaries also allows you to use acronyms,
like the following: this is the full version, Frame per Second (FPS), and
this is the short one FPS. These entries will appear in the glossary in the
backmatter.
Unless you use Overleaf or some other fancy IDE for LATEX, you need
to run an external command from your terminal in order to compile a
document with a glossary. In particular, the commands required are:2 2: These are the commands you would
run in a UNIX system, but see also Section
$ pdflatex main 5.4 (A Final Note on Compilation); I have
$ makeglossaries main no idea about how it works in Windows.
$ pdflatex main
Note that you need not run makeglossaries every time you compile
your document, but only when you change the glossary entries.
To create an index, you need to insert the command \index{subject}
whenever you are talking about ‘subject’ in the text. For instance, at the
start of this paragraph I would write index{index}, and an entry would
be added to the Index in the backmatter. Check it out!
A nomenclature is just a special kind of index; you can find one at the In theory, you would need to run an ex-
end of this book. To insert a nomenclature, we use the package nomencl ternal command for the index as well,
but luckily the package we suggested,
and add the terms with the command \nomenclature. We put then a imakeidx, can compile the index automat-
\printnomenclature where we want it to appear. ically.
These packages are all loaded in packages.sty, one of the files that come
with this class. However, the configuration of the elements is best done in
the main.tex file, since each book will have different entries and styles.
Note that the nomencl package caused problems when the document was This brief section was by no means a com-
plete reference on the subject, therefore
compiled, so, to make a long story short, I had to prevent scrhack to load you should consult the documentation of
the hack-file for nomencl. When compiling the document on Overleaf, the above package to gain a full under-
however, this problem seem to vanish. standing of how they work.
5 References 17
5.3 Hyperreferences
Together with this class we provide a handy package to help you ref-
erencing the same elements always in the same way, for consistency
across the book. First, you can label each element with a specific com-
mand. For instance, should you want to label a chapter, you would
put \labch{chapter-title} right after the \chapter directive. This is
just a convenience, because \labch is actually just an alias to \label{ch:
chapter-title}, so it spares you the writing of ‘ch:’. We defined similar
commands for many typically labeled elements, including:
The full style references everything. You can use it with \frefch{chapter-
title} and it looks like this: Chapter 5 (References) on page 15.
Of course, all the other elements have similar commands (e. g. for parts
you would use \vrefpart{part-title} or something like that). However,
not all elements implement all the four styles. The commands provided
should be enough, but if you want to see what is available or to add the
missing ones, have a look at the attached package.
In order to have access to all these features, the kaorefs should be loaded
in the preamble of your document. It should be loaded last, or at least after
babel (or polyglossia) and plaintheorems (or mdftheorems). Options
can be passed to it like to any other package; in particular, it is possible to
specify the language of the captions. For instance, if you specify ‘italian’
as an option, instead of ‘Chapter’ it will be printed ‘Capitolo’, the Italian
analog. If you know other languages, you are welcome to contribute the
translations of these captions! Feel free to contact the author of the class
for further details.
5 References 18
Probably the easiest way to compile a latex document is with the latexmk
script, as it can take care of everything, if properly configured, from the
bibliography to the glossary. The command to issue, in general, is:
1 latexmk [latexmk_options] [filename ...]
6.1 Headings . . . . . . . . . . . . 20
6.1 Headings
6.2 Headers & Footers . . . . . . 21
So far, in this document I used two different styles for the chapter headings: 6.3 Table of Contents . . . . . . 21
one has the chapter name, a rule and, in the margin, the chapter number; 6.4 Paper Size . . . . . . . . . . . 22
the other has an image at the top of the page, and the chapter title is 6.5 Page Layout . . . . . . . . . . 22
printed in a box (like for this chapter). There is one additional style, 6.6 Numbers & Counters . . . . 23
which I used only in the appendix (on page ??page:appendix); there, the 6.7 White Space . . . . . . . . . . 24
chapter title is enclosed in two horizontal rules, and the chapter number
(or letter, in the case of the appendix) is above it.1 1: To be honest, I do not think that mixing
heading styles like this is a wise choice,
Every book is unique, so it makes sense to have different styles from but in this document I did it only to show
which to choose. Actually, it would be awesome if whenever a kao-user you how they look.
designs a new heading style, he or she added it to the three styles already
present, so that it will be available for new users and new books.
The choice of the style is made simple by the \setchapterstyle com-
mand. It accepts one option, the name of the style, which can be: ‘plain’,
‘kao’, or ‘lines’.2 If instead you want the image style, you have to use the 2: Plain is the default LATEX title style; the
command \setchapterimage, which accepts the path to the image as other ones are self explanatory.
In Line 1 I choose the style for the title to be ‘kao’. Then, I specify that
I want the margin toc. The rest is ordinary administration in LATEX,
except that I use my own \labch to label the chapter. Actually, the
\setchapterpreamble is a standard KOMA - Script one, so I invite you to
read about it in the KOMA documentation. Once the chapter style is set, 3: The \margintoc has to be specified at
every chapter. Perhaps in the future this
it holds until you change it.3 Whenever I want to start a chapter with an may change; it all depends on how this
image, I simply write: feature will be welcomed by the users, so
keep in touch with me if you have prefer-
ences!
6 Page Design 21
If you prefer, you can also specify the style at the beginning of the main
document, and that style will hold until you change it again.
To Do
The twoside class option is still unstable and may lead to unexpected
behaviours. As always, any help will be greatly appreciated.
Of course, some packages, like those for glossaries and indices, will try to
add their own entries. In such cases, you have to follow the instructions In a later section, we will see how you
specific to that package. Here, since we have talked about glossaries and can define your own floating environment,
and endow it with an entry in the TOC.
notations in Chapter 5, we will briefly see how to configure them.
For the glossaries package, use the ‘toc’ option when you load it:
For nomencl, pass the ‘intoc’ option at
\usepackage[toc]{glossaries}.
the moment of loading the package. Both glossaries and nomencl are
loaded in the attached ‘packages’ package.
Additional configuration of the table of contents can be performed
through the packages etoc, which is loaded because it is needed for
the margintocs, or the more traditional tocbase. Read the respective 5: (And please, send me a copy of what
documentations if you want to be able to change the default TOC style.5 you have done, I’m so curious!)
Recent versions of Kaobook support paper sizes different from the default
A4. It is possible to pass the name of the paper as an option to the class,
as we are accustomed for any other LATEX class. For example, the class Table 6.2: Some non-standard paper sizes
supported by kaobook.
option b5paper would set the paper size to the B5 format.
We also support the paper sizes specified in this web page and some Dimension Option name
additional sizes requested by the users, with the option names specified 12.0cm x 19.0cm smallpocketpaper
in Table 6.2. 13.5cm x 21.5cm pocketpaper
For instance, to use the ‘smallpocketpaper’ add the correct description at 14.8cm x 21.0cm a5paper
the beginning of the documentclass instruction: 15.5cm x 22.0cm juvenilepaper
17.0cm x 17.0cm smallphotopaper
1 \documentclass[ 21.0cm x 15.0cm appendixpaper
2 smallpocketpaper,
17.0cm x 22.0cm cookpaper
3 fontsize=10pt,
19.0cm x 27.0cm illustratedpaper
4 twoside=false,
17.0cm x 17.0cm photopaper
5 %open=any,
6 secnumdepth=1,
16.0cm x 24.0cm f24paper
7 ]{kaobook}
Besides the page style, you can also change the width of the content
of a page. This is particularly useful for pages dedicated to part titles,
where having the 1.5-column layout might be a little awkward, or for
pages where you only put figures, where it is important to exploit all the
available space.
In practice, there are two layouts: ‘wide’ and ‘margin’. The former
suppresses the margins and allocates the full page for contents, while
the latter is the layout used in most of the pages of this book, including
this one. The wide layout is also used automatically in the front and back
matters.
Sometimes it is desirable to increase the
To change page layout, use the \pagelayout command. For example, width for just one or a few paragraphs;
the widepar environment does that: wrap
when I start a new part, I write: your paragraphs in this environment, and
they will occupy the full width of the page.
1 \pagelayout{wide}
2 \addpart{Title of the New Part}
3 \pagelayout{margin}
Beyond these two basic layouts, it is also possible to finely tune the page
layout by redefining the \marginlayout command. This command is
called internally by the higher-level \pagelayout, and it is responsible
6 Page Design 23
for setting the width of the margins and of the text. The default definition
is:
1 \newcommand{\marginlayout}{%
2 \newgeometry{
3 top=27.4mm, % height of the top margin
4 bottom=27.4mm, % height of the bottom margin
5 inner=24.8mm, % width of the inner margin
6 textwidth=107mm, % width of the text
7 marginparsep=8.2mm, % width between text and margin
8 marginparwidth=49.4mm, % width of the margin
9 }%
10 }
so if you want to, say, decrease the width of the margin while increasing
the width of the text, you could write in the preamble of your document
something like:
1 \renewcommand{\marginlayout}{%
2 \newgeometry{
3 top=27.4mm, % height of the top margin
4 bottom=27.4mm, % height of the bottom margin
5 inner=24.8mm, % width of the inner margin
6 textwidth=117mm, % width of the text
7 marginparsep=8.2mm, % width between text and margin
8 marginparwidth=39.4mm, % width of the margin
9 }%
10 }
where the text width has been increased by 10mm and the margin width
has been decreased by 10mm.
In this short section we shall see how dispositions, sidenotes and figures
are numbered in the kaobook class.
By default, dispositions are numbered up to the section in kaobook and
up to the subsection in kaohandt. This can be changed by passing the
option secnumdepth tokaobook or kaohandt (e.g. 1 corresponds to section
and 2 corresponds to subsections).
The sidenotes counter is the same across all the document, but if you
want it to reset at each chapter, just uncomment the line
\counterwithin*{sidenote}{chapter}
One of the things that I find most hard in LATEX is to finely tune the white
space around objects. There are not fixed rules, each object needs its
own adjustment. Here we shall see how some spaces are defined at the
moment in this class. Attention! This section may be incomplete.
You can safely ignore the content of the theorems. . . I assume that if
you are interested in having theorems in your book, you already know
something about the classical way to add them. These example should
just showcase all the things you can do within this class.
Proof. The proof is left to the reader as a trivial exercise. Hint: Hello,
here is some text without a meaning. This text should show what a
printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
7 Mathematics and Boxes 26
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
set if, for any 𝑥 ∈ 𝑈 there exists 𝑟 > 0 such that 𝐵(𝑥, 𝑟) ⊂ 𝑈 . We call
the topology associated to d the set 𝜏d of all the open subsets of (𝑋 , 𝑑).
As you may have noticed, definitions, example and remarks have inde-
pendent counters; theorems, propositions, lemmas and corollaries share
the same counter.
∫𝑏
Remark 7.1.2 Here is how an integral looks like inline: 𝑎 𝑥 2 𝑑𝑥 , and
here is the same integral displayed in its own paragraph:
∫ 𝑏
𝑥 2 𝑑𝑥
𝑎
Say you want to insert a special section, an optional content or just 3: Notice that in the table of contents and
something you want to emphasise. We think that nothing works better in the header, the name of this section is
‘Boxes & Environments’; we achieved this
with the optional argument of the section
command.
7 Mathematics and Boxes 27
than a box in these cases. We used mdframed to construct the ones shown
below. You can create and modify such environments by editing the
provided file environments.sty.
If you set up a counter, you can even create your own numbered environ-
ment.
Comment 7.2.1
Hello, here is some text without a meaning. This text should show
what a printed text will look like at this place. If you read this text,
you will get no information. Really? Is there no information? Is there
a difference between this text and some nonsense like “Huardest
gefburn”? Kjift – not at all! A blind text like this gives you information
about the selected font, how the letters are written and an impression
of the look. This text should contain all letters of the alphabet and it
should be written in of the original language. There is no need for
special content, but the length of words should match the language.
7.3 Experiments
It is possible to wrap marginnotes inside boxes, too. Audacious readers title of margin note
are encouraged to try their own experiments and let me know the
outcomes. Margin note inside a kaobox.
(Actually, kaobox inside a margin-
I believe that many other special things are possible with the kaobook note!)
class. During its development, I struggled to keep it as flexible as possible,
so that new features could be added without too great an effort. Therefore,
I hope that you can find the optimal way to express yourselves in writing
a book, report or thesis with this class, and I am eager to see the outcomes
of any experiment that you may try.
Appendix
Heading on Level 0 (chapter)
A
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
A Heading on Level 0 (chapter) 30
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
A.2 Lists
Hello, here is some text without a meaning. This text should show what a
printed text will look like at this place. If you read this text, you will get no
information. Really? Is there no information? Is there a difference between
this text and some nonsense like “Huardest gefburn”? Kjift – not at all! A blind
text like this gives you information about the selected font, how the letters are
written and an impression of the look. This text should contain all letters of the
alphabet and it should be written in of the original language. There is no need
for special content, but the length of words should match the language.
The quick brown fox jumps over the lazy dog. Medium.
The quick brown fox jumps over the lazy dog. Bold.
The quick brown fox jumps over the lazy dog. Upright.
The quick brown fox jumps over the lazy dog. Italics.
The quick brown fox jumps over the lazy dog. Slanted.
B Fonts Testing 33
The quick brown fox jumps over the lazy dog. Small Caps.
The quick brown fox jumps over the lazy dog. Medium.
The quick brown fox jumps over the lazy dog. Bold.
The quick brown fox jumps over the lazy dog. Upright.
The quick brown fox jumps over the lazy dog. Italics.
The quick brown fox jumps over the lazy dog. Slanted.
The quick brown fox jumps over the lazy dog. Small Caps.
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference
between this text and some nonsense like “Huardest gefburn”? Kjift –
not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text
should contain all letters of the alphabet and it should be written in of
the original language. There is no need for special content, but the length
of words should match the language.
The quick brown fox jumps over the lazy dog. Medium.
The quick brown fox jumps over the lazy dog. Bold.
The quick brown fox jumps over the lazy dog. Upright.
The quick brown fox jumps over the lazy dog. Italics.
The quick brown fox jumps over the lazy dog. Slanted.
The quick brown fox jumps over the lazy dog. Small Caps.
Bibliography
[1] Peter M Visscher, William G Hill, and Naomi R Wray. ‘Heritability in the genomics era–concepts and
misconceptions.’ In: Nat. Rev. Genet. 9.4 (2008), pp. 255–266. doi: 10.1038/nrg2322 (cited on page 15).
[2] Gareth James et al. An Introduction to Statistical Learning. 2013 (cited on pages 15, 24).
[3] Alexis Battle et al. ‘Characterizing the genetic basis of transcriptome diversity through RNA-sequencing
of 922 individuals’. In: Genome Res. 24.1 (2014), pp. 14–24. doi: 10.1101/gr.155192.113 (cited on
page 15).
[4] Hui Zou and Trevor Hastie. ‘Regularization and variable selection via the elastic-net’. In: J. R. Stat. Soc.
67.2 (2005), pp. 301–320. doi: 10.1111/j.1467-9868.2005.00503.x (cited on page 15).
Capitals shown are the ones that differ from Roman capitals.