├── .github ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── SUPPORT.md └── workflows │ └── verify_examples.yml ├── .gitignore ├── CHANGELOG.rst ├── CODE_OF_CONDUCT.md ├── LICENSE ├── MANIFEST.md ├── README.md ├── example_and_documentation.pdf ├── examples ├── README.md ├── documentation │ ├── chapters │ │ ├── appendix.tex │ │ ├── figsntabs.tex │ │ ├── introduction.tex │ │ ├── layout.tex │ │ ├── mathematics.tex │ │ ├── options.tex │ │ ├── preface.tex │ │ ├── references.tex │ │ └── textnotes.tex │ ├── glossary.tex │ ├── images │ │ ├── monalisa.jpg │ │ └── seaside.jpeg │ ├── main.bib │ ├── main.pdf │ └── main.tex ├── machine_learning_project │ ├── img │ │ ├── bid_expr.png │ │ ├── bid_tba.png │ │ ├── cv.png │ │ ├── cv_example.png │ │ ├── expr_vs_tba.png │ │ ├── nested_cv.png │ │ ├── qq.png │ │ ├── regreg.png │ │ ├── response.png │ │ ├── rho2distr.png │ │ ├── tba_tf.png │ │ └── tigar_article.png │ ├── main.bib │ ├── main.pdf │ ├── main.tex │ └── sections │ │ ├── data.tex │ │ ├── discussion.tex │ │ ├── introduction.tex │ │ └── results.tex ├── minimal_book │ ├── main.pdf │ └── main.tex └── minimal_report │ ├── main.pdf │ └── main.tex ├── instructions ├── README.md ├── latexmk │ └── latexmkrc ├── normal_usage │ └── README.md ├── sharelatex_server │ ├── 1_DockerShareLatexInstallationSHORT.pdf │ ├── 2_DockerSharelatexLONG.txt │ └── 3_DockerShareLatexInstallation.docx └── texlive_integration │ └── README.md ├── kao.sty ├── kaobiblio.sty ├── kaobook.cls ├── kaohandt.cls ├── kaorefs.sty └── kaotheorems.sty /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | 🎉🎉🎉 Thank you for considering to contribute! 🎉🎉🎉 4 | 5 | ### Code of Conduct 6 | As a contributor, you are expected to follow the [code of conduct](https://github.com/fmarotta/kaobook/blob/master/CODE_OF_CONDUCT.md). 7 | Please read it and comply with the rules. 8 | 9 | ### Ways to Contribute 10 | * Use ```kaobook``` and write [bug reports](https://github.com/fmarotta/kaobook/issues/new?assignees=&labels=&template=bug_report.md) or [feature requests](https://github.com/AlexanderZeilmann/kaobook/issues/new?assignees=&labels=&template=feature_request.md). 11 | * Have a look at our [issues](https://github.com/fmarotta/kaobook/issues) and especially at our ["help wanted" issues](https://github.com/fmarotta/kaobook/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). Maybe you can help out with one of them. 12 | * Help improving our [documentation](https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf). 13 | 14 | ### Code Style Guide 15 | * We do not have a formal code style guide yet. 16 | * Please stick to the style of the surrounding code. 17 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: "https://paypal.me/marofede" 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 13 | 14 | ### Description 15 | 16 | 17 | ### Minimal Working Example 18 | 19 | 20 | ```latex 21 | \documentclass{kaobook} 22 | \usepackage[english]{babel} 23 | \usepackage{blindtext} 24 | \usepackage{kaobiblio} 25 | \usepackage{kaotheorems} 26 | \usepackage{kaorefs} 27 | 28 | \begin{document} 29 | 30 | \title{Bug Report} 31 | \author{Author} 32 | \date{\today} 33 | 34 | \frontmatter 35 | \maketitle 36 | \mainmatter 37 | \setchapterstyle{kao} 38 | 39 | \chapter{First Chapter} 40 | \blindtext 41 | 42 | \end{document} 43 | ``` 44 | 45 | **Expected behavior:** 46 | 47 | 48 | **Actual behavior:** 49 | 50 | 51 | 52 | ### Additional Information 53 | 54 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | ## Summary 7 | 8 | 9 | ## Details 10 | 11 | 12 | ## Additional context 13 | 14 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | Getting Support 2 | =============== 3 | 4 | Depending on your type of problem, there are several ways to get help: 5 | 6 | ### General LaTeX Questions 7 | * Completely new to TeX and LaTeX? → [Learn LaTeX in 30 minutes](https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes) 8 | * General question regarding TeX or LaTeX? → [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/) 9 | 10 | ### Questions regarding kaobook 11 | * Got a question on how to use kaobook? → [kaobook Documentation](https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf) 12 | * Got a question that is not answered by the documentation? → [kaobook Discussions](https://github.com/fmarotta/kaobook/discussions) 13 | 14 | ### Bug Reports & Feature requests 15 | * You want to report a bug? → [Create a bug report here.](https://github.com/fmarotta/kaobook/issues/new?assignees=&labels=&template=bug_report.md) 16 | * You want to propose a new feature? → [Create a feature request here.](https://github.com/fmarotta/kaobook/issues/new?assignees=&labels=&template=feature_request.md) 17 | -------------------------------------------------------------------------------- /.github/workflows/verify_examples.yml: -------------------------------------------------------------------------------- 1 | name: Verify examples 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | find_examples: 6 | runs-on: ubuntu-latest 7 | outputs: 8 | matrix: ${{ steps.find-dirs.outputs.matrix }} 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Gather directories inside examples 12 | id: find-dirs 13 | run: | 14 | cd examples 15 | echo "matrix={\"dir\":[$(for dir in $(echo */); do echo -n \"${dir%?}\",; done)]}" >> $GITHUB_OUTPUT 16 | build_latex: 17 | needs: find_examples 18 | runs-on: ubuntu-latest 19 | strategy: 20 | matrix: ${{fromJson(needs.find_examples.outputs.matrix)}} 21 | fail-fast: false 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Check that LaTeX example compiles 25 | uses: xu-cheng/latex-action@v3 26 | with: 27 | working_directory: examples/${{ matrix.dir }} 28 | pre_compile: | 29 | cp -r ../../* . || true 30 | root_file: main.tex 31 | latexmk_shell_escape: true 32 | - uses: actions/upload-artifact@v4 33 | if: ${{ always() }} 34 | with: 35 | name: Log - ${{ matrix.dir }} 36 | path: examples/${{ matrix.dir }}/main.log 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Custom exclusions 2 | article-template.pdf 3 | book-template.pdf 4 | 5 | ## Core latex/pdflatex auxiliary files: 6 | *.aux 7 | *.lof 8 | *.log 9 | *.lot 10 | *.fls 11 | *.out 12 | *.toc 13 | *.fmt 14 | *.fot 15 | *.cb 16 | *.cb2 17 | .*.lb 18 | 19 | ## Intermediate documents: 20 | *.dvi 21 | *.xdv 22 | *-converted-to.* 23 | # these rules might exclude image files for figures etc. 24 | # *.ps 25 | # *.eps 26 | # *.pdf 27 | 28 | ## Generated if empty string is given at "Please type another file name for output:" 29 | .pdf 30 | 31 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 32 | *.bbl 33 | *.bcf 34 | *.blg 35 | *-blx.aux 36 | *-blx.bib 37 | *.run.xml 38 | 39 | ## Build tool auxiliary files: 40 | *.fdb_latexmk 41 | *.synctex 42 | *.synctex(busy) 43 | *.synctex.gz 44 | *.synctex.gz(busy) 45 | *.pdfsync 46 | 47 | ## Auxiliary and intermediate files from other packages: 48 | # algorithms 49 | *.alg 50 | *.loa 51 | 52 | # achemso 53 | acs-*.bib 54 | 55 | # amsthm 56 | *.thm 57 | 58 | # beamer 59 | *.nav 60 | *.pre 61 | *.snm 62 | *.vrb 63 | 64 | # changes 65 | *.soc 66 | 67 | # cprotect 68 | *.cpt 69 | 70 | # elsarticle (documentclass of Elsevier journals) 71 | *.spl 72 | 73 | # endnotes 74 | *.ent 75 | 76 | # fixme 77 | *.lox 78 | 79 | # feynmf/feynmp 80 | *.mf 81 | *.mp 82 | *.t[1-9] 83 | *.t[1-9][0-9] 84 | *.tfm 85 | 86 | #(r)(e)ledmac/(r)(e)ledpar 87 | *.end 88 | *.?end 89 | *.[1-9] 90 | *.[1-9][0-9] 91 | *.[1-9][0-9][0-9] 92 | *.[1-9]R 93 | *.[1-9][0-9]R 94 | *.[1-9][0-9][0-9]R 95 | *.eledsec[1-9] 96 | *.eledsec[1-9]R 97 | *.eledsec[1-9][0-9] 98 | *.eledsec[1-9][0-9]R 99 | *.eledsec[1-9][0-9][0-9] 100 | *.eledsec[1-9][0-9][0-9]R 101 | 102 | # glossaries 103 | *.acn 104 | *.acr 105 | *.glg 106 | *.glo 107 | *.gls 108 | *.glsdefs 109 | 110 | # gnuplottex 111 | *-gnuplottex-* 112 | 113 | # gregoriotex 114 | *.gaux 115 | *.gtex 116 | 117 | # htlatex 118 | *.4ct 119 | *.4tc 120 | *.idv 121 | *.lg 122 | *.trc 123 | *.xref 124 | 125 | # hyperref 126 | *.brf 127 | 128 | # knitr 129 | *-concordance.tex 130 | # TODO Comment the next line if you want to keep your tikz graphics files 131 | *.tikz 132 | *-tikzDictionary 133 | 134 | # listings 135 | *.lol 136 | 137 | # makeidx 138 | *.idx 139 | *.ilg 140 | *.ind 141 | *.ist 142 | 143 | # minitoc 144 | *.maf 145 | *.mlf 146 | *.mlt 147 | *.mtc[0-9]* 148 | *.slf[0-9]* 149 | *.slt[0-9]* 150 | *.stc[0-9]* 151 | 152 | # minted 153 | _minted* 154 | *.pyg 155 | 156 | # morewrites 157 | *.mw 158 | 159 | # nomencl 160 | *.nlg 161 | *.nlo 162 | *.nls 163 | 164 | # pax 165 | *.pax 166 | 167 | # pdfpcnotes 168 | *.pdfpc 169 | 170 | # sagetex 171 | *.sagetex.sage 172 | *.sagetex.py 173 | *.sagetex.scmd 174 | 175 | # scrwfile 176 | *.wrt 177 | 178 | # sympy 179 | *.sout 180 | *.sympy 181 | sympy-plots-for-*.tex/ 182 | 183 | # pdfcomment 184 | *.upa 185 | *.upb 186 | 187 | # pythontex 188 | *.pytxcode 189 | pythontex-files-*/ 190 | 191 | # thmtools 192 | *.loe 193 | 194 | # TikZ & PGF 195 | *.dpth 196 | *.md5 197 | *.auxlock 198 | 199 | # todonotes 200 | *.tdo 201 | 202 | # easy-todo 203 | *.lod 204 | 205 | # xmpincl 206 | *.xmpi 207 | 208 | # xindy 209 | *.xdy 210 | 211 | # xypic precompiled matrices 212 | *.xyc 213 | 214 | # endfloat 215 | *.ttt 216 | *.fff 217 | 218 | # Latexian 219 | TSWLatexianTemp* 220 | 221 | ## Editors: 222 | # WinEdt 223 | *.bak 224 | *.sav 225 | 226 | # Texpad 227 | .texpadtmp 228 | 229 | # Kile 230 | *.backup 231 | 232 | # KBibTeX 233 | *~[0-9]* 234 | 235 | # auto folder when using emacs and auctex 236 | ./auto/* 237 | *.el 238 | 239 | # expex forward references with \gathertags 240 | *-tags.tex 241 | 242 | # standalone packages 243 | *.sta 244 | 245 | # generated if using elsarticle.cls 246 | *.spl 247 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package kaobook 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | 0.9.8 (2021/08/23) 6 | ---------------- 7 | * Fix some issues 8 | 9 | 0.9.7 (2021/06/02) 10 | ------------------ 11 | * Move the packages to the root of the repository 12 | * Introduce the 'bar' chapterstyle 13 | * Fix some issues 14 | 15 | 0.9.6 (2021/03/23) 16 | ------------------ 17 | * Short margin tocs 18 | * Dynamic section-number-width in the margintoc 19 | * Use kvoptions instead of xkeyval 20 | * Slight modification of the page layout so that margin and wide pages 21 | have the same total width 22 | 23 | 0.9.5 (2020/12/30) 24 | ------------------ 25 | * Use \DeclareCiteCommand in kaobiblio.sty (fixes #68) 26 | * Support f24paper 27 | * Include scrhack 28 | * Add \FloatBarrier before marginfigures, tables and listings 29 | * Improve style of header and chapter, esp. for scales different from A4 30 | * Fix overfull boxes in header and chapter layouts 31 | * Increase the width of the page number boxes in the toc 32 | * Fix typos in the docs (contributor: Martin Michlmayr) 33 | * Set default chapter styles for front-, main-, and back- matter 34 | 35 | 0.9.0 (2020/12/02) 36 | ------------------ 37 | * First official release on GitHub 38 | * Define \hscale and \vscale, and rescale lengths accordingly 39 | * Allow user to choose papersize in the documentclass options 40 | 41 | Ancient history 42 | --------------- 43 | * Add the sidecite command modified to work with BibTeX 44 | * Add an example on how to use the kao_book template with BibTeX 45 | * Add short way to references equations, chapters and sections 46 | * Contributors: Giuseppe Silano 47 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | ```federicomarotta@mail.com```. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /MANIFEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # First Work: The kaobook Class 4 | 5 | MANIFEST.md 6 | Copyright 2020-2021 Federico Marotta 7 | 8 | This work may be distributed and/or modified under the 9 | conditions of the LaTeX Project Public License, either version 1.3 10 | of this license or (at your option) any later version. 11 | The latest version of this license is in 12 | 13 | http://www.latex-project.org/lppl.txt 14 | 15 | and version 1.3 or later is part of all distributions of LaTeX 16 | version 2005/12/01 or later. 17 | 18 | This work has the LPPL maintenance status `maintained'. 19 | 20 | The Current Maintainer of this work is Federico Marotta. 21 | 22 | This work consists of all files listed below. 23 | 24 | --- 25 | 26 | ``` 27 | kaobook/ 28 | |-- kaobook.cls - book-specific definitions 29 | |-- kaohandt.cls - handout-specific definitions 30 | |-- kao.sty - main definitions 31 | |-- kaobiblio.sty - style of the bibliography 32 | |-- kaotheorems.sty - colorful styling of theorems 33 | `-- kaorefs.sty - commands for referencing 34 | ``` 35 | 36 | --- 37 | 38 | # Second Work: Templates and Examples 39 | 40 | This work is released into the public domain using the CC0 code. To the 41 | extent possible under law, I waive all copyright and related or 42 | neighbouring rights to this work. To view a copy of the CC0 code, visit: 43 | 44 | http://creativecommons.org/publicdomain/zero/1.0 45 | 46 | This work consists of all files listed below as well as the products of 47 | their compilation. 48 | 49 | --- 50 | 51 | ``` 52 | kaobook/ 53 | `-- examples/ 54 | |-- minimal_book/ 55 | | `-- main.tex 56 | |-- minimal_report/ 57 | | `-- main.tex 58 | |-- documentation/ 59 | | |-- main.tex 60 | | |-- main.bib 61 | | |-- glossary.tex 62 | | `-- chapters/ 63 | | |-- appendix.tex 64 | | |-- figsntabs.tex 65 | | |-- introduction.tex 66 | | |-- layout.tex 67 | | |-- mathematics.tex 68 | | |-- options.tex 69 | | |-- preface.tex 70 | | |-- references.tex 71 | | `-- textnotes.tex 72 | `-- machine_learning_project/ 73 | |-- sections/ 74 | | |-- introduction.tex 75 | | |-- data.tex 76 | | |-- results.tex 77 | | `-- discussion.tex 78 | |-- main.tex 79 | `-- main.bib 80 | ``` 81 | 82 | As regards the files in the `kaobook/examples/documentation/images` 83 | directory, they were downloaded from [Wikimedia 84 | Commons](https://commons.wikimedia.org/wiki/Main_Page) and are 85 | attributed inside the example book where they are used. 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kaobook 2 | 3 | ## Acknowledgements 4 | 5 | This class is based on the work of [Ken Arroyo 6 | Ohori](https://3d.bk.tudelft.nl/ken/en/) for his doctoral thesis. 7 | The main ideas behind the layout can be found in this [blog 8 | post](https://3d.bk.tudelft.nl/ken/en/2016/04/17/a-1.5-column-layout-in-latex.html). 9 | The [Tufte-LaTeX class](https://github.com/Tufte-LaTeX/tufte-latex) has also been a 10 | source of ideas about the layout. 11 | 12 | My gratitude goes also to [Vel](https://www.vel.nz/), for his patience 13 | and his invaluable suggestions about the design, and to all the people 14 | who have contributed either on 15 | [GitHub](https://github.com/fmarotta/kaobook/graphs/contributors) or by 16 | sending e-mails. 17 | 18 | ## Description 19 | 20 | The salient features of the class are as follows. 21 | 22 | * Wide margin to house captions, small figures or tables, and textual 23 | notes. 24 | 25 | * Mini table of contents in the margin at the start of each chapter. 26 | 27 | * Easily-customisable chapter headings. 28 | 29 | * Flexible citations with references both in the margin and in the 30 | bibliography at the end. 31 | 32 | * Powered by KOMA-Script. 33 | 34 | * Many commands have been redefined to ease the life of the user. 35 | 36 | A better description can be found at [LaTeX 37 | Templates](http://www.latextemplates.com/template/kaobook). If you think 38 | that a PDF is worth a thousand words, have a look at [this](example_and_documentation.pdf). 39 | 40 | ## Showcase 41 | 42 | In the [examples](examples) directory you can find some sample 43 | documents, but here are some more books or reports created with the 44 | kaobook class. If you want to add a link to your work, please send me an 45 | email or open a pull request! 46 | 47 | * [Growing Open Source Projects with a Stable Foundation (short book)](https://www.cyrius.com/foss-foundations/growing-open-source-projects.pdf) 48 | * [Cours De Physique - Mécanique Classique (textbook)](https://femto-physique.fr/mecanique/pdf/book_meca.pdf) 49 | * [Introduction to Causal Inference (textbook)](https://www.bradyneal.com/Introduction_to_Causal_Inference-Dec17_2020-Neal.pdf) 50 | * [Formalisation and Meta-Theory of Type Theory (PhD thesis)](https://github.com/TheoWinterhalter/phd-thesis/releases/latest) 51 | * [Computational modelling of terrains (textbook)](https://github.com/tudelft3d/terrainbook/releases/latest) 52 | * [Meta-analysis of Type Theories with an Application to the Design of Formal Proofs (PhD thesis)](https://anjapetkovic.com/img/doctoralThesis.pdf) 53 | * [Deep Inference for Graphical Theorem Proving (PhD thesis)](https://github.com/Champitoad/thesis/releases/tag/v1.0.0) 54 | * [Psychedelic therapy in practice. Case studies of self-treatment, individual therapy, and group therapy (academic book)](https://www.researchgate.net/publication/389998402) 55 | * [Ayahuasca revisited: Case studies & observations (academic book)](https://www.researchgate.net/publication/389998045) 56 | * [From Underactuation to Quasi-Full Actuation: A Unifying Control Framework for Rigid and Elastic Joint Robots (PhD thesis)](https://mediatum.ub.tum.de/1662418) 57 | 58 | ## Getting Started 59 | 60 | If you are not familiar with LaTeX, I recommend starting with [this 61 | tutorial](https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes), 62 | which will give you a basic understanding of the language. As you will 63 | read in the tutorial, all LaTeX documents, including books, start by 64 | defining the so-called *class* of the document, for example 'article', 65 | or 'book'. Thus, the first line of a LaTeX document will be something 66 | like 67 | ``` 68 | \documentclass{book} 69 | ``` 70 | 71 | Each class provides a unique style and set of commands that can be used 72 | throughout the document. `kaobook` is just another class. The following 73 | paragraphs will outline how to use it. 74 | 75 | ### On Overleaf 76 | 77 | Browse to the [latextemplates.com page for 78 | kaobook](https://www.latextemplates.com/template/kaobook) and start 79 | editing the `main.tex` file to fill it with your own contents. 80 | 81 | ### On your computer 82 | 83 | Download the latest release from GitHub. At the root of the repository, 84 | create a new `.tex` file and make sure that the first line reads 85 | `\documentclass{kaobook}` (for books) or `\documentclass{kaohandt}` (for 86 | reports). Then, fill the file with your LaTeX contents. 87 | 88 | Important: when we say `\documentclass{kaobook}`, LaTeX needs to know 89 | where the `kaobook` file is. This means that the `.tex` file should be 90 | in the same folder as the `kaobook.cls` file, *i.e.* at the root of the 91 | repository. (There are exceptions to this rule. For instance, the 92 | kaobook files can be placed in a folder that is automatically searched 93 | by LaTeX. This, way, the `.tex` file with your contents can be placed 94 | anywhere; check out the [instructions](instructions) directory for 95 | hints.) 96 | 97 | If you don't want to start from scratch, go to the `examples` directory, 98 | and find a template that you like; then, copy the corresponding 99 | `main.tex` at the root of the repository, and start editing it, filling 100 | it with your contents. 101 | 102 | ### Other 103 | 104 | Check out the [instructions](instructions) directory for additional 105 | guidance. There, you can read about setting up your own sharelatex 106 | server or integrating kaobook with your local LaTeX installation. 107 | 108 | --- 109 | 110 | The class is documented and exemplified in the 111 | [example\_and\_documentation.pdf](example_and_documentation.pdf) file. 112 | The easiest way to start using the class is to open one of the examples 113 | and start editing them. 114 | 115 | ## Compiling the examples 116 | 117 | In the `examples` directory of this repository you can find several 118 | documents exemplifying the kaobook class. For the sake of simplicity 119 | I shall list the commands to compile only the documentation, but the 120 | compilation of the other examples would proceed in the same way. Also, 121 | you can replace pdflatex with your favorite engine, like *e.g.* xelatex. 122 | 123 | ### From the command line (Unix-like operating systems) 124 | 125 | `cd` into the root of the repository, and run 126 | ``` 127 | pdflatex -output-directory examples/documentation main.tex 128 | biber -output-directory examples/documentation main 129 | pdflatex -output-directory examples/documentation main.tex 130 | pdflatex -output-directory examples/documentation main.tex 131 | pdflatex -output-directory examples/documentation main.tex 132 | ``` 133 | 134 | To compile the glossary and nomenclature as well, `cd` into the 135 | `examples/documentation` directory and run 136 | ``` 137 | makeindex main.nlo -s nomencl.ist -o main.nls 138 | makeglossaries main 139 | ``` 140 | Then, `cd` back into the root of the repository and re-run pdflatex. 141 | 142 | NOTE: sometimes LaTeX needs more than one run to get the correct 143 | position of each element; this is true in particular for the positioning 144 | of floating elements like figures, tables, and margin notes. 145 | Occasionally, LaTeX can need up to four re-runs, so If the alignment of 146 | margin elements looks odd, or if they bleed into ther main text, try 147 | running pdflatex one more time. 148 | 149 | ## Updating kaobook 150 | 151 | To update kaobook you should download the whole repository (or one of 152 | the releases) again, and replace all of your old files with the newer 153 | ones, *except* for the main.tex and the files that you have created, 154 | like the chapters of the book. The crucial files that pertain to kaobook 155 | and that you should always update are: 156 | 157 | 1. `kaobook.cls`; 158 | 2. `kaohandt.cls`; 159 | 3. `kao.sty`; 160 | 3. `kaobiblio.sty` (optional); 161 | 4. `kaorefs.sty` (optional); 162 | 5. `kaotheorems.sty` (optional); 163 | 164 | These files should be in the same folder as your `main.tex`. Even if a 165 | file has not been modified, I would still suggest to replace everything 166 | because it is easier. 167 | 168 | In practice, I would do as follows. I would have a directory, called for 169 | example 'my\_book', with all the files necessary for the book: 170 | `kaobook.cls`, `kaohand.cls`, the `*.sty` files, and the `main.tex`. I 171 | like to have a separate file for each chapter, so I would also have a 172 | directory called `chapters`, with all the `.tex` files with the actual 173 | chapters. Then, when I want to update kaobook, I would download the 174 | GitHub repository (or one of the releases) into a directory called 175 | 'kaobook', and finally copy the `kaobook.cls`, `kaohandt.cls`, and the 176 | whole `styles` directory from 'kaobook' to 'my\_book'. Once the update 177 | is completed, the whole 'my\_book' directory can be uploaded on Overleaf 178 | or on a personal ShareLaTeX server. 179 | 180 | Alternatively, advanced users can download the repository in their local 181 | texmf tree; see the [instructions](instructions) directory for hints. 182 | 183 | ## Repository Schema 184 | 185 | There are two main class files: `kaobook.cls`, used for books, and 186 | `kaohandt.cls`, used for reports or handouts; both heavily rely on 187 | `kao.sty`, which contains the bulk of the definitions that are common to 188 | both classes. In the future there may be another class for theses. 189 | 190 | Some examples and templates are listed in the `examples` directory. The 191 | book that documents the class is an example itself, and the pdf has been 192 | copied to the root of the repository so that it will be found more 193 | easily. 194 | 195 | The `*.sty` files contain additional packages that are used by the 196 | class, but in principle they are independent of it (even though in 197 | practice it is still not so). 198 | 199 | If you want to do something more peculiar, the `instructions` directory 200 | may contain what you need. 201 | 202 | ## Contributing 203 | 204 | Do you like the design, but you found a bug? Is there something you 205 | would have done differently? Any contribution is welcome! Moreover, even 206 | if you'd rather not tamper with the code it is *not* forbidden to send 207 | me the documents you compiled using the kaobook class. 208 | 209 | Since the content of this repository is published at [LaTeX 210 | Templates](http://www.latextemplates.com/), if you wish to contribute by 211 | changing the code you must follow the style guidelines of the site: 212 | extensive commenting and clear separation of the code into nicely 213 | formatted blocks. 214 | 215 | ## Supporting 216 | 217 | I am always happy to help as much as I can, and I am glad if someone 218 | uses the `kaobook` class for their works, so there is no real need to do 219 | anything: the kaobook can be used just like any other LaTeX package (no 220 | need to add copyright statements). However, if you want to acknowledge 221 | kaobook, adding somewhere a sentence like 'This book was typeset with the 222 | kaobook class' would suffice. 223 | 224 | Coffee keeps me awake and helps me writing a better LaTeX template. As 225 | another way to contribute, you can buy me a coffee through PayPal: 226 | https://paypal.me/marofede. 227 | 228 | ## License 229 | 230 | This repository contains two independent works. On the one hand, the 231 | kaobook class, consisting of `kaobook.cls`, `kaohandt.cls`, and 232 | `kao.def` files plus all of the files listed in the `styles` directory; 233 | on the other hand, the templates and the examples in the `examples` 234 | directory. 235 | 236 | The first work is licensed under the [LaTeX Project Public 237 | License](https://www.latex-project.org/lppl/), so if you want to modify 238 | and/or distribute the `*.cls` and `*.sty` files pertaining to this work 239 | you have to complain with the terms of the license. However, if you just 240 | want to use the class to compile your documents you need not worry about 241 | the license. 242 | 243 | The second work is released into the public domain with a Creative 244 | Commons Zero License. 245 | 246 | Read [MANIFEST.md](MANIFEST.md) for the details. 247 | -------------------------------------------------------------------------------- /example_and_documentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/example_and_documentation.pdf -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | In this folder "examples" you will find 4 examples of KaoBook layouts, 4 | each demonstrating different publications. 5 | * documentation 6 | * machine\_learning\_project 7 | * minimal\_book 8 | * minimal\_report 9 | 10 | The PDF files provided with the individual examples show the appearance 11 | of the respective end product. 12 | 13 | NOTE: These examples are not yet complete in this form. 14 | They must be supplemented by two additional components: 15 | * the "styles" folder 16 | * the file that defines the layout type (Book or Report / kaobook.cls or 17 | kaohandt.cls) 18 | 19 | To make it more clear: 20 | you have to add "kaohandt.cls" for machine\_learning\_project and 21 | to minimal\_report, because these examples are of type "report". 22 | "kaobook.cls" should be included to the two other examples. 23 | -------------------------------------------------------------------------------- /examples/documentation/chapters/appendix.tex: -------------------------------------------------------------------------------- 1 | \setchapterstyle{lines} 2 | \labch{appendix} 3 | \blinddocument 4 | 5 | \setchapterpreamble[u]{\margintoc} 6 | \chapter{Fonts Testing} 7 | 8 | \section{Font Sizes} 9 | 10 | {\tiny The quick brown fox jumps over the lazy dog.} 11 | 12 | {\scriptsize The quick brown fox jumps over the lazy dog.} 13 | 14 | {\footnotesize The quick brown fox jumps over the lazy dog.} 15 | 16 | {\small The quick brown fox jumps over the lazy dog.} 17 | 18 | {\normalsize The quick brown fox jumps over the lazy dog.} 19 | 20 | {\large The quick brown fox jumps over the lazy dog.} 21 | 22 | {\Large The quick brown fox jumps over the lazy dog.} 23 | 24 | {\LARGE The quick brown fox jumps over the lazy dog.} 25 | 26 | {\huge The quick brown fox jumps over the lazy dog.} 27 | 28 | {\Huge The quick brown fox jumps over the lazy dog.} 29 | 30 | 31 | \section{Font Families} 32 | 33 | \sffamily\blindtext 34 | 35 | \textmd{The quick brown fox jumps over the lazy dog. Medium.} 36 | 37 | \textbf{The quick brown fox jumps over the lazy dog. Bold.} 38 | 39 | \textup{The quick brown fox jumps over the lazy dog. Upright.} 40 | 41 | \textit{The quick brown fox jumps over the lazy dog. Italics.} 42 | 43 | \textsl{The quick brown fox jumps over the lazy dog. Slanted.} 44 | 45 | \textsc{The quick brown fox jumps over the lazy dog. Small Caps.} 46 | 47 | \ttfamily\blindtext 48 | 49 | \textmd{The quick brown fox jumps over the lazy dog. Medium.} 50 | 51 | \textbf{The quick brown fox jumps over the lazy dog. Bold.} 52 | 53 | \textup{The quick brown fox jumps over the lazy dog. Upright.} 54 | 55 | \textit{The quick brown fox jumps over the lazy dog. Italics.} 56 | 57 | \textsl{The quick brown fox jumps over the lazy dog. Slanted.} 58 | 59 | \textsc{The quick brown fox jumps over the lazy dog. Small Caps.} 60 | 61 | \rmfamily\blindtext 62 | 63 | \textmd{The quick brown fox jumps over the lazy dog. Medium.} 64 | 65 | \textbf{The quick brown fox jumps over the lazy dog. Bold.} 66 | 67 | \textup{The quick brown fox jumps over the lazy dog. Upright.} 68 | 69 | \textit{The quick brown fox jumps over the lazy dog. Italics.} 70 | 71 | \textsl{The quick brown fox jumps over the lazy dog. Slanted.} 72 | 73 | \textsc{The quick brown fox jumps over the lazy dog. Small Caps.} 74 | 75 | -------------------------------------------------------------------------------- /examples/documentation/chapters/figsntabs.tex: -------------------------------------------------------------------------------- 1 | \setchapterimage[7.5cm]{seaside} 2 | \setchapterpreamble[u]{\margintoc} 3 | %\chapter[Figures and Tables]{Figures and Tables\footnotemark[0]} 4 | \chapter{Figures and Tables} 5 | 6 | \footnotetext{The credits for the image above the chapter title go to: 7 | Bushra Feroz, CC~BY-SA~4.0, \url{https://commons.wikimedia.org/w/index.php?curid=68724647}} 8 | 9 | \section{Normal Figures and Tables} 10 | 11 | Figures and tables can be inserted just like in any standard 12 | \LaTeX\xspace document. The \Package{graphicx} package is already loaded 13 | and configured in such a way that the figure width is equal to the 14 | textwidth and the height is adjusted in order to maintain the original 15 | aspect ratio. As you may have imagined, the captions will be 16 | positioned\ldots well, in the margins. This is achieved with the help of 17 | the \Package{floatrow} package. 18 | 19 | Here is a picture of Mona Lisa (\reffig{normalmonalisa}), as an example. 20 | The captions are formatted as the margin- and the side-notes; If you 21 | want to change something about captions you can use the command 22 | \Command{captsetup} from the \Package{caption} package. Remember that if 23 | you want to reference a figure, the label must come \emph{after} the 24 | caption! 25 | 26 | \begin{figure}[hb] 27 | \includegraphics[width=0.45\textwidth]{monalisa} 28 | \caption[Mona Lisa, again]{It's Mona Lisa again. \blindtext} 29 | \labfig{normalmonalisa} 30 | \end{figure} 31 | 32 | While the format of the caption is managed by \Package{caption}, its 33 | position is handled by the \Package{floatrow} package. Achieving this 34 | result has been quite hard, but now I am pretty satisfied. In two-side 35 | mode, the captions are printed in the correct margin. 36 | 37 | Tables can be inserted just as easily as figures, as exemplified by the 38 | following code: 39 | 40 | \begin{lstlisting}[caption={Caption of a listing.}] 41 | \begin{table} 42 | \begin{tabular}{ c c c c } 43 | \toprule 44 | col1 & col2 & col3 & col 4 \\ 45 | \midrule 46 | \multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4\\ & 47 | cell5 & cell6 & cell7 \\ & 48 | cell8 & cell9 & cell10 \\ 49 | \multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4 \\ & 50 | cell5 & cell6 & cell7 \\ & 51 | cell8 & cell9 & cell10 \\ 52 | \bottomrule 53 | \end{tabular} 54 | \end{table} 55 | \end{lstlisting} 56 | 57 | which results in the useless \vreftab{useless}. 58 | 59 | \begin{table}[ht] 60 | \caption[A useless table]{A useless table.} 61 | \labtab{useless} 62 | \begin{tabular}{ c c c c } 63 | \toprule 64 | col1 & col2 & col3 & col 4 \\ 65 | \midrule 66 | \multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4\\ & 67 | cell5 & cell6 & cell7 \\ & 68 | cell8 & cell9 & cell10 \\ 69 | \multirow{3}{4em}{Multiple row} & cell2 & cell3 & cell4 \\ & 70 | cell5 & cell6 & cell7 \\ & 71 | cell8 & cell9 & cell10 \\ 72 | \bottomrule 73 | \end{tabular} 74 | \end{table} 75 | 76 | I don't have much else to say, so I will just insert some blind text. 77 | \blindtext 78 | 79 | \section{Margin Figures and Tables} 80 | 81 | Marginfigures can be inserted with the environment 82 | \Environment{marginfigure}. In this case, the whole picture is confined 83 | to the margin and the caption is below it. \reffig{marginmonalisa} is 84 | obtained with something like this: 85 | 86 | \begin{lstlisting}[caption={Another caption.}] 87 | \begin{marginfigure} 88 | \includegraphics{monalisa} 89 | \caption[The Mona Lisa]{The Mona Lisa.} 90 | \labfig{marginmonalisa} 91 | \end{marginfigure} 92 | \end{lstlisting} 93 | 94 | There is also the \Environment{margintable} environment, of which 95 | \reftab{anotheruseless} is an example. Notice how you can place the 96 | caption above the table by just placing the \Command{caption} command 97 | before beginning the \Environment{tabular} environment. Usually, figure 98 | captions are below, while table captions are above. This rule is also 99 | respected for normal figures and tables: the captions are always on the 100 | side, but for figure they are aligned to the bottom, while for tables to 101 | the top. 102 | 103 | \begin{margintable} 104 | \caption[Another useless table]{Another useless table.} 105 | \labtab{anotheruseless} 106 | \raggedright 107 | \begin{tabular}{ c c c c } 108 | \hline 109 | col1 & col2 & col3 \\ 110 | \hline 111 | \multirow{3}{4em}{Multiple row} & cell2 & cell3 \\ & cell5 & cell6 112 | \\ & cell8 & cell9 \\ \hline 113 | \end{tabular} 114 | \end{margintable} 115 | 116 | Marginfigures and tables can be positioned with an optional offset 117 | command, like so: 118 | 119 | \begin{lstlisting} 120 | \begin{marginfigure}[offset] 121 | \includegraphics{seaside} 122 | \end{marginfigure} 123 | \end{lstlisting} 124 | 125 | Offset ca be either a measure or a multiple of \Command{baselineskip}, 126 | much like with \Command{sidenote}, \Command{marginnote} and 127 | \Command{margintoc}.\todo{Improve this part.} If you are wondering how I 128 | inserted this orange bubble, have a look at the \Package{todo} package. 129 | 130 | \section{Wide Figures and Tables} 131 | 132 | With the environments \Environment{figure*} and \Environment{table*} you 133 | can insert figures which span the whole page width. For example, here 134 | are a wide figure and a wide table. 135 | 136 | \begin{figure*}[h!] 137 | \includegraphics{seaside} 138 | \caption[A wide seaside]{A wide seaside, and a wide caption. 139 | Credits: By Bushra Feroz, CC BY-SA 4.0, \url{https://commons.wikimedia.org/w/index.php?curid=68724647}} 140 | \end{figure*} 141 | 142 | \begin{table*}[h!] 143 | \caption{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.} 144 | \begin{tabular}{p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{1.5cm}} 145 | \toprule 146 | Name & Surname & Job & Salary & Age & Height & Country \\ 147 | \midrule 148 | Alice & Red & Writer & 4.000 \pounds & 34 & 167 cm & England \\ 149 | Bob & White & Bartender & 2.000 \pounds & 24 & 180 cm & Scotland \\ 150 | Drake & Green & Scientist & 4.000 \pounds & 26 & 175 cm & Wales \\ 151 | \bottomrule 152 | \end{tabular} 153 | \end{table*} 154 | 155 | It is the user's responsibility to adjust the width of the table, if 156 | necessary, until it is aesthetically pleasing. The previous table was 157 | obtained with the following code: 158 | 159 | \begin{lstlisting}[caption=How to typeset a wide table] 160 | \begin{table*}[h!] 161 | \caption{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.} 162 | \begin{tabular}{p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{2.0cm} p{1.5cm}} 163 | \toprule 164 | Name & Surname & Job & Salary & Age & Height & Country \\ 165 | \midrule 166 | Alice & Red & Writer & 4.000 \pounds & 34 & 167 cm & England \\ 167 | Bob & White & Bartender & 2.000 \pounds & 24 & 180 cm & Scotland \\ 168 | Drake & Green & Scientist & 4.000 \pounds & 26 & 175 cm & Wales \\ 169 | \bottomrule 170 | \end{tabular} 171 | \end{table*} 172 | \end{lstlisting} 173 | 174 | The \Package{floatrow} package provides the \enquote{H} specifier to 175 | instruct \LaTeX to position the figure (or table) in precisely the same 176 | position it occupies in the source code. However, this specifier does 177 | not work with wide figures or tables: you should use \enquote{h!} 178 | instead, like so: \lstinline|\begin{figure*}[h!]|. 179 | 180 | You may have noticed the full width image at the very beginning of this 181 | chapter: that, however, is set up in an entirely different way, which 182 | you'll read about in \vrefch{layout}. 183 | 184 | \Class{kaobook} also supports paginated tables (have a look at the 185 | \Package{longtable} package). The 186 | \Environment{longtable}\sidenote{Interestingly, \Environment{longtable}s 187 | may require up to four rounds of compilation before they are typeset 188 | correctly.} environment behaves a bit differently from 189 | \Environment{table}, in that \Environment{longtable} encompasses both 190 | \Environment{table} and \Environment{tabular}, so that you can write, 191 | \eg, 192 | 193 | \begin{lstlisting}[caption=Example of a longtable] 194 | \begin{longtable}{|l c c|} 195 | \hline 196 | One & Two & Three \\ 197 | Left & Center & Center \\ 198 | \hline 199 | \caption{Caption of the longtable.} 200 | \end{longtable} 201 | \end{lstlisting} 202 | 203 | to obtain the following table: 204 | \begin{longtable}{|l c c|} 205 | \hline 206 | One & Two & Three \\ 207 | Left & Center & Center \\ 208 | \hline 209 | \caption{Caption of the longtable.} 210 | \end{longtable} 211 | 212 | The caption of a \Environment{longtable} is always positioned below the 213 | table, and it has the same width as the text (it doesn't extend into the 214 | margin). However, sometimes you may need a \Environment{longtable} that 215 | is so wide that it trespass into the margins; in those cases, you may 216 | want to also increase the width of the caption. To do so, you'll have to 217 | write two additional commands, one before and one after the 218 | \Environment{longtable}: 219 | 220 | \begin{lstlisting}[caption=Increasing the width of the caption of a \Environment{longtable}.] 221 | \floatsetup[longtable]{margins=centering,LTcapwidth=table} % Add this line before the longtable to increase the caption width 222 | \begin{longtable}{lp{8cm}p{5cm}p{2cm}} 223 | ... 224 | \end{longtable} 225 | \floatsetup[longtable]{margins=raggedright,LTcapwidth=\textwidth} % Add this line after the longtable to revert the previous change 226 | \end{lstlisting} 227 | 228 | Having seen figures and tables, it is now time to tackle 229 | hyperreferences. 230 | -------------------------------------------------------------------------------- /examples/documentation/chapters/introduction.tex: -------------------------------------------------------------------------------- 1 | \setchapterpreamble[u]{\margintoc} 2 | \chapter{Introduction} 3 | \labch{intro} 4 | 5 | \section{The Main Ideas} 6 | 7 | Many modern printed textbooks have adopted a layout with prominent 8 | margins where small figures, tables, remarks and just about everything 9 | else can be displayed. Arguably, this layout helps to organise the 10 | discussion by separating the main text from the ancillary material, 11 | which at the same time is very close to the point in the text where 12 | it is referenced. 13 | 14 | This document does not aim to be an apology of wide margins, for there 15 | are many better suited authors for this task; the purpose of all these 16 | words is just to fill the space so that the reader can see how a book 17 | written with the kaobook class looks like. Meanwhile, I shall also try 18 | to illustrate the features of the class. 19 | 20 | The main ideas behind kaobook come from this 21 | \href{https://3d.bk.tudelft.nl/ken/en/2016/04/17/a-1.5-column-layout-in-latex.html}{blog 22 | post}, and actually the name of the class is dedicated to the author 23 | of the post, Ken Arroyo Ohori, which has kindly allowed me to create a 24 | class based on his thesis. Therefore, if you want to know more reasons 25 | to prefer a 1.5-column layout for your books, be sure to read his blog 26 | post. 27 | 28 | Another source of inspiration, as you may have noticed, is the 29 | \href{https://github.com/Tufte-LaTeX/tufte-latex}{Tufte-Latex Class}. 30 | The fact that the design is similar is due to the fact that it is very 31 | difficult to improve something which is already so good. However, I like 32 | to think that this class is more flexible than Tufte-Latex. For 33 | instance, I have tried to use only standard packages and to implement as 34 | little as possible from scratch;\sidenote{This also means that 35 | understanding and contributing to the class development is made easier. 36 | Indeed, many things still need to be improved, so if you are interested, 37 | check out the repository on github!} therefore, it should be pretty easy 38 | to customise anything, provided that you read the documentation of the 39 | package that provides that feature. 40 | 41 | In this book I shall illustrate the main features of the class and 42 | provide information about how to use and change things. Let us get 43 | started. 44 | 45 | \section{What This Class Does} 46 | \labsec{does} 47 | 48 | The \Class{kaobook} class focuses more about the document structure than 49 | about the style. Indeed, it is a well-known \LaTeX\xspace principle that 50 | structure and style should be separated as much as possible (see also 51 | \vrefsec{doesnot}). This means that this class will only provide 52 | commands, environments and in general, the opportunity to do things, 53 | which the user may or may not use. Actually, some stylistic matters are 54 | embedded in the class, but the user is able to customise them with ease. 55 | 56 | The main features are the following: 57 | 58 | \begin{description} 59 | \item[Page Layout] The text width is reduced to improve readability 60 | and make space for the margins, where any sort of elements can be 61 | displayed. 62 | \item[Chapter Headings] As opposed to Tufte-Latex, we provide a 63 | variety of chapter headings among which to choose; examples will be 64 | seen in later chapters. 65 | \item[Page Headers] They span the whole page, margins included, and, 66 | in twoside mode, display alternatively the chapter and the section 67 | name.\sidenote[][-2mm]{This is another departure from Tufte's 68 | design.} 69 | \item[Matters] The commands \Command{frontmatter}, 70 | \Command{mainmatter} and \Command{backmatter} have been redefined in 71 | order to have automatically wide margins in the main matter, and 72 | narrow margins in the front and back matters. However, the page 73 | style can be changed at any moment, even in the middle of the 74 | document. 75 | \item[Margin text] We provide commands \Command{sidenote} and 76 | \Command{marginnote} to put text in the 77 | margins.\sidenote[][-2mm]{Sidenotes (like this!) are numbered while 78 | marginnotes are not} 79 | \item[Margin figs/tabs] A couple of useful environments is 80 | \Environment{marginfigure} and \Environment{margintable}, which, not 81 | surprisingly, allow you to put figures and tables in the margins 82 | (\cfr \reffig{marginmonalisa}). 83 | \item[Margin toc] Finally, since we have wide margins, why don't add 84 | a little table of contents in them? See \Command{margintoc} for 85 | that. 86 | \item[Hyperref] \Package{hyperref} is loaded and by default we try 87 | to add bookmarks in a sensible way; in particular, the bookmarks 88 | levels are automatically reset at \Command{appendix} and 89 | \Command{backmatter}. Moreover, we also provide a small package to 90 | ease the hyperreferencing of other parts of the text. 91 | \item[Bibliography] We want the reader to be able to know what has 92 | been cited without having to go to the end of the document every 93 | time, so citations go in the margins as well as at the end, as in 94 | Tufte-Latex. Unlike that class, however, you are free to customise 95 | the citations as you wish. 96 | \end{description} 97 | 98 | \begin{marginfigure}[-5.5cm] 99 | \includegraphics{monalisa} 100 | \caption[The Mona Lisa]{The Mona Lisa.\\ 101 | \url{https://commons.wikimedia.org/wiki/File:Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg}} 102 | \labfig{marginmonalisa} 103 | \end{marginfigure} 104 | 105 | The order of the title pages, table of contents and preface can be 106 | easily changed, as in any \LaTeX\ document. In addition, the class is 107 | based on \KOMAScript's \Class{scrbook}, therefore it inherits all the 108 | goodies of that. 109 | 110 | \section{What This Class Does Not Do} 111 | \labsec{doesnot} 112 | 113 | As anticipated, further customisation of the book is left to the user. 114 | Indeed, every book may have sidenotes, margin figures and so on, but 115 | each book will have its own fonts, toc style, special environments and 116 | so on. For this reason, in addition to the class, we provide only 117 | sensible defaults, but if these features are not needed, they can be 118 | left out. These special packages are located in the \Path{style} 119 | directory, which is organised as follows: 120 | 121 | \begin{description} 122 | \item[kao.sty] This package contains the most important definitions 123 | of macros and specifications of page layout. It is the heart of the 124 | \Class{kaobook}. Special features include: most commonly used 125 | \LaTeX\ packages are already loaded; there is some flexibility to 126 | change the default layout; some fancy environments (with coloured 127 | boxes around them, floating, and/or with a counter) are predefined. 128 | \item[kaobiblio.sty] Where commands to print citations in the 129 | margins are defined.\sidenote{See \refch{references}.} It is the 130 | \Class{kao-} analog of \Package{biblatex}. 131 | \item[kaorefs.sty] It contains some useful commands to manage 132 | labeling and referencing, again to ensure that the same elements are 133 | referenced always in a consistent way. 134 | \item[kaotheorems.sty] For the style of mathematical environments, 135 | which can be optionally wrapped in a colourful \Package{mdframed} 136 | environment, like in this document, or not. 137 | \end{description} 138 | 139 | \marginnote[2mm]{The audacious users might feel tempted to edit some of 140 | these packages. I'd be immensely happy if they sent me examples of what 141 | they have been able to do!} 142 | 143 | In the rest of the book, I shall assume that the reader is not a novice 144 | in the use of \LaTeX, and refer to the documentation of the packages 145 | used in this class for things that are already explained there. 146 | Moreover, I assume that the reader is willing to make minor edits to the 147 | provided packages for styles, environments and commands, if he or she 148 | does not like the default settings. 149 | 150 | \section{How to Use This Class} 151 | 152 | Either if you are using the template from 153 | \href{http://latextemplates.org/template/kaobook}{latextemplates}, or if 154 | you cloned the GitHub 155 | \href{https://www.github.com/fmarotta/kaobook}{repository}, there are 156 | infinite ways to use the \Class{kaobook} class in practice, but we will 157 | discuss only two of them. The first is to find the \Path{main.tex} file 158 | which I used to write this book, and edit it; this will probably involve 159 | a lot of text-deleting, copying-and-pasting, and rewriting. The second 160 | way is to start almost from scratch and use the 161 | \Path{./examples/minimal\_book/main.tex} file, which is a cleaned-up 162 | version of the \Path{./examples/documentation/main.tex}; even if you 163 | choose the second way, you may find it useful to draw inspiration from 164 | the \Path{./examples/documentation/main.tex} file. 165 | 166 | To compile the document, assuming that its name is \Path{main.tex}, you 167 | will have to run the following sequence of commands: 168 | 169 | \begin{lstlisting}[style=kaolstplain,linewidth=1.5\textwidth] 170 | pdflatex main # Compile template 171 | makeindex main.nlo -s nomencl.ist -o main.nls # Compile nomenclature 172 | makeindex main # Compile index 173 | biber main # Compile bibliography 174 | makeglossaries main # Compile glossary 175 | pdflatex main # Compile template again 176 | pdflatex main # Compile template again 177 | \end{lstlisting} 178 | 179 | You may need to compile the template some more times in order for some 180 | errors to disappear. For any support requests, please ask a question on 181 | \url{tex.stackexchange.org} with the tag \enquote{kaobook}, open an 182 | issue on GitHub, or contact the author via e-mail. 183 | -------------------------------------------------------------------------------- /examples/documentation/chapters/layout.tex: -------------------------------------------------------------------------------- 1 | \setchapterimage[6cm]{seaside} 2 | \setchapterpreamble[u]{\margintoc} 3 | \chapter{Page Design} 4 | \labch{layout} 5 | 6 | \section{Headings} 7 | 8 | So far, in this document I used two different styles for the chapter 9 | headings: one has the chapter name, a rule and, in the margin, the 10 | chapter number; the other has an image at the top of the page, and 11 | the chapter title is printed in a box (like for this chapter). There 12 | is one additional style, which I used only in the \nrefch{appendix}; 13 | there, the chapter title is enclosed in two horizontal rules, and 14 | the chapter number (or letter, in the case of the appendix) is above 15 | it.\sidenote[][.7cm]{To be honest, I do not think that mixing heading 16 | styles like this is a wise choice, but in this document I did it only to 17 | show you how they look.} 18 | 19 | Every book is unique, so it makes sense to have different styles from 20 | which to choose. Actually, it would be awesome if whenever a 21 | \Class{kao}-user designs a new heading style, he or she added it to the 22 | three styles already present, so that it will be available for new users 23 | and new books. 24 | 25 | The choice of the style is made simple by the \Command{setchapterstyle} 26 | command. It accepts one option, the name of the style, which can be: 27 | \enquote{plain}, \enquote{kao}, \enquote{bar}, or 28 | \enquote{lines}.\sidenote{Plain is the default \LaTeX\xspace title 29 | style; the other ones are self explanatory.} If instead you want the 30 | image style, you have to use the command \Command{setchapterimage}, 31 | which accepts the path to the image as argument; you can also provide an 32 | optional parameter in square brackets to specify the height of the 33 | image. \Command{setchapterimage} automatically sets the chapter style to 34 | \enquote{bar} for that chapter (and also for subsequent chapters). 35 | 36 | Let us make some examples. In this book, I begin a normal chapter with 37 | the lines: 38 | \begin{lstlisting} 39 | \setchapterstyle{kao} 40 | \setchapterpreamble[u]{\margintoc} 41 | \chapter{Title of the Chapter} 42 | \labch{title} 43 | \end{lstlisting} 44 | 45 | In Line 1 I choose the style for the title to be \enquote{kao}. Then, I 46 | specify that I want the margin toc. The rest is ordinary administration 47 | in \LaTeX, except that I use my own \Command{labch} to label the 48 | chapter. Actually, the \Command{setchapterpreamble} is a standard 49 | \KOMAScript\xspace one, so I invite you to read about it in the KOMA 50 | documentation. Once the chapter style is set, it holds until you change 51 | it.\sidenote{The \Command{margintoc} has to be specified at every 52 | chapter. Perhaps in the future this may change; it all depends on how 53 | this feature will be welcomed by the users, so keep in touch with me if 54 | you have preferences!} Whenever I want to start a chapter with an image, 55 | I simply write: 56 | 57 | \begin{lstlisting} 58 | \setchapterimage[7cm]{path/to/image.png} % Optionally specify the height 59 | \setchapterpreamble[u]{\margintoc} 60 | \chapter{Catchy Title} % No need to set a chapter style 61 | \labch{catchy} 62 | \end{lstlisting} 63 | 64 | If you prefer, you can also specify the style at the beginning of the 65 | main document, and that style will hold until you change it again. 66 | 67 | \section{Headers \& Footers} 68 | 69 | Headers and footers in \KOMAScript\xspace are handled by the 70 | \Package{scrlayer-scrpage} package. There are two basic style: 71 | \enquote{scrheadings} and \enquote{plain.scrheadings}. The former is 72 | used for normal pages, whereas the latter is used in title pages (those 73 | where a new chapter starts, for instance) and, at least in this book, in 74 | the front matter. At any rate, the style can be changed with the 75 | \Command{pagestyle} command, \eg 76 | \lstinline|\pagestyle{plain.scrheadings}|. 77 | 78 | In both styles, the footer is completely empty. In plain.scrheadings, 79 | also the header is absent (otherwise it wouldn't be so plain\ldots), but 80 | in the normal style the design is reminiscent of the \enquote{kao} style 81 | for chapter titles. 82 | 83 | \section{\Option{twoside} mode} 84 | 85 | \begin{kaobox}[title=To Do] 86 | The \Option{twoside} class option is still unstable and may lead to 87 | unexpected behaviours. Great strides have been done since the first 88 | version of \Class{kaobook}, but some work still needs to be done. As 89 | always, any help will be greatly appreciated. 90 | \end{kaobox} 91 | 92 | By passing the \Option{twoside} option to the \Class{kaobook}, the 93 | style of left and right pages will be different, similarly to a 94 | printed book. In digital books, having a symmetrical layout for 95 | left and right pages is less important, and you may be tempted 96 | to use the \Option{twoside=false} option. However, keep in mind 97 | that in \enquote{oneside} mode the \Command{uppertitleback} and 98 | \Command{lowertitleback} commands are not available.\sidenote{Another 99 | useful thing to keep in mind is that, when \Option{twoside=true}, an 100 | extra white page will be added to the frontmatter.} If you want to have 101 | the upper/lower titleback in a one-side document, just add manually the 102 | contents that you'd put using the upper/lower titleback commands. 103 | 104 | \section{Table of Contents} 105 | 106 | Another important part of a book is the table of contents. By default, 107 | in \Class{kaobook} there is an entry for everything: list of figures, 108 | list of tables, bibliographies, and even the table of contents itself. 109 | Not everybody might like this, so we will provide a description of the 110 | changes you need to do in order to enable or disable each of these 111 | entries. In the following \reftab{tocentries}, each item corresponds to 112 | a possible entry in the \acrshort{tocLabel}, and its description is the 113 | command you need to provide to have such entry. These commands are 114 | specified in the attached \href{style/style.sty}{style 115 | package},\sidenote{In the same file, you can also choose the titles of 116 | these entries.} so if you don't want the entries, just comment the 117 | corresponding lines. 118 | 119 | Of course, some packages, like those for glossaries and indices, will 120 | try to add their own entries.\marginnote{In a later section, we will see 121 | how you can define your own floating environment, and endow it with an 122 | entry in the \acrshort{tocLabel}.} In such cases, you have to follow the 123 | instructions specific to that package. Here, since we have talked about 124 | glossaries and notations in \refch{references}, we will briefly see how 125 | to configure them. 126 | 127 | \begin{table} 128 | \footnotesize 129 | \caption{Commands to add a particular entry to the table of contents.} 130 | \labtab{tocentries} 131 | \begin{tabular}{ l@{\hspace{1mm}}l } 132 | \toprule 133 | Entry & Command to Activate \\ 134 | \midrule 135 | Table of Contents & \lstinline|\setuptoc{toc}{totoc}| \\ 136 | List of Figs/Tabs & \lstinline|\PassOptionsToClass{toc=listof}{\@baseclass}| \\ 137 | Bibliography & \lstinline|\PassOptionsToClass{toc=bibliography}{\@baseclass}| \\ 138 | \bottomrule 139 | \end{tabular} 140 | \end{table} 141 | 142 | For the \Package{glossaries} package, use the \enquote{toc} option when 143 | you load it: \lstinline|\usepackage[toc]{glossaries}|. For 144 | \Package{nomencl}, pass the \enquote{intoc} option at the moment of 145 | loading the package. Both \Package{glossaries} and \Package{nomencl} are 146 | loaded in the attached \href{style/packages.sty}{\enquote{packages} 147 | package}. 148 | 149 | Additional configuration of the table of contents can be performed 150 | through the packages \Package{etoc}, which is loaded because it is 151 | needed for the margintocs, or the more traditional \Package{tocbase}. 152 | Read the respective documentations if you want to be able to change the 153 | default \acrshort{tocLabel} style.\sidenote[][*-1]{(And please, send me 154 | a copy of what you have done, I'm so curious!)} 155 | 156 | \section{Paper Size} 157 | 158 | Recent versions of Kaobook support paper sizes different from the 159 | default A4. It is possible to pass the name of the paper as an option 160 | to the class, as we are accustomed for any other \LaTeX\ class. For 161 | example, the class option \Option{b5paper} would set the paper size 162 | to the B5 format. 163 | 164 | We also support the paper sizes specified in 165 | \href{https://www.bod.de/hilfe/hilfe-und-service.html?cmd=SINGLE\&entryID=2494\_GER\_WSS\&eo=2\&title=welche-buchformate-gibt-es}{this 166 | web page} and some additional sizes requested by the users, with the 167 | option names specified in \reftab{papersizes}. 168 | 169 | \begin{margintable}[*-6] 170 | \caption{Some non-standard paper sizes supported by kaobook.} 171 | \labtab{papersizes} 172 | \begin{tabular}{ll} 173 | \toprule 174 | Dimension & Option name \\ 175 | \midrule 176 | 12.0cm x 19.0cm & smallpocketpaper \\ 177 | 13.5cm x 21.5cm & pocketpaper \\ 178 | 14.8cm x 21.0cm & a5paper \\ 179 | 15.5cm x 22.0cm & juvenilepaper \\ 180 | 17.0cm x 17.0cm & smallphotopaper \\ 181 | 21.0cm x 15.0cm & appendixpaper \\ 182 | 17.0cm x 22.0cm & cookpaper \\ 183 | 19.0cm x 27.0cm & illustratedpaper \\ 184 | 17.0cm x 17.0cm & photopaper \\ 185 | 16.0cm x 24.0cm & f24paper \\ 186 | %21.0cm x 29.7cm & a4paper \\ 187 | \bottomrule 188 | \end{tabular} 189 | \end{margintable} 190 | 191 | For instance, to use the \enquote{smallpocketpaper} add the correct 192 | description at the beginning of the documentclass instruction: 193 | \begin{lstlisting} 194 | \documentclass[ 195 | smallpocketpaper, 196 | fontsize=10pt, 197 | twoside=false, 198 | %open=any, 199 | secnumdepth=1, 200 | ]{kaobook} 201 | \end{lstlisting} 202 | 203 | Sometimes it is convenient to adopt a landscape view; \Class{kaobook} 204 | provides two additional options, \Option{a4paperlandscape} and 205 | \Option{169paperlandscape}, which set the page in landscape mode with 206 | width-to-height ratios of, respectively, 1.414 and 16:9. 207 | 208 | \section{Page Layout} 209 | 210 | Besides the page style, you can also change the width of the content of 211 | a page. This is particularly useful for pages dedicated to part titles, 212 | where having the 1.5-column layout might be a little awkward, or for 213 | pages where you only put figures, where it is important to exploit all 214 | the available space. 215 | 216 | In practice, there are two layouts: \enquote{wide} and \enquote{margin}. 217 | The former suppresses the margins and allocates the full page for 218 | contents, while the latter is the layout used in most of the pages of 219 | this book, including this one. The wide layout is also used 220 | automatically in the front and back matters. 221 | 222 | \marginnote{Sometimes it is desirable to increase the width for just one 223 | or a few paragraphs; the \Environment{widepar} environment does that: 224 | wrap your paragraphs in this environment, and they will occupy the full 225 | width of the page.} 226 | 227 | To change page layout, use the \Command{pagelayout} command. For 228 | example, when I start a new part, I write: 229 | 230 | \begin{lstlisting} 231 | \pagelayout{wide} 232 | \addpart{Title of the New Part} 233 | \pagelayout{margin} 234 | \end{lstlisting} 235 | 236 | Beyond these two basic layouts, it is also possible to finely tune the 237 | page layout by redefining the \Command{marginlayout} command. This 238 | command is called internally by the higher-level \Command{pagelayout}, 239 | and it is responsible for setting the width of the margins and of the 240 | text. The default definition is: 241 | 242 | \begin{lstlisting} 243 | \newcommand{\marginlayout}{% 244 | \newgeometry{ 245 | top=27.4mm, % height of the top margin 246 | bottom=27.4mm, % height of the bottom margin 247 | inner=24.8mm, % width of the inner margin 248 | textwidth=107mm, % width of the text 249 | marginparsep=8.2mm, % width between text and margin 250 | marginparwidth=49.4mm, % width of the margin 251 | }% 252 | } 253 | \end{lstlisting} 254 | 255 | so if you want to, say, decrease the width of the margin while 256 | increasing the width of the text, you could write in the preamble of 257 | your document something like: 258 | 259 | \begin{lstlisting} 260 | \renewcommand{\marginlayout}{% 261 | \newgeometry{ 262 | top=27.4mm, % height of the top margin 263 | bottom=27.4mm, % height of the bottom margin 264 | inner=24.8mm, % width of the inner margin 265 | textwidth=117mm, % width of the text 266 | marginparsep=8.2mm, % width between text and margin 267 | marginparwidth=39.4mm, % width of the margin 268 | }% 269 | } 270 | \end{lstlisting} 271 | 272 | where the text width has been increased by 10mm and the margin width has 273 | been decreased by 10mm. 274 | 275 | \section{Numbers \& Counters} 276 | 277 | In this short section we shall see how dispositions, sidenotes and 278 | figures are numbered in the \Class{kaobook} class. 279 | 280 | By default, dispositions are numbered up to the section in \Class{kaobook} 281 | and up to the subsection in \Class{kaohandt}. This can be changed by 282 | passing the option \Option{secnumdepth} to\Class{kaobook} or 283 | \Class{kaohandt} (e.g. 1 corresponds to section and 2 corresponds to 284 | subsections). 285 | 286 | The sidenotes counter is the same across all the document, but if you 287 | want it to reset at each chapter, just uncomment the line 288 | 289 | \begin{lstlisting}[style=kaolstplain] 290 | \counterwithin*{sidenote}{chapter} 291 | \end{lstlisting} 292 | 293 | in the \Package{styles/style.sty} package provided by this class. 294 | 295 | Figure and Table numbering is also per-chapter; to change that, use 296 | something like: 297 | 298 | \begin{lstlisting}[style=kaolstplain] 299 | \renewcommand{\thefigure}{\arabic{section}.\arabic{figure}} 300 | \end{lstlisting} 301 | 302 | \section{White Space} 303 | 304 | One of the things that I find most hard in \LaTeX\xspace is to finely 305 | tune the white space around objects. There are not fixed rules, each 306 | object needs its own adjustment. Here we shall see how some spaces are 307 | defined at the moment in this class.\marginnote{Attention! This section 308 | may be incomplete.} 309 | 310 | \textbf{Space around sidenotes and citations marks} 311 | 312 | There should be no space before or after sidenotes and citation marks, 313 | like so: 314 | 315 | sidenote\sidenote{This paragraph can be used to diagnose any problems: 316 | if you see whitespace around sidenotes or citation marks, probably 317 | a \% sign is missing somewhere in the definitions of the class 318 | macros.}sidenote\newline 319 | citation\cite{James2013}citation 320 | 321 | \textbf{Space around figures and tables} 322 | 323 | \begin{lstlisting}[style=kaolstplain] 324 | \renewcommand\FBaskip{.4\topskip} 325 | \renewcommand\FBbskip{\FBaskip} 326 | \end{lstlisting} 327 | 328 | \textbf{Space around captions} 329 | 330 | \begin{lstlisting}[style=kaolstplain] 331 | \captionsetup{ 332 | aboveskip=6pt, 333 | belowskip=6pt 334 | } 335 | \end{lstlisting} 336 | 337 | \textbf{Space around displays (\eg equations)} 338 | 339 | \begin{lstlisting}[style=kaolstplain] 340 | \setlength\abovedisplayskip{6pt plus 2pt minus 4pt} 341 | \setlength\belowdisplayskip{6pt plus 2pt minus 4pt} 342 | \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ 343 | \abovedisplayshortskip \z@ \@plus3\p@ 344 | \belowdisplayskip \abovedisplayskip 345 | \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ 346 | \end{lstlisting} 347 | -------------------------------------------------------------------------------- /examples/documentation/chapters/mathematics.tex: -------------------------------------------------------------------------------- 1 | \setchapterstyle{kao} 2 | \setchapterpreamble[u]{\margintoc} 3 | \chapter{Mathematics and Boxes} 4 | \labch{mathematics} 5 | 6 | \section{Theorems} 7 | 8 | Despite most people complain at the sight of a book full of equations, 9 | mathematics is an important part of many books. Here, we shall 10 | illustrate some of the possibilities. We believe that theorems, 11 | definitions, remarks and examples should be emphasised with a shaded 12 | background; however, the colour should not be to heavy on the eyes, so 13 | we have chosen a sort of light yellow.\sidenote{The boxes are all of the 14 | same colour here, because we did not want our document to look like 15 | \href{https://en.wikipedia.org/wiki/Harlequin}{Harlequin}.} 16 | 17 | \begin{definition} 18 | \labdef{openset} 19 | Let $(X, d)$ be a metric space. A subset $U \subset X$ is an open set 20 | if, for any $x \in U$ there exists $r > 0$ such that $B(x, r) \subset 21 | U$. We call the topology associated to d the set $\tau\textsubscript{d}$ 22 | of all the open subsets of $(X, d).$ 23 | \end{definition} 24 | 25 | \refdef{openset} is very important. I am not joking, but I have inserted 26 | this phrase only to show how to reference definitions. The following 27 | statement is repeated over and over in different environments. 28 | 29 | \begin{theorem} 30 | A finite intersection of open sets of (X, d) is an open set of (X, d), 31 | i.e $\tau\textsubscript{d}$ is closed under finite intersections. Any 32 | union of open sets of (X, d) is an open set of (X, d). 33 | \end{theorem} 34 | 35 | \begin{proposition} 36 | A finite intersection of open sets of (X, d) is an open set of (X, d), 37 | i.e $\tau\textsubscript{d}$ is closed under finite intersections. Any 38 | union of open sets of (X, d) is an open set of (X, d). 39 | \end{proposition} 40 | 41 | \marginnote{You can even insert footnotes inside the theorem 42 | environments; they will be displayed at the bottom of the box.} 43 | 44 | \begin{lemma} 45 | A finite intersection\footnote{I'm a footnote} of open sets of (X, d) is 46 | an open set of (X, d), i.e $\tau\textsubscript{d}$ is closed under 47 | finite intersections. Any union of open sets of (X, d) is an open set of 48 | (X, d). 49 | \end{lemma} 50 | 51 | You can safely ignore the content of the theorems\ldots I assume that if 52 | you are interested in having theorems in your book, you already know 53 | something about the classical way to add them. These example should just 54 | showcase all the things you can do within this class. 55 | 56 | \begin{corollary}[Finite Intersection, Countable Union] 57 | A finite intersection of open sets of (X, d) is an open set of (X, d), 58 | i.e $\tau\textsubscript{d}$ is closed under finite intersections. Any 59 | union of open sets of (X, d) is an open set of (X, d). 60 | \end{corollary} 61 | 62 | \begin{proof} 63 | The proof is left to the reader as a trivial exercise. Hint: \blindtext 64 | \end{proof} 65 | 66 | \begin{definition} 67 | Let $(X, d)$ be a metric space. A subset $U \subset X$ is an open set 68 | if, for any $x \in U$ there exists $r > 0$ such that $B(x, r) \subset 69 | U$. We call the topology associated to d the set $\tau\textsubscript{d}$ 70 | of all the open subsets of $(X, d).$ 71 | \end{definition} 72 | 73 | \marginnote{ 74 | Here is a random equation, just because we can: 75 | \begin{equation*} 76 | x = a_0 + \cfrac{1}{a_1 77 | + \cfrac{1}{a_2 78 | + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } } 79 | \end{equation*} 80 | } 81 | 82 | \begin{example} 83 | Let $(X, d)$ be a metric space. A subset $U \subset X$ is an open set 84 | if, for any $x \in U$ there exists $r > 0$ such that $B(x, r) \subset 85 | U$. We call the topology associated to d the set $\tau\textsubscript{d}$ 86 | of all the open subsets of $(X, d).$ 87 | \end{example} 88 | 89 | \begin{remark} 90 | Let $(X, d)$ be a metric space. A subset $U \subset X$ is an open set 91 | if, for any $x \in U$ there exists $r > 0$ such that $B(x, r) \subset 92 | U$. We call the topology associated to d the set $\tau\textsubscript{d}$ 93 | of all the open subsets of $(X, d).$ 94 | \end{remark} 95 | 96 | As you may have noticed, definitions, example and remarks have 97 | independent counters; theorems, propositions, lemmas and corollaries 98 | share the same counter. 99 | 100 | \begin{remark} 101 | Here is how an integral looks like inline: $\int_{a}^{b} x^2 dx$, and 102 | here is the same integral displayed in its own paragraph: 103 | \[\int_{a}^{b} x^2 dx\] 104 | \end{remark} 105 | 106 | There is also an environment for exercises. 107 | 108 | \begin{exercise} 109 | Prove (or disprove) the Riemann hypothesis. 110 | \end{exercise} 111 | 112 | We provide one package for the theorem styles: 113 | \href{kaotheorems.sty}{kaotheorems.sty}, to which you can pass the 114 | \Option{framed} option you do want coloured boxes around theorems, like 115 | in this document.\sidenote{The styles without \Option{framed} are not 116 | showed, but actually the only difference is that they don't have the 117 | yellow boxes.} You may want to edit this files according to your taste 118 | and the general style of the book. However, there is an option to 119 | customise the background colour of the boxes if you use the 120 | \Option{framed} option: when you load this package, you can pass it the 121 | \Option{background=mycolour} option (replace \enquote{mycolour} with the 122 | actual colour, for instance, \enquote{red!35!white}). This will change 123 | the colour of all the boxes, but it is also possible to override the 124 | default colour only for some elements. For instance, the 125 | \Option{propositionbackground=mycolour} option will change the colour 126 | for propositions only. There are similar options for theorem, 127 | definition, lemma, corollary, remark, and example. 128 | 129 | \section[Boxes \& Environments]{Boxes \& Custom Environments 130 | \sidenote[][*1.8]{Notice that in the table of contents and in the 131 | header, the name of this section is \enquote{Boxes \& Environments}; 132 | we achieved this with the optional argument of the \texttt{section} 133 | command.}} 134 | 135 | Say you want to insert a special section, an optional content or just 136 | something you want to emphasise. We think that nothing works better than 137 | a box in these cases. We used \Package{mdframed} to construct the ones 138 | shown below. You can create and modify such environments by editing the 139 | provided file \href{kao.sty}{kao.sty}. 140 | 141 | \begin{kaobox}[title=Title of the box] 142 | \blindtext 143 | \end{kaobox} 144 | 145 | If you set up a counter, you can even create your own numbered 146 | environment. 147 | 148 | \begin{kaocounter} 149 | \blindtext 150 | \end{kaocounter} 151 | 152 | \section{Experiments} 153 | 154 | It is possible to wrap marginnotes inside boxes, too. Audacious readers 155 | are encouraged to try their own experiments and let me know the 156 | outcomes. 157 | 158 | \marginnote[-2.2cm]{ 159 | \begin{kaobox}[title=title of margin note] 160 | Margin note inside a kaobox.\\ 161 | (Actually, kaobox inside a marginnote!) 162 | \end{kaobox} 163 | } 164 | 165 | I believe that many other special things are possible with the 166 | \Class{kaobook} class. During its development, I struggled to keep it as 167 | flexible as possible, so that new features could be added without too 168 | great an effort. Therefore, I hope that you can find the optimal way to 169 | express yourselves in writing a book, report or thesis with this class, 170 | and I am eager to see the outcomes of any experiment that you may try. 171 | 172 | %\begin{margintable} 173 | %\captionsetup{type=table,position=above} 174 | %\begin{kaobox} 175 | %\caption{caption} 176 | %\begin{tabular}{ |c|c|c|c| } 177 | %\hline 178 | %col1 & col2 & col3 \\ 179 | %\hline 180 | %\multirow{3}{4em}{Multiple row} & cell2 & cell3 \\ & cell5 181 | %%& cell6 \\ 182 | %& cell8 & cell9 \\ 183 | %\hline 184 | %\end{tabular} 185 | %\end{kaobox} 186 | %\end{margintable} 187 | -------------------------------------------------------------------------------- /examples/documentation/chapters/options.tex: -------------------------------------------------------------------------------- 1 | \setchapterpreamble[u]{\margintoc} 2 | \chapter{Class Options} 3 | \labch{options} 4 | 5 | In this chapter I will describe the most common options used, both the 6 | ones inherited from \Class{scrbook} and the \Class{kao}-specific ones. 7 | Options passed to the class modifies its default behaviour; beware 8 | though that some options may lead to unexpected results\ldots 9 | 10 | \section{\Class{KOMA} Options} 11 | 12 | The \Class{kaobook} class is based on \Class{scrbook}, therefore it 13 | understands all of the options you would normally pass to that class. If 14 | you have a lot of patience, you can read the \KOMAScript\xspace 15 | guide.\sidenote{The guide can be downloaded from 16 | \url{https://ctan.org/pkg/koma-script?lang=en}.} Actually, the reading 17 | of such guide is suggested as it is very instructive. 18 | 19 | Every \KOMAScript\xspace option you pass to the class when you load it 20 | is automatically activated. In addition, in \Class{kaobook} some options 21 | have modified default values. For instance, the font size is 9.5pt and 22 | the paragraphs are separated by space,\sidenote[][-7mm]{To be precise, 23 | they are separated by half a line worth of space: the \Option{parskip} 24 | value is \enquote{half}.} not marked by indentation. 25 | 26 | \section{\Class{kao} Options} 27 | 28 | In the future I plan to add more options to set the paragraph formatting 29 | (justified or ragged) and the position of the margins (inner or outer in 30 | twoside mode, left or right in oneside mode).\sidenote{As of now, 31 | paragraphs are justified, formatted with \Command{singlespacing} (from 32 | the \Package{setspace} package) and \Command{frenchspacing}.} 33 | 34 | I take this opportunity to renew the call for help: everyone is 35 | encouraged to add features or reimplement existing ones, and to send me 36 | the results. You can find the GitHub repository at 37 | \url{https://github.com/fmarotta/kaobook}. 38 | 39 | \begin{kaobox}[title=To Do] 40 | Implement the \Option{justified} and \Option{margin} options. To be 41 | consistent with the \KOMAScript\xspace style, they should accept a 42 | simple switch as a parameter, where the simple switch should be 43 | \Option{true} or \Option{false}, or one of the other standard values for 44 | simple switches supported by \KOMAScript. See the \KOMAScript\xspace 45 | documentation for further information. 46 | \end{kaobox} 47 | 48 | The above box is an example of a \Environment{kaobox}, which will be 49 | discussed more thoroughly in \frefch{mathematics}. Throughout the book I 50 | shall use these boxes to remarks what still needs to be done. 51 | 52 | \section{Other Things Worth Knowing} 53 | 54 | A bunch of packages are already loaded in the class because they are 55 | needed for the implementation. These include: 56 | 57 | \begin{itemize} 58 | \item etoolbox 59 | \item calc 60 | \item xifthen 61 | \item xkeyval 62 | \item xparse 63 | \item xstring 64 | \end{itemize} 65 | 66 | Many more packages are loaded, but they will be discussed in due time. 67 | Here, we will mention only one more set of packages, needed to change 68 | the paragraph formatting (recall that in the future there will be 69 | options to change this). In particular, the packages we load are: 70 | 71 | \begin{itemize} 72 | \item ragged2e 73 | \item setspace 74 | \item hyphenat 75 | \item microtype 76 | \item needspace 77 | \item xspace 78 | \item xcolor (with options \Option{usenames,dvipsnames}) 79 | \end{itemize} 80 | 81 | Some of the above packages do not concern paragraph formatting, but we 82 | nevertheless grouped them with the others. By default, the main text is 83 | justified and formatted with singlespacing and frenchspacing; the margin 84 | text is the same, except that the font is a bit smaller. 85 | 86 | As a last warning, please be aware that the \Package{cleveref} package 87 | is not compatible with \Class{kaobook}. You should use the commands 88 | discussed in \refsec{hyprefs} instead. 89 | 90 | \section{Document Structure} 91 | 92 | We provide optional arguments to the \Command{title} and 93 | \Command{author} commands so that you can insert short, plain text 94 | versions of this fields, which can be used, typically in the half-title 95 | or somewhere else in the front matter, through the commands 96 | \Command{@plaintitle} and \Command{@plainauthor}, respectively. The PDF 97 | properties \Option{pdftitle} and \Option{pdfauthor} are automatically 98 | set by hyperref to the plain values if present, otherwise to the normal 99 | values.\sidenote[][*-1]{We think that this is an important point so 100 | we remark it here. If you compile the document with pdflatex, the PDF 101 | metadata will be altered so that they match the plain title and author 102 | you have specified; if you did not specify them, the metadata will be 103 | set to the normal title and author.} 104 | 105 | There are defined two page layouts, \Option{margin} and \Option{wide}, 106 | and two page styles, \Option{plain} and \Option{fancy}. The layout 107 | basically concern the width of the margins, while the style refers to 108 | headers and footer; these issues will be 109 | discussed in \frefch{layout}.\sidenote[][6mm]{For now, suffice it to say that pages with 110 | the \Option{margin} layout have wide margins, while with the 111 | \Option{wide} layout the margins are absent. In \Option{plain} pages the 112 | headers and footer are suppressed, while in \Option{fancy} pages there 113 | is a header.} 114 | 115 | The commands \Command{frontmatter}, \Command{mainmatter}, and 116 | \Command{backmatter} have been redefined in order to automatically 117 | change page layout and style for these sections of the book. The front 118 | matter uses the \Option{margin} layout and the \Option{plain} page 119 | style. In the mainmatter the margins are wide and the headings are 120 | fancy. In the appendix the style and the layout do not change; however 121 | we use \Command{bookmarksetup\{startatroot\}} so that the bookmarks of 122 | the chapters are on the root level (without this, they would be under 123 | the preceding part). In the backmatter the margins shrink again and we 124 | also reset the bookmarks root. 125 | -------------------------------------------------------------------------------- /examples/documentation/chapters/preface.tex: -------------------------------------------------------------------------------- 1 | \chapter*{Preface} 2 | \addcontentsline{toc}{chapter}{Preface} % Add the preface to the table of contents as a chapter 3 | 4 | I am of the opinion that every \LaTeX\xspace geek, at least once during 5 | his life, feels the need to create his or her own class: this is what 6 | happened to me and here is the result, which, however, should be seen as 7 | a work still in progress. Actually, this class is not completely 8 | original, but it is a blend of all the best ideas that I have found in a 9 | number of guides, tutorials, blogs and tex.stackexchange.com posts. In 10 | particular, the main ideas come from two sources: 11 | 12 | \begin{itemize} 13 | \item \href{https://3d.bk.tudelft.nl/ken/en/}{Ken Arroyo Ohori}'s 14 | \href{https://3d.bk.tudelft.nl/ken/en/nl/ken/en/2016/04/17/a-1.5-column-layout-in-latex.html}{Doctoral 15 | Thesis}, which served, with the author's permission, as a backbone 16 | for the implementation of this class; 17 | \item The 18 | \href{https://github.com/Tufte-LaTeX/tufte-latex}{Tufte-Latex 19 | Class}, which was a model for the style. 20 | \end{itemize} 21 | 22 | The first chapter of this book is introductory and covers the most 23 | essential features of the class. Next, there is a bunch of chapters 24 | devoted to all the commands and environments that you may use in writing 25 | a book; in particular, it will be explained how to add notes, figures 26 | and tables, and references. The second part deals with the page layout 27 | and design, as well as additional features like coloured boxes and 28 | theorem environments. 29 | 30 | I started writing this class as an experiment, and as such it should be 31 | regarded. Since it has always been intended for my personal use, it may 32 | not be perfect but I find it quite satisfactory for the use I want to 33 | make of it. I share this work in the hope that someone might find here 34 | the inspiration for writing his or her own class. 35 | 36 | \begin{flushright} 37 | \textit{Federico Marotta} 38 | \end{flushright} 39 | -------------------------------------------------------------------------------- /examples/documentation/chapters/references.tex: -------------------------------------------------------------------------------- 1 | \setchapterstyle{kao} 2 | %\setchapterpreamble[u]{\margintoc} 3 | \chapter{References} 4 | \labch{references} 5 | 6 | \section{Citations} 7 | 8 | \index{citations} 9 | To cite someone \sidecite{Visscher2008,James2013} is very simple: just 10 | use the \Command{sidecite}\index{\Command{sidecite}} command. It does 11 | not have an offset argument yet, but it probably will in the future. 12 | This command supports multiple entries, as you can see, and by default 13 | it prints the reference on the margin as well as adding it to the 14 | bibliography at the end of the document. Note that the citations have 15 | nothing to do with the text,\sidecite{James2013} but they are completely 16 | random as they only serve the purpose to illustrate the feature. 17 | 18 | For this setup I wrote a separate package, \Package{kaobiblio}, which 19 | you can find in the \Package{styles} directory and include in your main 20 | tex file. This package accepts all the options that you can pass to 21 | \Package{biblatex}, and actually it passes them to \Package{biblatex} 22 | under the hood. Moreover, it also defines some commands, like 23 | \Command{sidecite}, and environments that can be used within a 24 | \Class{kao} book.\sidenote[][-.9cm]{For this reason you should always 25 | use \Package{kaobiblio} instead of \Package{biblatex}, but the syntax 26 | and the options are exactly the same.} 27 | 28 | If you want to use \Package{bibtex} instead of \Package{biblatex}, 29 | pass the option \Option{backend=bibtex} to \Package{kaobiblio}. 30 | \Package{kaobiblio} also supports two options that are not shared with 31 | \Package{biblatex}: \Option{addspace} and \Option{linkeverything}, 32 | both of which are boolean options, meaning that they can take 33 | either \enquote{true} or \enquote{false} as a value. If you 34 | pass \Option{addspace=true} when loading \Package{kaobiblio}, 35 | a space will be automatically added before the citation marks. 36 | If you pass \Option{linkeverything=true}, the author's name in 37 | the authoryear-* and authortitle-* styles will be a hyperlink 38 | like the year.\sidenote{The fact that the author name is not 39 | a hyperlink bothers more than one biblatex user. There are 40 | \href{https://github.com/plk/biblatex/issues/428}{strong arguments} 41 | \emph{against} hyperlinking the author name, but in my personal opinion, 42 | linking the author's name does not result in any problems in most 43 | practical cases.} 44 | 45 | As you have seen, the \Command{sidecite} command will print a citation 46 | in the margin. However, this command would be useless without a way to 47 | customise the format of the citation, so the \Class{kaobook} provides 48 | also the \Command{formatmargincitation} command. By \enquote{renewing} 49 | that command, you can choose which items will be printed in the margins. 50 | The best way to understand how it works is to see the actual definition 51 | of this command. 52 | 53 | \begin{lstlisting}[style=kaolstplain,linewidth=1.5\textwidth] 54 | \newcommand{\formatmargincitation}[1]{% 55 | \parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}% 56 | } 57 | \end{lstlisting} 58 | 59 | Thus, the \Command{formatmargincitation} accepts one parameter, which is 60 | the citation key, and prints the parencite followed by a colon, then the 61 | author, then the year (in brackets), and finally the 62 | title.\sidecite{Battle2014} Now, suppose that you wish the margin 63 | citation to display the year and the author, followed by the title, and 64 | finally a fixed arbitrary string; you would add to your document: 65 | 66 | \begin{lstlisting}[style=kaolstplain,linewidth=1.5\textwidth] 67 | \renewcommand{\formatmargincitation}[1]{% 68 | \citeyear{#1}, \citeauthor*{#1}: \citetitle{#1}; very interesting!% 69 | } 70 | \end{lstlisting} 71 | 72 | \renewcommand{\formatmargincitation}[1]{% 73 | \citeyear{#1}, \citeauthor*{#1}: \citetitle{#1}; very interesting!% 74 | } 75 | 76 | The above code results in citations that look like the 77 | following.\sidecite{Zou2005} Of course, changing the format is most 78 | useful when you also change the default bibliography style. For 79 | instance, if you want to use the \enquote{philosophy-modern} style for 80 | your bibliography, you might have something like this in the preamble: 81 | 82 | \begin{lstlisting}[style=kaolstplain,linewidth=1.5\textwidth] 83 | \usepackage[style=philosophy-modern]{styles/kaobiblio} 84 | \renewcommand{\formatmargincitation}[1]{% 85 | \sdcite{#1}% 86 | } 87 | \addbibresource{main.bib} 88 | \end{lstlisting} 89 | 90 | \renewcommand{\formatmargincitation}[1]{% 91 | \parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}% 92 | } 93 | 94 | The commands like \Command{citeyear}, \Command{parencite} 95 | and \Command{sdcite} are just examples. A full 96 | reference of the available commands can be found in this 97 | \href{http://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf}{cheatsheet}, 98 | under the \enquote{Citations} section. 99 | 100 | Finally, to compile a document containing citations, you need to use an 101 | external tool, which for this class is biber. You need to run the 102 | following (assuming that your tex file is called main.tex): 103 | 104 | \begin{lstlisting}[style=kaolstplain] 105 | $ pdflatex main 106 | $ biber main 107 | $ pdflatex main 108 | \end{lstlisting} 109 | 110 | \section{Glossaries and Indices} 111 | 112 | \index{glossary} 113 | The \Class{kaobook} class loads the packages \Package{glossaries} and 114 | \Package{imakeidx}, with which you can add glossaries and indices to 115 | your book. For instance, I previously defined some glossary entries and 116 | now I am going to use them, like this: \gls{computer}. 117 | \Package{glossaries} also allows you to use acronyms, like the 118 | following: this is the full version, \acrfull{fpsLabel}, and this is the 119 | short one \acrshort{fpsLabel}. These entries will appear in the glossary 120 | in the backmatter. 121 | 122 | Unless you use \href{https://www.overleaf.com}{Overleaf} or some other 123 | fancy IDE for \LaTeX, you need to run an external command from your 124 | terminal in order to compile a document with a glossary. In particular, 125 | the commands required are:\sidenote{These are the commands you would run 126 | in a UNIX system, but see also \nrefsec{compiling}; I have no idea about 127 | how it works in Windows.} 128 | 129 | \begin{lstlisting}[style=kaolstplain] 130 | $ pdflatex main 131 | $ makeglossaries main 132 | $ pdflatex main 133 | \end{lstlisting} 134 | 135 | Note that you need not run \texttt{makeglossaries} every time you 136 | compile your document, but only when you change the glossary entries. 137 | 138 | \index{index} 139 | To create an index, you need to insert the command 140 | \lstinline|\index{subject}| whenever you are talking about 141 | \enquote{subject} in the text. For instance, at the start of this 142 | paragraph I would write \lstinline|index{index}|, and an entry would be 143 | added to the Index in the backmatter. Check it out! 144 | 145 | \marginnote[2mm]{In theory, you would need to run an external command 146 | for the index as well, but luckily the package we suggested, 147 | \Package{imakeidx}, can compile the index automatically.} 148 | 149 | \index{nomenclature} 150 | A nomenclature is just a special kind of index; you can find one at the end of 151 | this book. To insert a nomenclature, we use the package \Package{nomencl} and 152 | add the terms with the command \Command{nomenclature}. We put then a 153 | \Command{printnomenclature} where we want it to appear. 154 | 155 | Also with this package we need to run an external command to compile the 156 | document, otherwise the nomenclature will not appear: 157 | 158 | \begin{lstlisting}[style=kaolstplain] 159 | $ pdflatex main 160 | $ makeindex main.nlo -s nomencl.ist -o main.nls 161 | $ pdflatex main 162 | \end{lstlisting} 163 | 164 | These packages are all loaded in 165 | \href{style/packages.sty}{packages.sty}, one of the files that come with 166 | this class. However, the configuration of the elements is best done in 167 | the main.tex file, since each book will have different entries and 168 | styles. 169 | 170 | Note that the \Package{nomencl} package caused problems when the 171 | document was compiled, so, to make a long story short, I had to prevent 172 | \Package{scrhack} to load the hack-file for \Package{nomencl}. When 173 | compiling the document on Overleaf, however, this problem seem to 174 | vanish. 175 | 176 | \marginnote[-19mm]{This brief section was by no means a complete 177 | reference on the subject, therefore you should consult the documentation 178 | of the above package to gain a full understanding of how they work.} 179 | 180 | \section{Hyperreferences} 181 | \labsec{hyprefs} 182 | 183 | \index{hyperreferences} 184 | Together with this class we provide a handy package to help you 185 | referencing the same elements always in the same way, for consistency 186 | across the book. First, you can label each element with a specific 187 | command. For instance, should you want to label a chapter, you would put 188 | \lstinline|\labch{chapter-title}| right after the \Command{chapter} 189 | directive. This is just a convenience, because \Command{labch} is 190 | actually just an alias to \lstinline|\label{ch:chapter-title}|, so it 191 | spares you the writing of \enquote{ch:}. We defined similar commands for 192 | many typically labeled elements, including: 193 | 194 | \begin{multicols}{2} 195 | \setlength{\columnseprule}{0pt} 196 | \begin{itemize} 197 | \item Page: \Command{labpage} 198 | \item Part: \Command{labpart} 199 | \item Chapter: \Command{labch} 200 | \item Section: \Command{labsec} 201 | \item Figure: \Command{labfig} 202 | \item Table: \Command{labtab} 203 | \item Definition: \Command{labdef} 204 | \item Assumption: \Command{labassum} 205 | \item Theorem: \Command{labthm} 206 | \item Proposition: \Command{labprop} 207 | \item Lemma: \Command{lablemma} 208 | \item Remark: \Command{labremark} 209 | \item Example: \Command{labexample} 210 | \item Exercise: \Command{labexercise} 211 | \end{itemize} 212 | \end{multicols} 213 | 214 | Of course, we have similar commands for referencing those elements. 215 | However, since the style of the reference should depend on the context, 216 | we provide different commands to reference the same thing. For instance, 217 | in some occasions you may want to reference the chapter by name, but 218 | other times you want to reference it only by number. In general, there 219 | are four reference style, which we call plain, vario, name, and full. 220 | 221 | The plain style references only by number. It is accessed, for chapters, 222 | with \lstinline|\refch{chapter-title}| (for other elements, the syntax 223 | is analogous). Such a reference results in: \refch{references}. 224 | 225 | The vario and name styles rest upon the \Package{varioref} package. 226 | Their syntax is \lstinline|\vrefch{chapter-title}| and 227 | \lstinline|\nrefch{chapter-title}|, and they result in: 228 | \vrefch{references}, for the vario style, and: \nrefch{references}, for 229 | the name style. As you can see, the page is referenced in 230 | \Package{varioref} style. 231 | 232 | The full style references everything. You can use it with 233 | \lstinline|\frefch{chapter-title}| and it looks like this: 234 | \frefch{references}. 235 | 236 | Of course, all the other elements have similar commands (\eg for parts 237 | you would use \lstinline|\vrefpart{part-title}| or something like that). 238 | However, not all elements implement all the four styles. The commands 239 | provided should be enough, but if you want to see what is available or 240 | to add the missing ones, have a look at the 241 | \href{styles/kaorefs.sty}{attached package}. 242 | 243 | In order to have access to all these features, the \Package{kaorefs} 244 | should be loaded in the preamble of your document. It should be loaded 245 | last, or at least after \Package{babel} (or \Package{polyglossia}) and 246 | \Package{plaintheorems} (or \Package{mdftheorems}). Options can be 247 | passed to it like to any other package; in particular, it is possible to 248 | specify the language of the captions. For instance, if you specify 249 | \enquote{italian} as an option, instead of \enquote{Chapter} it will be 250 | printed \enquote{Capitolo}, the Italian analog. If you know other 251 | languages, you are welcome to contribute the translations of these 252 | captions! Feel free to contact the author of the class for further 253 | details. 254 | 255 | The \Package{kaorefs} package also include \Package{cleveref}, so it is 256 | possible to use \Command{cref} in addition to all the previously 257 | described referencing commands. 258 | 259 | \section{A Final Note on Compilation} 260 | \labsec{compiling} 261 | 262 | Probably the easiest way to compile a latex document is with the 263 | \Package{latexmk} script, as it can take care of everything, if properly 264 | configured, from the bibliography to the glossary. The command to issue, 265 | in general, is: 266 | 267 | \begin{lstlisting} 268 | latexmk [latexmk_options] [filename ...] 269 | \end{lstlisting} 270 | 271 | \Package{latexmk} can be extensively configured (see 272 | \url{https://mg.readthedocs.io/latexmk.html}). For convenience, I print 273 | here an example configuration that would cover all the steps described 274 | above. 275 | 276 | \begin{lstlisting} 277 | # By default compile only the file called 'main.tex' 278 | @default_files = ('main.tex'); 279 | 280 | # Compile the glossary and acronyms list (package 'glossaries') 281 | add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' ); 282 | add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' ); 283 | $clean_ext .= " acr acn alg glo gls glg"; 284 | sub makeglossaries { 285 | my ($base_name, $path) = fileparse( $_[0] ); 286 | pushd $path; 287 | my $return = system "makeglossaries", $base_name; 288 | popd; 289 | return $return; 290 | } 291 | 292 | # Compile the nomenclature (package 'nomencl') 293 | add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' ); 294 | sub makenlo2nls { 295 | system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" ); 296 | } 297 | \end{lstlisting} 298 | 299 | However, if you'd rather not use an external package and want to do 300 | everything manually, here are some tips.\sidenote{As the author only 301 | uses Linux and compiles everything from the command line, he doesn't 302 | know how the compilation works in Windows or Mac. The tips, therefore, 303 | refer to the usage with Linux from the command line.} 304 | 305 | \minisec{Compiling the examples in the kaobook repository} 306 | To compile the examples, and in particular the documentation, that are 307 | in the \Path{examples} directory of the 308 | \href{https://github.com/fmarotta/kaobook}{kaobook repository} on 309 | GitHub, do as follows. \lstinline[language=bash]|cd| into the root 310 | directory of the repository, and run 311 | \lstinline|pdflatex -output-directory examples/documentation main.tex|. 312 | With this trick, you can compile the documentation using the class files 313 | pertaining to the repository (and not, say, those in your texmf tree). 314 | The \enquote{-output-directory} option works with the other 315 | \LaTeX-related commands such as biber and makeglossaries. 316 | 317 | A note of warning: sometimes \LaTeX\ needs more than one run to get the 318 | correct position of each element; this is true in particular for the 319 | positioning of floating elements like figures, tables, and margin notes. 320 | Occasionally, \LaTeX\ can need up to four re-runs, so If the alignment 321 | of margin elements looks odd, or if they bleed into the main text, try 322 | running pdflatex one more time. 323 | -------------------------------------------------------------------------------- /examples/documentation/chapters/textnotes.tex: -------------------------------------------------------------------------------- 1 | \setchapterpreamble[u]{\margintoc} 2 | \chapter{Margin Stuff} 3 | 4 | Sidenotes are a distinctive feature of all 1.5-column-layout books. 5 | Indeed, having wide margins means that some material can be displayed 6 | there. We use margins for all kind of stuff: sidenotes, marginnotes, 7 | small tables of contents, citations, and, why not?, special boxes and 8 | environments. 9 | 10 | \section{Sidenotes} 11 | 12 | Sidenotes are like footnotes, except that they go in the margin, where 13 | they are more readable. To insert a sidenote, just use the command 14 | \Command{sidenote\{Text of the note\}}. You can specify a 15 | mark\sidenote[O]{This sidenote has a special mark, a big O!} with \\ 16 | \Command{sidenote[mark]\{Text\}}, but you can also specify an offset, 17 | which moves the sidenote upwards or downwards, so that the full syntax is: 18 | 19 | \begin{lstlisting}[style=kaolstplain] 20 | \sidenote[mark][offset]{Text} 21 | \end{lstlisting} 22 | 23 | If you use an offset, you always have to add the brackets for the mark, 24 | but they can be empty.\sidenote{If you want to know more about the usage 25 | of the \Command{sidenote} command, read the documentation of the 26 | \Package{sidenotes} package.} 27 | 28 | In \Class{kaobook} we copied a feature from the \Package{snotez} 29 | package: the possibility to specify a multiple of \Command{baselineskip} 30 | as an offset. For example, if you want to enter a sidenote with the 31 | normal mark and move it upwards one line, type: 32 | 33 | \begin{lstlisting}[style=kaolstplain] 34 | \sidenote[][*-1]{Text of the sidenote.} 35 | \end{lstlisting} 36 | 37 | As we said, sidenotes are handled through the \Package{sidenotes} 38 | package, which in turn relies on the \Package{marginnote} package. 39 | 40 | \section{Marginnotes} 41 | 42 | This command is very similar to the previous one. You can create a 43 | marginnote with \Command{marginnote[offset]\{Text\}}, where the offset 44 | argument can be left out, or it can be a multiple of 45 | \Command{baselineskip},\marginnote[-1cm]{While the command for margin 46 | notes comes from the \Package{marginnote} package, it has been redefined 47 | in order to change the position of the optional offset argument, which 48 | now precedes the text of the note, whereas in the original version it 49 | was at the end. We have also added the possibility to use a multiple of 50 | \Command{baselineskip} as offset. These things were made only to make 51 | everything more consistent, so that you have to remember less things!} 52 | \eg 53 | 54 | \begin{lstlisting}[style=kaolstplain] 55 | \marginnote[-12pt]{Text} or \marginnote[*-3]{Text} 56 | \end{lstlisting} 57 | 58 | \begin{kaobox}[title=To Do] 59 | A small thing that needs to be done is to renew the \Command{sidenote} 60 | command so that it takes only one optional argument, the offset. The 61 | special mark argument can go somewhere else. In other words, we want the 62 | syntax of \Command{sidenote} to resemble that of \Command{marginnote}. 63 | \end{kaobox} 64 | 65 | We load the packages \Package{marginnote}, \Package{marginfix} and 66 | \Package{placeins}. Since \Package{sidenotes} uses \Package{marginnote}, 67 | what we said for marginnotes is also valid for sidenotes. Side- and 68 | margin- notes are shifted slightly upwards 69 | (\Command{renewcommand\{\textbackslash marginnotevadjust\}\{3pt\}}) in 70 | order to align them to the bottom of the line of text where the note is 71 | issued. Importantly, both sidenotes and marginnotes are defined as 72 | floating if the optional argument (\ie the vertical offset) is left 73 | blank, but if the offset is specified they are not floating. Recall that 74 | floats cannot be nested, so in some rare cases you may encounter errors 75 | about lost floats; in those cases, remember that sidenotes and 76 | marginnotes are floats. To solve the problem, it may be possible to 77 | transform them into non-floating elements by specifying an offset of 78 | 0pt. 79 | 80 | \section{Footnotes} 81 | 82 | Even though they are not displayed in the margin, we will discuss about 83 | footnotes here, since sidenotes are mainly intended to be a replacement 84 | of them. Footnotes force the reader to constantly move from one area of 85 | the page to the other. Arguably, marginnotes solve this issue, so you 86 | should not use footnotes. Nevertheless, for completeness, we have left 87 | the standard command \Command{footnote}, just in case you want to put a 88 | footnote once in a while.\footnote{And this is how they look like. 89 | Notice that in the PDF file there is a back reference to the text; 90 | pretty cool, uh?} 91 | 92 | \section{Margintoc} 93 | 94 | Since we are talking about margins, we introduce here the 95 | \Command{margintoc} command, which allows one to put small table of 96 | contents in the margin. Like other commands we have discussed, 97 | \Command{margintoc} accepts a parameter for the vertical offset, like 98 | so: \Command{margintoc[offset]}. 99 | 100 | The command can be used in any point of the document, but we think it 101 | makes sense to use it just at the beginning of chapters or parts. In 102 | this document I make use of a \KOMAScript\xspace feature and put it in 103 | the chapter preamble, with the following code: 104 | 105 | \marginnote{The font used in the margintoc is the same as the one for 106 | the chapter entries in the main table of contents at the beginning 107 | of the document.} 108 | 109 | \begin{lstlisting}[style=kaolstplain] 110 | \setchapterpreamble[u]{\margintoc} 111 | \chapter{Chapter title} 112 | \end{lstlisting} 113 | 114 | As the space in the margin is a valuable resource, there is the 115 | possibility to print a shorter version of the title in the margin toc. 116 | Thus, there are in total three possible versions for the title of a 117 | section (or subsection): the one for the main text, the one for the main 118 | table of contents, and the one for the margintoc. These versions can be 119 | specified at the same time when the section is created in the source 120 | \TeX file: 121 | \begin{lstlisting}[style=kaolstplain] 122 | \section[alternative-title-for-toc]{title-as-written-in-text}[alternative-title-for-margintoc] 123 | \end{lstlisting} 124 | 125 | By default, the margintoc includes sections and subsections. 126 | If you only want to show sections, add 127 | \begin{lstlisting}[style=kaolstplain] 128 | \setcounter{margintocdepth}{\sectiontocdepth} 129 | \end{lstlisting} 130 | somewhere in your preamble. 131 | 132 | \section{Marginlisting} 133 | 134 | On some occasions it may happen that you have a very short piece of code 135 | that doesn't look good in the body of the text because it breaks the 136 | flow of narration: for that occasions, you can use a 137 | \Environment{marginlisting}. The support for this feature is still 138 | limited, especially for the captions, but you can try the following 139 | code: 140 | 141 | \begin{marginlisting} 142 | \caption{An example of a margin listing.} 143 | \begin{lstlisting}[language=Python,style=kaolstplain] 144 | print("Hello World!") 145 | \end{lstlisting} 146 | \end{marginlisting} 147 | 148 | \begin{verbatim} 149 | \begin{marginlisting} 150 | \caption{My caption} 151 | \begin{lstlisting}[language=Python,style=kaolstplain] 152 | ... code ... 153 | \end{lstlisting} 154 | \end{marginlisting} 155 | \end{verbatim} 156 | 157 | Since we are here, let me spend a few words about listsings. Thanks to contributions from \href{https://github.com/fmarotta/kaobook/pull/225}{Kazuhiko Sakaguchi}, kaobook now supports both \Package{listings} and \Package{minted}. Just pass the option \Option{listing=listings} or \Option{listing=minted} when you load the \Class{kaobook} class, and the appropriate pacakge will be loaded. 158 | 159 | Not only textual stuff can be displayed in the margin, but also figures. 160 | Those will be the focus of the next chapter. 161 | -------------------------------------------------------------------------------- /examples/documentation/glossary.tex: -------------------------------------------------------------------------------- 1 | \newglossaryentry{computer}{ 2 | name=computer, 3 | description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format} 4 | } 5 | 6 | % Glossary entries (used in text with e.g. \acrfull{fpsLabel} or \acrshort{fpsLabel}) 7 | \newacronym[longplural={Frames per Second}]{fpsLabel}{FPS}{Frame per Second} 8 | \newacronym[longplural={Tables of Contents}]{tocLabel}{TOC}{Table of Contents} 9 | 10 | -------------------------------------------------------------------------------- /examples/documentation/images/monalisa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/documentation/images/monalisa.jpg -------------------------------------------------------------------------------- /examples/documentation/images/seaside.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/documentation/images/seaside.jpeg -------------------------------------------------------------------------------- /examples/documentation/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/documentation/main.pdf -------------------------------------------------------------------------------- /examples/documentation/main.tex: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % kaobook 3 | % LaTeX Class 4 | % Version 0.9.8 (2021/08/23) 5 | % 6 | % This template originates from: 7 | % https://www.LaTeXTemplates.com 8 | % 9 | % For the latest template development version and to make contributions: 10 | % https://github.com/fmarotta/kaobook 11 | % 12 | % Authors: 13 | % Federico Marotta (federicomarotta@mail.com) 14 | % Based on the doctoral thesis of Ken Arroyo Ohori (https://3d.bk.tudelft.nl/ken/en) 15 | % and on the Tufte-LaTeX class. 16 | % Modified for LaTeX Templates by Vel (vel@latextemplates.com) 17 | % 18 | % License: 19 | % LPPL (see included MANIFEST.md file) 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | 23 | %---------------------------------------------------------------------------------------- 24 | % EXAMPLE AND DOCUMENTATION OF THE KAOBOOK CLASS 25 | %---------------------------------------------------------------------------------------- 26 | 27 | \documentclass[ 28 | a4paper, % Page size 29 | fontsize=10pt, % Base font size 30 | twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside) 31 | %open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages 32 | %chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents 33 | numbers=noenddot, % Comment to output dots after chapter numbers; the most common values for this option are: enddot, noenddot and auto (see the KOMAScript documentation for an in-depth explanation) 34 | fontmethod=tex, % Can also use "modern" with XeLaTeX or LuaTex; "tex" is the default for PdfLaTex, and "modern" is the default for those two. 35 | ]{kaobook} 36 | 37 | %---------------------------------------------------------------------------------------- 38 | % PACKAGES AND OTHER DOCUMENT CONFIGURATIONS 39 | %---------------------------------------------------------------------------------------- 40 | 41 | % Choose the language 42 | \ifxetexorluatex 43 | \usepackage{polyglossia} 44 | \setmainlanguage{english} 45 | \else 46 | \usepackage[english]{babel} % Load characters and hyphenation 47 | \fi 48 | \usepackage[english=british]{csquotes} % English quotes 49 | 50 | % Load packages for testing 51 | \usepackage{blindtext} % Print text without any meaning for testing purposes 52 | %\usepackage{showframe} % Uncomment to show boxes around the text area, margin, header and footer 53 | %\usepackage{showlabels} % Uncomment to output the content of \label commands to the document where they are used 54 | 55 | % Load the bibliography package 56 | \usepackage{kaobiblio} 57 | \addbibresource{main.bib} % Bibliography file 58 | 59 | % Load mathematical packages for theorems and related environments 60 | \usepackage[framed=true]{kaotheorems} 61 | 62 | % Load the package for hyperreferences 63 | \usepackage{kaorefs} 64 | 65 | \graphicspath{{examples/documentation/images/}{images/}} % Paths in which to look for images 66 | 67 | \makeindex[columns=3, title=Alphabetical Index, intoc] % Make LaTeX produce the files required to compile the index 68 | 69 | \makeglossaries % Make LaTeX produce the files required to compile the glossary 70 | \input{glossary.tex} % Include the glossary definitions 71 | 72 | \makenomenclature % Make LaTeX produce the files required to compile the nomenclature 73 | 74 | % Reset sidenote counter at chapters 75 | %\counterwithin*{sidenote}{chapter} 76 | 77 | %---------------------------------------------------------------------------------------- 78 | 79 | \begin{document} 80 | 81 | %---------------------------------------------------------------------------------------- 82 | % BOOK INFORMATION 83 | %---------------------------------------------------------------------------------------- 84 | 85 | \titlehead{The \texttt{kaobook} class} 86 | \subject{Use this document as a template} 87 | 88 | \title[Example and documentation of the {\normalfont\texttt{kaobook}} class]{Example and documentation \\ of the {\normalfont\texttt{kaobook}} class} 89 | \subtitle{Customise this page according to your needs} 90 | 91 | %\author[Federico Marotta]{Federico Marotta\thanks{A \LaTeX\ lover}} 92 | \author[Federico Marotta]{Federico Marotta\thanks{A LaTeX lover}} 93 | \date{\today} 94 | 95 | \publishers{An Awesome Publisher} 96 | 97 | %---------------------------------------------------------------------------------------- 98 | 99 | \frontmatter % Denotes the start of the pre-document content, uses roman numerals 100 | 101 | %---------------------------------------------------------------------------------------- 102 | % OPENING PAGE 103 | %---------------------------------------------------------------------------------------- 104 | 105 | %\makeatletter 106 | %\extratitle{ 107 | % % In the title page, the title is vspaced by 9.5\baselineskip 108 | % \vspace*{9\baselineskip} 109 | % \vspace*{\parskip} 110 | % \begin{center} 111 | % % In the title page, \huge is set after the komafont for title 112 | % \usekomafont{title}\huge\@title 113 | % \end{center} 114 | %} 115 | %\makeatother 116 | 117 | %---------------------------------------------------------------------------------------- 118 | % COPYRIGHT PAGE 119 | %---------------------------------------------------------------------------------------- 120 | 121 | \makeatletter 122 | \uppertitleback{\@titlehead} % Header 123 | 124 | \lowertitleback{ 125 | \textbf{Disclaimer}\\ 126 | You can edit this page to suit your needs. For instance, here we have a no copyright statement, a colophon and some other information. This page is based on the corresponding page of Ken Arroyo Ohori's thesis, with minimal changes. 127 | 128 | \medskip 129 | 130 | \textbf{No copyright}\\ 131 | \cczero\ 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. 132 | 133 | To view a copy of the CC0 code, visit: \\\url{http://creativecommons.org/publicdomain/zero/1.0/} 134 | 135 | \medskip 136 | 137 | \textbf{Colophon} \\ 138 | This document was typeset with the help of \href{https://sourceforge.net/projects/koma-script/}{\KOMAScript} and \href{https://www.latex-project.org/}{\LaTeX} using the \href{https://github.com/fmarotta/kaobook/}{kaobook} class. 139 | 140 | The source code of this book is available at:\\\url{https://github.com/fmarotta/kaobook} 141 | 142 | (You are welcome to contribute!) 143 | 144 | \medskip 145 | 146 | \textbf{Publisher} \\ 147 | First printed in May 2019 by \@publishers 148 | } 149 | \makeatother 150 | 151 | %---------------------------------------------------------------------------------------- 152 | % DEDICATION 153 | %---------------------------------------------------------------------------------------- 154 | 155 | \dedication{ 156 | 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.\\ 157 | \flushright -- D'Arcy Wentworth Thompson 158 | } 159 | 160 | %---------------------------------------------------------------------------------------- 161 | % OUTPUT TITLE PAGE AND PREVIOUS 162 | %---------------------------------------------------------------------------------------- 163 | 164 | % Note that \maketitle outputs the pages before here 165 | 166 | \maketitle 167 | 168 | %---------------------------------------------------------------------------------------- 169 | % PREFACE 170 | %---------------------------------------------------------------------------------------- 171 | 172 | \input{chapters/preface.tex} 173 | \index{preface} 174 | 175 | %---------------------------------------------------------------------------------------- 176 | % TABLE OF CONTENTS & LIST OF FIGURES/TABLES 177 | %---------------------------------------------------------------------------------------- 178 | 179 | \begingroup % Local scope for the following commands 180 | 181 | % Define the style for the TOC, LOF, and LOT 182 | %\setstretch{1} % Uncomment to modify line spacing in the ToC 183 | %\hypersetup{linkcolor=blue} % Uncomment to set the colour of links in the ToC 184 | \setlength{\textheight}{230\hscale} % Manually adjust the height of the ToC pages 185 | 186 | % Turn on compatibility mode for the etoc package 187 | \etocstandarddisplaystyle % "toc display" as if etoc was not loaded 188 | \etocstandardlines % "toc lines as if etoc was not loaded 189 | 190 | \tableofcontents % Output the table of contents 191 | 192 | \listoffigures % Output the list of figures 193 | 194 | % Comment both of the following lines to have the LOF and the LOT on 195 | % different pages 196 | \let\cleardoublepage\bigskip 197 | \let\clearpage\bigskip 198 | 199 | \listoftables % Output the list of tables 200 | 201 | \listoflstlistings % Output the list of listings 202 | 203 | \endgroup 204 | 205 | %---------------------------------------------------------------------------------------- 206 | % MAIN BODY 207 | %---------------------------------------------------------------------------------------- 208 | 209 | \mainmatter % Denotes the start of the main document content, resets page numbering and uses arabic numbers 210 | \setchapterstyle{kao} % Choose the default chapter heading style 211 | 212 | \input{chapters/introduction.tex} 213 | 214 | \pagelayout{wide} % No margins 215 | \addpart{Class Options, Commands and Environments} 216 | \pagelayout{margin} % Restore margins 217 | 218 | \input{chapters/options.tex} 219 | \input{chapters/textnotes.tex} 220 | \input{chapters/figsntabs.tex} 221 | \input{chapters/references.tex} 222 | 223 | \pagelayout{wide} % No margins 224 | \addpart{Design and Additional Features} 225 | \pagelayout{margin} % Restore margins 226 | 227 | \input{chapters/layout.tex} 228 | \input{chapters/mathematics.tex} 229 | 230 | \appendix % From here onwards, chapters are numbered with letters, as is the appendix convention 231 | 232 | \pagelayout{wide} % No margins 233 | \addpart{Appendix} 234 | \pagelayout{margin} % Restore margins 235 | 236 | \input{chapters/appendix.tex} 237 | 238 | \pagelayout{wide} 239 | \setchapterstyle{kao} 240 | \chapter{Test} 241 | \blindtext 242 | 243 | %---------------------------------------------------------------------------------------- 244 | 245 | \backmatter % Denotes the end of the main document content 246 | \setchapterstyle{plain} % Output plain chapters from this point onwards 247 | 248 | %---------------------------------------------------------------------------------------- 249 | % BIBLIOGRAPHY 250 | %---------------------------------------------------------------------------------------- 251 | 252 | % The bibliography needs to be compiled with biber using your LaTeX editor, or on the command line with 'biber main' from the template directory 253 | 254 | \defbibnote{bibnote}{Here are the references in citation order.\par\bigskip} % Prepend this text to the bibliography 255 | \printbibliography[heading=bibintoc, title=Bibliography, prenote=bibnote] % Add the bibliography heading to the ToC, set the title of the bibliography and output the bibliography note 256 | 257 | %---------------------------------------------------------------------------------------- 258 | % NOMENCLATURE 259 | %---------------------------------------------------------------------------------------- 260 | 261 | % The nomenclature needs to be compiled on the command line with 'makeindex main.nlo -s nomencl.ist -o main.nls' from the template directory 262 | 263 | \nomenclature{$c$}{Speed of light in a vacuum inertial frame} 264 | \nomenclature{$h$}{Planck constant} 265 | 266 | \renewcommand{\nomname}{Notation} % Rename the default 'Nomenclature' 267 | \renewcommand{\nompreamble}{The next list describes several symbols that will be later used within the body of the document.} % Prepend this text to the nomenclature 268 | 269 | \printnomenclature % Output the nomenclature 270 | 271 | %---------------------------------------------------------------------------------------- 272 | % GREEK ALPHABET 273 | % Originally from https://gitlab.com/jim.hefferon/linear-algebra 274 | %---------------------------------------------------------------------------------------- 275 | 276 | \vspace{1cm} 277 | 278 | {\usekomafont{chapter}Greek Letters with Pronunciations} \\[2ex] 279 | \begin{center} 280 | \newcommand{\pronounced}[1]{\hspace*{.2em}\small\textit{#1}} 281 | \begin{tabular}{l l @{\hspace*{3em}} l l} 282 | \toprule 283 | Character & Name & Character & Name \\ 284 | \midrule 285 | $\alpha$ & alpha \pronounced{AL-fuh} & $\nu$ & nu \pronounced{NEW} \\ 286 | $\beta$ & beta \pronounced{BAY-tuh} & $\xi$, $\Xi$ & xi \pronounced{KSIGH} \\ 287 | $\gamma$, $\Gamma$ & gamma \pronounced{GAM-muh} & o & omicron \pronounced{OM-uh-CRON} \\ 288 | $\delta$, $\Delta$ & delta \pronounced{DEL-tuh} & $\pi$, $\Pi$ & pi \pronounced{PIE} \\ 289 | $\epsilon$ & epsilon \pronounced{EP-suh-lon} & $\rho$ & rho \pronounced{ROW} \\ 290 | $\zeta$ & zeta \pronounced{ZAY-tuh} & $\sigma$, $\Sigma$ & sigma \pronounced{SIG-muh} \\ 291 | $\eta$ & eta \pronounced{AY-tuh} & $\tau$ & tau \pronounced{TOW (as in cow)} \\ 292 | $\theta$, $\Theta$ & theta \pronounced{THAY-tuh} & $\upsilon$, $\Upsilon$ & upsilon \pronounced{OOP-suh-LON} \\ 293 | $\iota$ & iota \pronounced{eye-OH-tuh} & $\phi$, $\Phi$ & phi \pronounced{FEE, or FI (as in hi)} \\ 294 | $\kappa$ & kappa \pronounced{KAP-uh} & $\chi$ & chi \pronounced{KI (as in hi)} \\ 295 | $\lambda$, $\Lambda$ & lambda \pronounced{LAM-duh} & $\psi$, $\Psi$ & psi \pronounced{SIGH, or PSIGH} \\ 296 | $\mu$ & mu \pronounced{MEW} & $\omega$, $\Omega$ & omega \pronounced{oh-MAY-guh} \\ 297 | \bottomrule 298 | \end{tabular} \\[1.5ex] 299 | Capitals shown are the ones that differ from Roman capitals. 300 | \end{center} 301 | 302 | %---------------------------------------------------------------------------------------- 303 | % GLOSSARY 304 | %---------------------------------------------------------------------------------------- 305 | 306 | % The glossary needs to be compiled on the command line with 'makeglossaries main' from the template directory 307 | 308 | \setglossarystyle{listgroup} % Set the style of the glossary (see https://en.wikibooks.org/wiki/LaTeX/Glossary for a reference) 309 | \printglossary[title=Special Terms, toctitle=List of Terms] % Output the glossary, 'title' is the chapter heading for the glossary, toctitle is the table of contents heading 310 | 311 | %---------------------------------------------------------------------------------------- 312 | % INDEX 313 | %---------------------------------------------------------------------------------------- 314 | 315 | % The index needs to be compiled on the command line with 'makeindex main' from the template directory 316 | 317 | \printindex % Output the index 318 | 319 | %---------------------------------------------------------------------------------------- 320 | % BACK COVER 321 | %---------------------------------------------------------------------------------------- 322 | 323 | % If you have a PDF/image file that you want to use as a back cover, uncomment the following lines 324 | 325 | %\clearpage 326 | %\thispagestyle{empty} 327 | %\null% 328 | %\clearpage 329 | %\includepdf{cover-back.pdf} 330 | 331 | %---------------------------------------------------------------------------------------- 332 | 333 | \end{document} 334 | -------------------------------------------------------------------------------- /examples/machine_learning_project/img/bid_expr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/bid_expr.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/bid_tba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/bid_tba.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/cv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/cv.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/cv_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/cv_example.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/expr_vs_tba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/expr_vs_tba.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/nested_cv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/nested_cv.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/qq.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/regreg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/regreg.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/response.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/rho2distr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/rho2distr.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/tba_tf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/tba_tf.png -------------------------------------------------------------------------------- /examples/machine_learning_project/img/tigar_article.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/img/tigar_article.png -------------------------------------------------------------------------------- /examples/machine_learning_project/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/machine_learning_project/main.pdf -------------------------------------------------------------------------------- /examples/machine_learning_project/main.tex: -------------------------------------------------------------------------------- 1 | \documentclass[ 2 | fontsize=10pt, % Base font size 3 | twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside) 4 | %open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages 5 | %chapterprefix=true, % Uncomment to use the word "Chapter" before chapter numbers everywhere they appear 6 | %chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents 7 | numbers=noenddot, % Comment to output dots after chapter numbers; the most common values for this option are: enddot, noenddot and auto (see the KOMAScript documentation for an in-depth explanation) 8 | %draft=true, % If uncommented, rulers will be added in the header and footer 9 | %overfullrule=true, % If uncommented, overly long lines will be marked by a black box; useful for correcting spacing problems 10 | ]{kaohandt} 11 | 12 | % Choose the language 13 | \usepackage[english]{babel} % Load characters and hyphenation 14 | \usepackage[english=british]{csquotes} % English quotes 15 | 16 | % Load the bibliography package 17 | \usepackage{kaobiblio} 18 | \addbibresource{main.bib} % Bibliography file 19 | 20 | % Load mathematical packages for theorems and related environments 21 | \usepackage{kaotheorems} 22 | 23 | % Load the package for hyperreferences 24 | \usepackage{kaorefs} 25 | 26 | % Set the paths where to look for images 27 | \usepackage{subcaption} 28 | \graphicspath{{examples/report/img/}{img/}} 29 | 30 | \begin{document} 31 | 32 | \title{Operation T-REx} 33 | \author[FM]{Federico Marotta} 34 | \date{December 2019} 35 | \maketitle 36 | 37 | \input{sections/introduction.tex} 38 | \input{sections/data.tex} 39 | \input{sections/results.tex} 40 | \input{sections/discussion.tex} 41 | 42 | \defbibnote{bibnote}{Here are the references in citation order.\par\bigskip} % Prepend this text to the bibliography 43 | \renewcommand*{\bibfont}{\small} 44 | \printbibliography[title=Bibliography]% , prenote=bibnote] 45 | 46 | \end{document} 47 | -------------------------------------------------------------------------------- /examples/machine_learning_project/sections/data.tex: -------------------------------------------------------------------------------- 1 | \section{Data} 2 | \labsec{data} 3 | 4 | The Genotype-Tissue Expression (GTEx) project \sidecite{Lonsdale2013a} 5 | aims to characterise gene expression and regulation for 54 human healthy 6 | tissues across nearly 1000 people. While the results of the analyses are 7 | open-access, in order to gain access to the raw data about the DNA and 8 | the gene expression of the individuals, it is necessary to go through a 9 | long bureaucratic procedure. 10 | 11 | Another source of data was the Ensembl project (release 75), 12 | \sidecite[-1.55cm]{Zerbino2018} which was used to obtain the coordinates 13 | of the regulatory regions for each gene. Regulatory regions are 14 | particular positions around a gene where transcription factors can bind; 15 | from there, these transcription factors exert a control on gene 16 | expression.\sidenote{In this project, I considered 141 genes of a 17 | particular type of blood cells, for 95 individuals. Each gene is 18 | associated to about 10 regulatory regions on average.} Each 19 | transcription factor recognises a specific sequence of DNA, therefore it 20 | is possible to compute the affinity of a factor for a given region. The 21 | total binding affinity (TBA) \sidecite[-3.85cm]{Molineris2011a} is one 22 | of the possible affinity measures.\sidenote[][]{The TBA is also 23 | related to the name of this project, T-REx: indeed, the goal is to 24 | estimate the TBA-Regulated Expression.} 25 | 26 | Gene expression in GTEx was measured with a technique called 27 | RNA-sequencing, which returns, for each gene and each individual, the 28 | RPKM, \sidecite[-4.6cm]{Mortazavi2008} which is the number of sequencing 29 | reads normalised by the length of the gene and by the total number of 30 | reads. 31 | 32 | %\begin{figure}[H] 33 | \begin{figure}[H] 34 | \begin{subfigure}{\textwidth} 35 | \centering 36 | \caption{} 37 | % \caption{Histogram and normal Q\babelhyphen{nobreak}Q plot of the 38 | %expression of a randomly selected gene called BID. In the histogram, the 39 | %brown dashed line indicates the mean, while the dotted lines indicate 40 | %plus and minus one standard deviation. In the Q\babelhyphen{nobreak}Q 41 | %plot, each point represents an individual.} 42 | \labfig{distrexpr} 43 | \includegraphics[height=4.8cm,width=.8\textwidth,keepaspectratio=false]{bid_expr} 44 | \end{subfigure} 45 | %\end{figure} 46 | 47 | \begin{subfigure}{\textwidth} 48 | %\begin{figure}[t] 49 | \centering 50 | \caption{} 51 | % \caption{Scree plot and biplot of 52 | % the \textasciitilde800 affinities for the gene BID. In the biplot, each 53 | % label corresponds to an individual.} 54 | \labfig{pcatba} 55 | \includegraphics[height=4.8cm,width=.8\textwidth,keepaspectratio=false]{bid_tba} 56 | \end{subfigure} 57 | % \end{figure} 58 | \caption{(a): Histogram and normal Q\babelhyphen{nobreak}Q plot of the 59 | expression of a randomly selected gene called BID. In the histogram, the 60 | brown dashed line indicates the mean, while the dotted lines indicate 61 | plus and minus one standard deviation. In the Q\babelhyphen{nobreak}Q 62 | plot, each point represents an individual. (b): Scree plot and biplot of 63 | the \textasciitilde800 affinities for the gene BID. In the biplot, each 64 | label corresponds to an individual.} 65 | \labfig{expl} 66 | \end{figure} 67 | 68 | The expression was preprocessed as recommended by the Stephen's 69 | Lab.\sidenote[][*7]{\url{http://stephenslab.github.io/gtex-eqtls/analysis/20170515\_RNASeq\_Analysis.html}} 70 | In summary, I applied a quantile normalisation to make sure that the 71 | distribution of our response variable was normal, and then I obtained 72 | the residuals of a linear model 73 | $Y~\sim~SEX+PEER\_FA+POPULATION+PLATFORM$, so as to disregard the 74 | effects of these covariates on the expression. The final result can be 75 | seen in \reffig{distrexpr}. 76 | 77 | The genotypes were also obtained with a sequencing technique and were 78 | provided in VCF format. \sidecite[-3.2cm]{Danecek2011} I 79 | used a software called 80 | \nohyphens{VCF\textunderscore\nobreak\hspace{0pt}rider}\sidenote[][*3]{\url{https://github.com/vodkatad/vcf\_rider}} 81 | to compute the total binding affinity of each transcription factor for 82 | each regulatory region associated to a gene (the total number of 83 | transcription factors is about 800). \reffig{pcatba} reports the PCA of 84 | the TBA for the gene BID. 85 | -------------------------------------------------------------------------------- /examples/machine_learning_project/sections/discussion.tex: -------------------------------------------------------------------------------- 1 | \section{Discussion} 2 | \labsec{discussion} 3 | 4 | Instead of finding a better model, in this project I tried to find 5 | better predictors. Using the affinities instead of the genotypes has 6 | several advantages: 7 | 8 | \begin{itemize} 9 | \item The model is more interpretable; 10 | \item The number of predictors decreases; 11 | \item The predictive power is higher; 12 | \end{itemize} 13 | 14 | Upon doing some biochemical considerations, it is possible to find even 15 | better predictors, although they violate the constraint of using only 16 | the DNA sequence to predict gene expression. 17 | 18 | There are many ways to continue this work. One would be to construct an 19 | ensemble model that chooses, for each gene, the model that achieved the 20 | best prediction on a training set. 21 | 22 | Another possibility is that of exploiting further the interpretability 23 | of this model, and use the trees produced by BART to make inferences 24 | about the regulatory network among genes. 25 | 26 | Finally, one of the biggest limitations of these kind of models is that 27 | they consider each gene as independent of all the others. One possible 28 | way to use the information hidden among other genes is what I call the 29 | \enquote{bagging of the genes,} where the prediction for a new gene is 30 | given by the average of the prediction of a number of other models 31 | trained on different genes. 32 | 33 | If we were able to accurately predict gene expression, the benefit would 34 | be twofold: first, it would be possible to predict which individuals are 35 | at risk of developing a disease, and consequently to prevent it; 36 | secondly, the biological mechanisms through which the illnesses arise 37 | would be elucidated, potentially leading to the discovery of new 38 | therapeutic targets. In conclusion, I hope that this project will give a 39 | contribution, albeit very small, in understanding the relationships 40 | between genome, expression and diseases. 41 | -------------------------------------------------------------------------------- /examples/machine_learning_project/sections/introduction.tex: -------------------------------------------------------------------------------- 1 | \section{Introduction} 2 | \labsec{intro} 3 | 4 | Ever since the sequence of the human genome was made available some 20 5 | years ago, \sidecite[-1\baselineskip]{Lander2001a} one of the most 6 | compelling goals in both science and medicine has been that of finding 7 | the genetic variants associated to diseases. 8 | 9 | % The first attempts relied on statistical association tests, like the 10 | % $\chi^2$ test, to identify the genetic variants that are more likely to 11 | % occur in ill rather than healthy individuals. \sidecite{Visscher2012a} 12 | % Despite its successes, the power of this approach is hampered by the 13 | % fact that there are so many genetic variants (on average, the DNA 14 | % sequences of two non-related people differ of about one letter every one 15 | % thousand \sidecite{Durbin2010}), most of which, the so-called rare 16 | % variants, appear only in a tiny fraction of individuals. 17 | 18 | In 2015 it was proposed a new method, 19 | \sidecite[-1.1cm]{Gamazon2015a} dubbed Transcriptome-Wide 20 | Association Study (TWAS), which consists of using the genetic variants 21 | to predict gene expression, and then finding associations between the 22 | predicted expression and a disease. The first advantage is that it is 23 | possible to avoid a direct measurement of gene expression, which can be 24 | expensive or even impossible for certain tissues. But another, more 25 | subtle advantage is that predicted values are less noisy than the real 26 | ones, because they do not include the environmental component of 27 | expression (\refeq{expr}). In view of this method, predicting gene 28 | expression is a relevant problem. 29 | 30 | A gene is a region of DNA, and its expression can be defined as the 31 | amount of RNA molecules that originate from that region 32 | (\vreffig{response}). This amount is different in different individuals, 33 | and our goal is to predict these differences. 34 | 35 | \begin{marginfigure}[-3.8cm] 36 | \includegraphics{response} 37 | \caption{Each gene is \enquote{transcribed} into many RNA molecules, 38 | which then are \enquote{translated} into proteins.} 39 | \labfig{response} 40 | \end{marginfigure} 41 | 42 | As regards the DNA itself, in this context it can be regarded as a 43 | 3-billion letter long string, different for each individual. Most of the 44 | positions in the sequence are the same, but there are some specific 45 | positions, called polymorphic loci, which harbour different letters in 46 | different people (\reffig{predictorsA}). There are many kinds of 47 | differences, but, as similar works do, 48 | \sidecite[-8.6cm]{Nagpal2019} here we will focus only on 49 | single-letter differences such that in the population only two letters 50 | are present, \ie we will only consider those positions that can be in 51 | two states. 52 | 53 | \begin{marginfigure}[-1.5cm] 54 | \setlength{\tabcolsep}{2pt} 55 | \scalebox{0.7}{% 56 | \begin{subfigure}{\textwidth} 57 | \caption{} 58 | \labfig{predictorsA} 59 | \small 60 | \texttt{% 61 | \begin{tabular}{l c c c c c c c c c c c c c c c c c c} 62 | \textsf{Alice\hspace{.2cm}} & A & T & G & \cellcolor{yellow}G & T & G & \cellcolor{cyan}C & T & G & T & C & T & C & C & T & G & \cellcolor{red}T & C \\ 63 | \textsf{Bob\hspace{.2cm}} & A & T & G & \cellcolor{yellow}G & T & G & \cellcolor{cyan}C & T & G & T & C & T & C & C & T & G & \cellcolor{cyan}C & C \\ 64 | \textsf{Craig\hspace{.2cm}} & A & T & G & \cellcolor{green}A & T & G & \cellcolor{green}A & T & G & T & C & T & C & C & T & G & \cellcolor{cyan}C & C \\ 65 | \textsf{Dave\hspace{.2cm}} & A & T & G & \cellcolor{green}A & T & G & \cellcolor{cyan}C & T & G & T & C & T & C & C & T & G & \cellcolor{cyan}C & C \\ 66 | \textsf{Eve\hspace{.2cm}} & A & T & G & \cellcolor{yellow}G & T & G & \cellcolor{green}A & T & G & T & C & T & C & C & T & G & \cellcolor{red}T & C \\ 67 | \textsf{Frank\hspace{.2cm}} & A & T & G & \cellcolor{yellow}G & T & G & \cellcolor{green}A & T & G & T & C & T & C & C & T & G & \cellcolor{cyan}C & C \\ 68 | \end{tabular}} 69 | \end{subfigure} 70 | } 71 | 72 | \scalebox{0.7}{% 73 | \begin{subfigure}{\textwidth} 74 | \caption{} 75 | \labfig{predictorsB} 76 | \small 77 | \texttt{% 78 | \begin{tabular}{l c c c c c c c c c c c c c c c c c c} 79 | \textsf{Alice\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 1 & \phantom{A} \\ 80 | \textsf{Bob\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} \\ 81 | \textsf{Craig\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 1 & \phantom{A} & \phantom{A} & 1 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} \\ 82 | \textsf{Dave\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 1 & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} \\ 83 | \textsf{Eve\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & 1 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 1 & \phantom{A} \\ 84 | \textsf{Frank\hspace{.2cm}} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} & \phantom{A} & 1 & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & \phantom{A} & 0 & \phantom{A} \\ 85 | \end{tabular}} 86 | \end{subfigure} 87 | } 88 | \caption{(a) Examples of DNA sequences; polymorphic loci are highlighted 89 | with different colours. (b) Predictors matrix built from the sequences 90 | in (a).} 91 | \labfig{predictors} 92 | \end{marginfigure} 93 | 94 | DNA lends itself to a representation where the positions that are the 95 | same in all the individuals are ignored, and the two possible letters of 96 | these polymorphic loci are encoded as zeroes or ones 97 | (\reffig{predictorsB}). Indeed, all the published works on this topic 98 | use a matrix of this kind, constructed on a window of one million 99 | letters around each gene. Moreover, each gene is treated independently 100 | of all the others, and one model is run for each gene. The expression of 101 | gene $A$ in individual $i$ can be modeled as in \vrefeq{expr}, where 102 | $X_{ij}$ is the genotype (0 or 1) of individual $i$ at locus $j$, and 103 | $\beta_j$ is the increase in expression for individuals that have a 1 at 104 | locus $j$ with respect to the other individuals. Importantly, this is an 105 | additive model and no interactions are considered. 106 | 107 | %\marginnote[-1.3cm]{% 108 | \begin{equation} 109 | \labeq{expr} 110 | Y_i^{(A)} = \overbrace{\underbrace{\sum_{j=0}^p \beta_j^{(A)} X_{ij}^{(A)}}_{\text{Genetic effect ($\hat{Y}^{(A)}$)}} + \underbrace{\epsilon_i^{(A)}}_{\text{Environmental effect}}}^{\text{Theoretical real expression}} 111 | \end{equation} 112 | %} 113 | -------------------------------------------------------------------------------- /examples/machine_learning_project/sections/results.tex: -------------------------------------------------------------------------------- 1 | \section{Results} 2 | \labsec{results} 3 | 4 | \subsection{Nested Cross-Validation Package} 5 | 6 | All the similar published works use a 5-fold cross-validation to 7 | evaluate their models. However, since there are also some parameters to 8 | tune, they rely on a (computationally expensive) netsed cross-validation 9 | in order not to overestimate the predictive power. Since I needed to run 10 | several different models for each of the 140 genes, each with its own 11 | parameters, I decided to write an R 12 | package\sidenote[][-2.3cm]{\url{https://github.com/fmarotta/cvtools}} to 13 | perform the nested cross-validation with a heuristic algorithm that does 14 | not try all the possible values for the parameters, but rather, 15 | independently for each parameter, it starts at one value and explores 16 | the adjacent ones; then, it moves in the direction where the error 17 | decreases 18 | (\reffig{cv}). 19 | 20 | \begin{marginfigure}[-3.4cm] 21 | \centering 22 | \includegraphics{cv} 23 | \caption{First, the mtry is tuned while the nodesize is kept fixed; 24 | the algorithm started at the default value of 256, then it moved up in 25 | the range as long as the error decreased, and finally it came back to 26 | explore the values in between. Next, the nodesize was tuned in a similar 27 | fashion.} 28 | \labfig{cv} 29 | \end{marginfigure} 30 | 31 | This package requires the user to write a function which takes 32 | predefined arguments and returns a predefined output, but except for 33 | that, it can be used with any regression model. I evaluated the 34 | performances of ridge, BART, random forest, and PCR. 35 | \sidecite[-12.9cm]{James2013a,Hastie2009} 36 | 37 | \subsection{Model Performance} 38 | 39 | The measure of performance is not the MSE nor the $R^2$, but rather the 40 | square of the correlation between true and predicted expression 41 | ($\rho^2$); indeed, we do not want to penalise errors on single 42 | individuals, but we are interested in the general trend of expression. I 43 | decided to compare my results with those of TIGAR, \cite{Nagpal2019} 44 | which is currently most recent paper on this topic. 45 | 46 | \begin{table}[b] 47 | \caption{Mean $\rho^2$ across 141 genes. The t-test was always 48 | performed with respect to TIGAR.} 49 | \labtab{comp} 50 | \begin{tabular}{lcc} 51 | \textbf{Model} & \textbf{Mean} \boldmath$\rho^2$ & \textbf{t-test pval} \\ 52 | \midrule 53 | TIGAR & 0.067 & NA\\ 54 | Ridge & 0.076 & 0.025\\ 55 | BART & 0.074 & 0.121\\ 56 | Ranger & 0.069 & 0.398\\ 57 | PCR & 0.064 & 0.737\\ 58 | \end{tabular} 59 | \end{table} 60 | 61 | Even if it captures only the linear relationships, ridge gave the best 62 | predictive performance (\reffig{rho2distr}), probably because in this 63 | context where $p >> n$, it is a good compromise between bias, variance 64 | and overfitting. According to a t-test, the $\rho^2$ achieved by ridge 65 | with the TBA values are even higher than those obtained by TIGAR 66 | (\reftab{comp}). 67 | 68 | \begin{marginfigure}[-2cm] 69 | \includegraphics{rho2distr} 70 | \caption{Density plot of the $\rho^2$ achieved by T-REx (Ridge) and 71 | TIGAR. The dotted lines denotes the means of the 72 | distributions.} 73 | \labfig{rho2distr} 74 | \end{marginfigure} 75 | 76 | The performance of BART was not so different, despite the method being 77 | completely different. However, an important advantage of BART with 78 | respect to ridge is its ability to provide importance measures, allowing 79 | us to find which transcription factors are important for each gene. 80 | Additionally, BART captures the interactions between transcription 81 | factors. 82 | 83 | The other methods, random forest and principal component regression, 84 | were much less powerful. 85 | 86 | \subsection{Considering the Expression of the Transcription Factor} 87 | 88 | As high as its affinity for the DNA may be, if the transcription factor 89 | is present only in tiny amounts it will not bind many regulatory 90 | regions. For this reason, we tried to enhance our predictors with 91 | information from the expression of the transcription factors. 92 | 93 | \marginnote{% 94 | The Hill equation models the rate of expression of a gene: 95 | \begin{equation*} 96 | \theta = w \frac{L^n}{K^n + L^n} \approx w \left(\frac{L}{K}\right)^n. 97 | \end{equation*} 98 | Here, $L$ is the amount of transcription factor, $K$ is the dissociation 99 | constant (the inverse of the affinity), and $w$ is a constant. It is 100 | reasonable to suppose that if many transcription factors regulate a 101 | gene, the rate will be given by the following product, where we denoted 102 | $A = 1 / K$: 103 | \begin{equation*} 104 | \theta = w_1 \left( L_1 A_1 \right)^{n_1} \cdots w_p \left( L_p A_p \right)^{n_p}. 105 | \end{equation*} 106 | Now, if we compute the log of the rate, we get a linear combination 107 | which in principle is a deterministic function, but in practice we can 108 | use this linear combination as the right-hand side of a model formula 109 | and let ridge estimate the coefficients: 110 | \begin{align*} 111 | Y \sim \beta_0 &+ \beta_1 \left(\log L_1 + \log A_1\right) \\ 112 | &+ \cdots \\ 113 | &+ \beta_p \left(\log L_p + \log A_p\right). 114 | \end{align*} 115 | } 116 | 117 | In the dataset, we have expression values for some 40.000 genes; of 118 | these, about 800 are transcriptional factors. In practice we removed 119 | those rows from the dataset, and summed the TBA and the expression of 120 | corresponding transcription factors. The new predictors gave a 121 | considerable improvement in the performance, and, perhaps surprisingly, 122 | ridge outclassed BART. In the adjacent margin note I describe the 123 | working hypothesis more in detail. 124 | 125 | \begin{table}[H] 126 | \begin{tabular}{lr} 127 | \textbf{Model} & \textbf{Mean} \boldmath$\rho^2$ \\ 128 | \midrule 129 | Ridge & 0.393\\ 130 | BART & 0.268\\ 131 | \end{tabular} 132 | \end{table} 133 | 134 | -------------------------------------------------------------------------------- /examples/minimal_book/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/minimal_book/main.pdf -------------------------------------------------------------------------------- /examples/minimal_book/main.tex: -------------------------------------------------------------------------------- 1 | % Load the kaobook class 2 | \documentclass[ 3 | fontsize=10pt, % Base font size 4 | twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside) 5 | %open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages 6 | secnumdepth=1, % How deep to number headings. Defaults to 1 (sections) 7 | ]{kaobook} 8 | 9 | % Choose the language 10 | \usepackage[english]{babel} % Load characters and hyphenation 11 | \usepackage[english=british]{csquotes} % English quotes 12 | 13 | % Load packages for testing 14 | \usepackage{blindtext} 15 | %\usepackage{showframe} % Uncomment to show boxes around the text area, margin, header and footer 16 | %\usepackage{showlabels} % Uncomment to output the content of \label commands to the document where they are used 17 | 18 | % Load the bibliography package 19 | \usepackage{kaobiblio} 20 | \addbibresource{minimal.bib} % Bibliography file 21 | 22 | % Load mathematical packages for theorems and related environments 23 | \usepackage{kaotheorems} 24 | 25 | % Load the package for hyperreferences 26 | \usepackage{kaorefs} 27 | 28 | \graphicspath{{images/}{./}} % Paths where images are looked for 29 | 30 | \makeindex[columns=3, title=Alphabetical Index, intoc] % Make LaTeX produce the files required to compile the index 31 | 32 | 33 | \begin{document} 34 | 35 | %---------------------------------------------------------------------------------------- 36 | % BOOK INFORMATION 37 | %---------------------------------------------------------------------------------------- 38 | 39 | \titlehead{Document Template} 40 | \title[Template for the {\normalfont\texttt{kaobook}} Class]{Template for the {\normalfont\texttt{kaobook}} Class} 41 | \author[JBG]{Johnny B. Goode} 42 | \date{\today} 43 | \publishers{An Awesome Publisher} 44 | 45 | %---------------------------------------------------------------------------------------- 46 | 47 | \frontmatter % Denotes the start of the pre-document content, uses roman numerals 48 | 49 | %---------------------------------------------------------------------------------------- 50 | % COPYRIGHT PAGE 51 | %---------------------------------------------------------------------------------------- 52 | 53 | \makeatletter 54 | \uppertitleback{\@titlehead} % Header 55 | 56 | \lowertitleback{ 57 | \textbf{Disclaimer} \\ 58 | You can edit this page to suit your needs. For instance, here we have a no copyright statement, a colophon and some other information. This page is based on the corresponding page of Ken Arroyo Ohori's thesis, with minimal changes. 59 | 60 | \medskip 61 | 62 | \textbf{No copyright} \\ 63 | \cczero\ 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. 64 | 65 | To view a copy of the CC0 code, visit: \\\url{http://creativecommons.org/publicdomain/zero/1.0/} 66 | 67 | \medskip 68 | 69 | \textbf{Colophon} \\ 70 | This document was typeset with the help of \href{https://sourceforge.net/projects/koma-script/}{\KOMAScript} and \href{https://www.latex-project.org/}{\LaTeX} using the \href{https://github.com/fmarotta/kaobook/}{kaobook} class. 71 | 72 | \medskip 73 | 74 | \textbf{Publisher} \\ 75 | First printed in May 2019 by \@publishers 76 | } 77 | \makeatother 78 | 79 | %---------------------------------------------------------------------------------------- 80 | % DEDICATION 81 | %---------------------------------------------------------------------------------------- 82 | 83 | \dedication{ 84 | 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.\\ 85 | \flushright -- D'Arcy Wentworth Thompson 86 | } 87 | 88 | %---------------------------------------------------------------------------------------- 89 | % OUTPUT TITLE PAGE AND PREVIOUS 90 | %---------------------------------------------------------------------------------------- 91 | 92 | % Note that \maketitle outputs the pages before here 93 | \maketitle 94 | 95 | %---------------------------------------------------------------------------------------- 96 | % PREFACE 97 | %---------------------------------------------------------------------------------------- 98 | 99 | \chapter*{Preface} 100 | 101 | \blindtext 102 | 103 | %---------------------------------------------------------------------------------------- 104 | % TABLE OF CONTENTS & LIST OF FIGURES/TABLES 105 | %---------------------------------------------------------------------------------------- 106 | 107 | \begingroup % Local scope for the following commands 108 | 109 | % Define the style for the TOC, LOF, and LOT 110 | %\setstretch{1} % Uncomment to modify line spacing in the ToC 111 | %\hypersetup{linkcolor=blue} % Uncomment to set the colour of links in the ToC 112 | \setlength{\textheight}{230\vscale} % Manually adjust the height of the ToC pages 113 | 114 | % Turn on compatibility mode for the etoc package 115 | \etocstandarddisplaystyle % "toc display" as if etoc was not loaded 116 | \etocstandardlines % "toc lines as if etoc was not loaded 117 | 118 | \tableofcontents % Output the table of contents 119 | 120 | \listoffigures % Output the list of figures 121 | 122 | % Comment both of the following lines to have the LOF and the LOT on different pages 123 | \let\cleardoublepage\bigskip 124 | \let\clearpage\bigskip 125 | 126 | \listoftables % Output the list of tables 127 | 128 | \endgroup 129 | 130 | %---------------------------------------------------------------------------------------- 131 | % MAIN BODY 132 | %---------------------------------------------------------------------------------------- 133 | 134 | \mainmatter % Denotes the start of the main document content, resets page numbering and uses arabic numbers 135 | \setchapterstyle{kao} % Choose the default chapter heading style 136 | 137 | \chapter{First Chapter} 138 | 139 | \blindtext 140 | 141 | \pagelayout{wide} % No margins 142 | \addpart{Title of the Part} 143 | \pagelayout{margin} % Restore margins 144 | 145 | \chapter{Second Chapter} 146 | 147 | \blindtext 148 | 149 | \appendix % From here onwards, chapters are numbered with letters, as is the appendix convention 150 | 151 | \pagelayout{wide} % No margins 152 | \addpart{Appendix} 153 | \pagelayout{margin} % Restore margins 154 | 155 | \chapter{Some more blindtext} 156 | 157 | \blindtext 158 | 159 | %---------------------------------------------------------------------------------------- 160 | 161 | \backmatter % Denotes the end of the main document content 162 | \setchapterstyle{plain} % Output plain chapters from this point onwards 163 | 164 | %---------------------------------------------------------------------------------------- 165 | % BIBLIOGRAPHY 166 | %---------------------------------------------------------------------------------------- 167 | 168 | % The bibliography needs to be compiled with biber using your LaTeX editor, or on the command line with 'biber main' from the template directory 169 | 170 | \defbibnote{bibnote}{Here are the references in citation order.\par\bigskip} % Prepend this text to the bibliography 171 | \printbibliography[heading=bibintoc, title=Bibliography, prenote=bibnote] % Add the bibliography heading to the ToC, set the title of the bibliography and output the bibliography note 172 | 173 | %---------------------------------------------------------------------------------------- 174 | % INDEX 175 | %---------------------------------------------------------------------------------------- 176 | 177 | % The index needs to be compiled on the command line with 'makeindex main' from the template directory 178 | 179 | \printindex % Output the index 180 | 181 | \end{document} 182 | -------------------------------------------------------------------------------- /examples/minimal_report/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/examples/minimal_report/main.pdf -------------------------------------------------------------------------------- /examples/minimal_report/main.tex: -------------------------------------------------------------------------------- 1 | % Load the kaohandt class (with the default options) 2 | \documentclass[ 3 | %fontsize=10pt, % Base font size 4 | %twoside=false, % If true, use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside) 5 | %secnumdepth=2, % How deep to number headings. Defaults to 2 (subsections) 6 | %abstract=true, % Uncomment to print the title of the abstract 7 | ]{kaohandt} 8 | 9 | % Choose the language 10 | \usepackage[english]{babel} % Load characters and hyphenation 11 | \usepackage[english=british]{csquotes} % English quotes 12 | 13 | % Load packages for testing 14 | \usepackage{blindtext} 15 | %\usepackage{showframe} % Uncomment to show boxes around the text area, margin, header and footer 16 | %\usepackage{showlabels} % Uncomment to output the content of \label commands to the document where they are used 17 | 18 | \graphicspath{{images/}{./}} % Paths where images are looked for 19 | 20 | % Load mathematical packages for theorems and related environments. 21 | \usepackage{kaotheorems} 22 | 23 | % Load the bibliography package 24 | \usepackage{kaobiblio} 25 | \addbibresource{report-template.bib} % Bibliography file 26 | 27 | % Load the package for hyperreferences 28 | \usepackage{kaorefs} 29 | 30 | %---------------------------------------------------------------------------------------- 31 | 32 | \begin{document} 33 | 34 | %---------------------------------------------------------------------------------------- 35 | % REPORT INFORMATION 36 | %---------------------------------------------------------------------------------------- 37 | 38 | \title[Template for a Kao Report (or Handout)]{Template for a Kao\\ Report (or Handout)} 39 | 40 | \author[MF, JMC]{Michael Faraday\thanks{Royal Society of London} \and John McClane \thanks{New York City Police Department}} 41 | 42 | \date{\today} 43 | 44 | %---------------------------------------------------------------------------------------- 45 | % TITLE AND ABSTRACT 46 | %---------------------------------------------------------------------------------------- 47 | 48 | \maketitle 49 | 50 | \margintoc 51 | 52 | \begin{abstract} 53 | \noindent 54 | \blindtext 55 | \end{abstract} 56 | 57 | {\noindent\textbf{Keywords:} \LaTeX, Kao, handout, article, report} 58 | 59 | \medskip 60 | 61 | %---------------------------------------------------------------------------------------- 62 | % MAIN BODY 63 | %---------------------------------------------------------------------------------------- 64 | 65 | \section{Introduction} 66 | 67 | Write here your introduction,\sidecite{James2013} and make sure to 68 | reference your sources. 69 | 70 | \blindtext\sidenote[][*-8]{\blindtext} 71 | 72 | \section{Methods} 73 | 74 | \blindtext 75 | 76 | \appendix % From here onwards, chapters are numbered with letters, as is the appendix convention 77 | 78 | \section{Appendix} 79 | 80 | \blindtext 81 | 82 | %---------------------------------------------------------------------------------------- 83 | % BIBLIOGRAPHY 84 | %---------------------------------------------------------------------------------------- 85 | 86 | % The bibliography needs to be compiled with biber using your LaTeX editor, or on the command line with 'biber main' from the template directory 87 | 88 | \printbibliography[title=Bibliography] % Set the title of the bibliography and print the references 89 | 90 | \end{document} 91 | -------------------------------------------------------------------------------- /instructions/README.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Some of the users of the template were so kind as to provide 4 | instructions to recreate a particular set up that they have been using 5 | to compile their books. In particular, Karl-Heinz Becker, author of 6 | "Dynamical Systems and Fractals," among other books and articles, wrote 7 | detailed instructions to configure a private ShareLaTeX server; and 8 | @pwgallagher opened an issue to tell us how to integrate the kaobook 9 | template with one's local TeX installation. There are also instructions 10 | for what I regards as a 'normal' LaTeX workflow, intended for beginners. 11 | Further instructions are welcome by anyone and will be added here. 12 | 13 | ## ShareLaTeX Server 14 | 15 | These instructions are useful if you don't want to use Overleaf, _e.g._ 16 | because of privacy concerns. Setting up your own ShareLaTeX server is a 17 | nice way to use the template from your browser. Moreover, you get 18 | autocompletion of the commands and automatic spell checking. 19 | 20 | **IMPORTANT:** if you use a ShareLaTeX server, your `main.tex` file must 21 | be at the root of the project, otherwise weird things will happen! 22 | 23 | ## Integration with the Local TeX Installation 24 | 25 | If you are used to TeXLive, then these instructions are for you. They 26 | tell you how to make sure that your local LaTeX installation will find 27 | the template's files, so that you do not need to have the `kaobook.cls` 28 | and `styles` files in the directory of your project. 29 | -------------------------------------------------------------------------------- /instructions/latexmk/latexmkrc: -------------------------------------------------------------------------------- 1 | # Output a pdf 2 | $pdf_mode = 1; 3 | $pdflatex = 'pdflatex --shell-escape %O %S'; 4 | 5 | # By default compile only the file called 'main.tex' 6 | @default_files = ('main.tex'); 7 | 8 | # Compile the glossary and acronyms list (package 'glossaries') 9 | add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' ); 10 | add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' ); 11 | $clean_ext .= " acr acn alg glo gls glg"; 12 | sub makeglossaries { 13 | my ($base_name, $path) = fileparse( $_[0] ); 14 | pushd $path; 15 | my $return = system "makeglossaries", $base_name; 16 | popd; 17 | return $return; 18 | } 19 | 20 | # Compile the nomenclature (package 'nomencl') 21 | add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' ); 22 | sub makenlo2nls { 23 | system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" ); 24 | } 25 | -------------------------------------------------------------------------------- /instructions/normal_usage/README.md: -------------------------------------------------------------------------------- 1 | # Normal Usage 2 | 3 | Here are more specific instructions intended for who has never used 4 | LaTeX before. Feel free to e-mail the author of this template to ask for 5 | clarifications. Also check out the instructions on how to set up your 6 | own ShareLaTeX server, if you want. 7 | 8 | ## Usage with Overleaf 9 | 10 | 1. Open the template from http://www.latextemplates.com/template/kaobook 11 | 12 | 1. Start writing your own content. 13 | 14 | 1. Fix the errors as they appear. 15 | 16 | 1. Go on writing and fixing errors until your book is done. 17 | 18 | 1. Uncork Champagne. 19 | 20 | ## Usage on your local machine 21 | 22 | 1. Download a TeX distribution for your computer (linux, windows or 23 | mac); see https://www.latex-project.org/get/. 24 | 25 | 1. Download the kaobook repository from github (or from overleaf). 26 | 27 | 1. Write your own content. You can either modify the existing files from 28 | the `examples` directory or start from scratch. 29 | 30 | 1. From the command line, run "pdflatex main.tex" to compile the pdf. 31 | Otherwise, install a LaTeX editor such as TeXStudio and follow the 32 | specific instructions to compile your document. 33 | 34 | 1. Fix the errors that will inevitably appear; a wise move is to search 35 | google for the error message you obtained. 36 | 37 | 1. Write more content, compile again, and solve the new errors. Do this 38 | until your book is done. 39 | 40 | 1. Uncork Champagne. 41 | -------------------------------------------------------------------------------- /instructions/sharelatex_server/1_DockerShareLatexInstallationSHORT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/instructions/sharelatex_server/1_DockerShareLatexInstallationSHORT.pdf -------------------------------------------------------------------------------- /instructions/sharelatex_server/3_DockerShareLatexInstallation.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fmarotta/kaobook/ebdb7cfe7d78c9d8c9604428216bfd5bbe16c062/instructions/sharelatex_server/3_DockerShareLatexInstallation.docx -------------------------------------------------------------------------------- /instructions/texlive_integration/README.md: -------------------------------------------------------------------------------- 1 | # TeXLive Integration 2 | 3 | Normally, when you write a book with this template, you need that the 4 | `kaobook.cls` and the `styles` directory be in the same directory as the 5 | `main.tex`. After following these instructions, kindly provided by 6 | @pwgallagher, you can start writing your `main.tex` anywhere in your 7 | computer and still be able to use the kaobook class. 8 | 9 | LaTeX looks at certain directories to find all the packages it can use. 10 | Integrating the kaobook with the TeXLive installation amounts to 11 | copying all the `*.cls` and `*.sty` files in one of the places that are 12 | searched by LaTeX. 13 | 14 | 1. Find the appropriate directory by running `kpsewhich 15 | -var-value=TEXMFHOME`. For instance, suppose it is 16 | `/home/john/texmf/`. 17 | 18 | 1. Create the following hierarchy of directories under the texmf home: 19 | `tex/latex/kaobook/`. 20 | 21 | 1. Copy all the `\*.cls` files and the `styles` directory from the 22 | repository into the directory you just created. If you are in a 23 | hurry, you can copy the whole repository into that directory. 24 | Alternatively, you can `git clone` the `kaobook` repository into that folder 25 | and periodically `git pull` to update your `kaobook` installation. 26 | In the end, the folder `/home/john/texmf/tex/latex/kaobook` should contain the 27 | following files 28 | ``` 29 | kao.sty 30 | kaobiblio.sty 31 | kaobook.cls 32 | kaohandt.cls 33 | kaorefs.sty 34 | kaotheorems.sty 35 | ``` 36 | 37 | 1. Run `kpsewhich kaobook.cls` to make sure that LaTeX can find the 38 | template. 39 | -------------------------------------------------------------------------------- /kaobiblio.sty: -------------------------------------------------------------------------------- 1 | \ProvidesPackage{kaobiblio} 2 | 3 | %---------------------------------------------------------------------------------------- 4 | % PACKAGE OPTIONS AND DEPENDENCIES 5 | %---------------------------------------------------------------------------------------- 6 | 7 | \RequirePackage{etoolbox} % Easy programming to modify TeX stuff 8 | \RequirePackage{perpage} % Reset counters 9 | \RequirePackage{iflang} % Check the document language 10 | \RequirePackage{xparse} % Parse arguments for macros 11 | \RequirePackage{xstring} % Parse strings 12 | \RequirePackage{hyperref} % Required for hyperlinks 13 | \RequirePackage{kvoptions} % Handle package options 14 | 15 | % Set up the package options 16 | \SetupKeyvalOptions{ 17 | family = kaobiblio, 18 | prefix = kaobiblio@ 19 | } 20 | 21 | \DeclareBoolOption{addspace}% If true, automatically add a space before printing the citation marker 22 | \DeclareBoolOption{linkeverything}% If true, the author name is a hyperlink in citation styles that support it 23 | 24 | % Choose the default options, which will be overwritten by the options 25 | % passed to this package. 26 | \PassOptionsToPackage{ 27 | %style=numeric-comp, 28 | %citestyle=authortitle-icomp, 29 | citestyle=numeric-comp, 30 | %bibstyle=authoryear, 31 | bibstyle=numeric, 32 | sorting=none, 33 | %sorting=nyt, 34 | %sortcites=true, 35 | %autocite=footnote, 36 | backend=biber, % Compile the bibliography with biber 37 | hyperref=true, 38 | backref=true, 39 | citecounter=true, 40 | pagetracker=true, 41 | citetracker=true, 42 | ibidtracker=context, 43 | autopunct=true, 44 | autocite=plain, 45 | }{biblatex} 46 | 47 | % Pass the unknown options to biblatex, overwriting the previous settings. Avoid passing the kao-specific options. 48 | \DeclareDefaultOption{% 49 | \IfBeginWith{\CurrentOption}{addspace}{}{% 50 | \IfBeginWith{\CurrentOption}{linkeverything}{}{% 51 | \PassOptionsToPackage{\CurrentOption}{biblatex}% 52 | }}% 53 | } 54 | 55 | % Process the options 56 | \ProcessKeyvalOptions{kaobiblio} 57 | 58 | % Load biblatex 59 | \RequirePackage{biblatex} 60 | 61 | % Remove some unwanted entries from the bibliography 62 | \AtEveryBibitem{ 63 | \clearfield{issn} 64 | \clearfield{isbn} 65 | \clearfield{archivePrefix} 66 | \clearfield{arxivId} 67 | \clearfield{pmid} 68 | \clearfield{eprint} 69 | \ifentrytype{online}{}{\ifentrytype{misc}{}{\clearfield{url}}} 70 | \ifentrytype{book}{\clearfield{doi}}{} 71 | } 72 | 73 | % Convert months to integers 74 | \DeclareSourcemap{ 75 | \maps[datatype=bibtex]{ 76 | \map[overwrite]{ 77 | \step[fieldsource=month, match={jan}, replace=${1}] 78 | \step[fieldsource=month, match={feb}, replace=${2}] 79 | \step[fieldsource=month, match={mar}, replace=${3}] 80 | \step[fieldsource=month, match={apr}, replace=${4}] 81 | \step[fieldsource=month, match={may}, replace=${5}] 82 | \step[fieldsource=month, match={jun}, replace=${6}] 83 | \step[fieldsource=month, match={jul}, replace=${7}] 84 | \step[fieldsource=month, match={aug}, replace=${8}] 85 | \step[fieldsource=month, match={sep}, replace=${9}] 86 | \step[fieldsource=month, match={oct}, replace=${10}] 87 | \step[fieldsource=month, match={nov}, replace=${11}] 88 | \step[fieldsource=month, match={dec}, replace=${12}] 89 | } 90 | } 91 | } 92 | 93 | %---------------------------------------------------------------------------------------- 94 | % BACK REFERENCES 95 | %---------------------------------------------------------------------------------------- 96 | 97 | % Check if a string is in a comma-separated list 98 | \newcommand\IfStringInList[2]{\IfSubStr{,#2,}{,#1,}} 99 | 100 | % Set the language-specific back reference strings 101 | % #LANGUAGE 102 | \@ifpackageloaded{polyglossia}{% 103 | \IfLanguageName{danish}{% 104 | \DefineBibliographyStrings{danish}{% 105 | backrefpage = {citeret på side}, 106 | backrefpages = {citeret på sider}, 107 | } 108 | }{} 109 | \IfLanguageName{english}{% 110 | \DefineBibliographyStrings{english}{% 111 | backrefpage = {cited on page}, 112 | backrefpages = {cited on pages}, 113 | } 114 | }{} 115 | \IfLanguageName{italian}{% 116 | \DefineBibliographyStrings{italian}{% 117 | backrefpage = {citato a pag.}, 118 | backrefpages = {citato a pagg.}, 119 | } 120 | }{} 121 | }{ 122 | \@ifpackageloaded{babel}{% 123 | \IfStringInList{danish}{\bbl@loaded}{% 124 | \DefineBibliographyStrings{danish}{% 125 | backrefpage = {citeret på side}, 126 | backrefpages = {citeret på sider}, 127 | } 128 | }{} 129 | \IfStringInList{english}{\bbl@loaded}{% 130 | \DefineBibliographyStrings{english}{% 131 | backrefpage = {cited on page}, 132 | backrefpages = {cited on pages}, 133 | } 134 | }{} 135 | \IfStringInList{italian}{\bbl@loaded}{% 136 | \DefineBibliographyStrings{italian}{% 137 | backrefpage = {citato a pag.}, 138 | backrefpages = {citato a pagg.}, 139 | } 140 | }{} 141 | }{} 142 | } 143 | 144 | %---------------------------------------------------------------------------------------- 145 | % CITATION COMMANDS 146 | %---------------------------------------------------------------------------------------- 147 | 148 | % Command to format the marginnote created for cited items 149 | \NewDocumentCommand{\formatmargincitation}{m}{% The parameter is a single citation key 150 | \parencite{#1}: \citeauthor*{#1} (\iffieldundef{year}{\bibsstring{nodate}}{\printfield{year}}), \citefield{#1}[emph]{title}% 151 | } 152 | 153 | % Command to format the marginnote created for supercited items 154 | \NewDocumentCommand{\formatmarginsupercitation}{m}{% The parameter is a single citation key 155 | \supercite{#1} \citeauthor*{#1} (\iffieldundef{year}{\bibsstring{nodate}}{\printfield{year}})% 156 | } 157 | 158 | % The following command needs to be redefined every time \sidecite is called in order for \DeclareCiteCommand's wrapper to work correctly 159 | \NewDocumentCommand{\kaobiblio@marginnote}{m}{% 160 | \marginnote{#1}% 161 | } 162 | 163 | % biblatex-like commands that also print a citation in the margin 164 | % Usage: 165 | % First optional argument is always vertical shift and must be given as an (empty) argument when using following a postnote and/or prenote 166 | % 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) 167 | % Third optional argument is always the postnote 168 | % Mandatory argument is always the citation key(s) 169 | 170 | % Command to \cite and print a citation in the margin 171 | % First optional argument: vertical shift 172 | % Second optional argument: postnote if the third argument isn't specified; prenote if the third argument is specified (same pattern as the \textcite command) 173 | % Third optional argument: postnote 174 | % Mandatory argument: citation key 175 | \NewDocumentCommand{\sidecite}{o o o m}{% 176 | \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% 177 | \marginnote[#1]{##1}% 178 | }% 179 | \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% 180 | }{% 181 | \formatmargincitation{\thefield{entrykey}}% 182 | }{% 183 | \\% separator between multiple citations 184 | }{% 185 | }% 186 | % With this we print the marker in the text and add the item to the bibliography at the end 187 | \IfNoValueOrEmptyTF{#2}% 188 | {\def\@tempa{\cite{#4}\kaobiblio@sidecite{#4}}}% 189 | {\IfNoValueOrEmptyTF{#3}% 190 | {\IfNoValueTF{#3}% 191 | {\def\@tempa{\cite[#2]{#4}\kaobiblio@sidecite{#4}}}% 192 | {\def\@tempa{\cite[#2][]{#4}\kaobiblio@sidecite{#4}}}% postnote is empty, so pass empty postnote 193 | }% 194 | {\def\@tempa{\cite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}% 195 | }% 196 | \ifkaobiblio@addspace% 197 | \unskip~\@tempa% 198 | \else% 199 | \@tempa% 200 | \fi% 201 | } 202 | 203 | % Command to \supercite and print a citation in the margin 204 | % First optional argument: vertical shift 205 | % Second optional argument: postnote if the third argument isn't specified; prenote if the third argument is specified (same pattern as the \textcite command) 206 | % Third optional argument: postnote 207 | % Mandatory argument: citation key 208 | \NewDocumentCommand{\sidesupercite}{o o o m}{% 209 | \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% 210 | \marginnote[#1]{##1}% 211 | }% 212 | \DeclareCiteCommand{\kaobiblio@sidesupercite}[\kaobiblio@marginnote]{% 213 | }{% 214 | \formatmarginsupercitation{\thefield{entrykey}}% 215 | }{% 216 | \\% separator between multiple citations 217 | }{% 218 | }% 219 | % With this we print the marker in the text and add the item to the bibliography at the end 220 | \IfNoValueOrEmptyTF{#2}% 221 | {\def\@tempa{\supercite{#4}\kaobiblio@sidesupercite{#4}}}% 222 | {\IfNoValueOrEmptyTF{#3}% 223 | {\IfNoValueTF{#3}% 224 | {\def\@tempa{\supercite[#2]{#4}\kaobiblio@sidesupercite{#4}}}% 225 | {\def\@tempa{\supercite[#2][]{#4}\kaobook@sidesupercite{#4}}}% postnote is empty, so pass empty postnote 226 | }% 227 | {\def\@tempa{\supercite[#2][#3]{#4}\kaobiblio@sidesupercite{#4}}}% 228 | }% 229 | \@tempa% 230 | } 231 | 232 | % Command to \textcite and print a citation in the margin 233 | % First optional argument: vertical shift 234 | % Second optional argument: postnote if the third argument isn't specified; prenote if the third argument is specified (same pattern as the \textcite command) 235 | % Third optional argument: postnote 236 | % Mandatory argument: citation key 237 | \NewDocumentCommand{\sidetextcite}{o o o m}{% 238 | \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% 239 | \marginnote[#1]{##1}% 240 | }% 241 | \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% 242 | }{% 243 | \formatmargincitation{\thefield{entrykey}}% 244 | }{% 245 | \\% separator between multiple citations 246 | }{% 247 | }% 248 | % With this we print the marker in the text and add the item to the bibliography at the end 249 | \IfNoValueOrEmptyTF{#2}% 250 | {\def\@tempa{\textcite{#4}\kaobiblio@sidecite{#4}}}% 251 | {\IfNoValueOrEmptyTF{#3}% 252 | {\IfNoValueTF{#3}% 253 | {\def\@tempa{\textcite[#2]{#4}\kaobiblio@sidecite{#4}}}% 254 | {\def\@tempa{\textcite[#2][]{#4}\kaobook@sidecite{#4}}}% postnote is empty, so pass empty postnote 255 | }% 256 | {\def\@tempa{\textcite[#2][#3]{#4}\kaobiblio@sidecite{#4}}}% 257 | }% 258 | \ifkaobiblio@addspace% 259 | \unskip~\@tempa% 260 | \else% 261 | \@tempa% 262 | \fi% 263 | } 264 | 265 | % Command to \parencite or \parencite* and print a citation in the margin 266 | % First optional (star) argument: use \parencite* if included; otherwise use \parencite 267 | % Second optional argument: vertical shift 268 | % Third optional argument: postnote if the fourth argument isn't specified; prenote if the fourth argument is specified (same pattern as the \parencite command) 269 | % Fourth optional argument: postnote 270 | % Mandatory argument: citation key 271 | \NewDocumentCommand{\sideparencite}{s o o o m}{% 272 | \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% 273 | \marginnote[#2]{##1}% 274 | }% 275 | \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% 276 | }{% 277 | \formatmargincitation{\thefield{entrykey}}% 278 | }{% 279 | \\% separator between multiple citations 280 | }{% 281 | }% 282 | % With this we print the marker in the text and add the item to the bibliography at the end 283 | \IfBooleanTF#1% 284 | {\IfNoValueOrEmptyTF{#3}% 285 | {\parencite*{#5}\kaobiblio@sidecite{#5}}% 286 | {\IfNoValueOrEmptyTF{#4}% 287 | {\IfNoValueTF{#4}% 288 | {\def\@tempa{\parencite*[#3]{#5}\kaobiblio@sidecite{#5}}}% 289 | {\def\@tempa{\parencite*[#3][]{#5}\kaobiblio@sidecite{#5}}}% postnote is empty, so pass empty postnote 290 | }% 291 | {\def\@tempa{\parencite*[#3][#4]{#5}\kaobiblio@sidecite{#5}}}% 292 | }% 293 | }% 294 | {\IfNoValueOrEmptyTF{#3}% 295 | {\def\@tempa{\parencite{#5}\kaobiblio@sidecite{#5}}}% 296 | {\IfNoValueOrEmptyTF{#4}% 297 | {\IfNoValueTF{#4}% 298 | {\def\@tempa{\parencite[#3]{#5}\kaobiblio@sidecite{#5}}}% 299 | {\def\@tempa{\parencite[#3][]{#5}\kaobiblio@sidecite{#5}}}% postnote is empty, so pass empty postnote 300 | }% 301 | {\def\@tempa{\parencite[#3][#4]{#5}\kaobiblio@sidecite{#5}}}% 302 | }% 303 | }% 304 | \ifkaobiblio@addspace% 305 | \unskip~\@tempa% 306 | \else% 307 | \@tempa% 308 | \fi% 309 | } 310 | 311 | 312 | %---------------------------------------------------------------------------------------- 313 | % LINKING THE AUTHOR'S NAME 314 | %---------------------------------------------------------------------------------------- 315 | 316 | % 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. 317 | 318 | \ifkaobiblio@linkeverything 319 | \xpatchbibmacro{cite} 320 | {\usebibmacro{cite:label}% 321 | \setunit{\printdelim{nonameyeardelim}}% 322 | \usebibmacro{cite:labeldate+extradate}} 323 | {\printtext[bibhyperref]{% 324 | \DeclareFieldAlias{bibhyperref}{default}% 325 | \usebibmacro{cite:label}% 326 | \setunit{\printdelim{nonameyeardelim}}% 327 | \usebibmacro{cite:labeldate+extradate}}} 328 | {} 329 | {\PackageWarning{biblatex-patch} 330 | {Failed to patch cite bibmacro}} 331 | 332 | % Include labelname in labelyear link 333 | \xpatchbibmacro{cite} 334 | {\printnames{labelname}% 335 | \setunit{\printdelim{nameyeardelim}}% 336 | \usebibmacro{cite:labeldate+extradate}} 337 | {\printtext[bibhyperref]{% 338 | \DeclareFieldAlias{bibhyperref}{default}% 339 | \printnames{labelname}% 340 | \setunit{\printdelim{nameyeardelim}}% 341 | \usebibmacro{cite:labeldate+extradate}}} 342 | {} 343 | {\PackageWarning{biblatex-patch} 344 | {Failed to patch cite bibmacro}} 345 | 346 | % Access hyperref's citation link start/end commands 347 | \makeatletter 348 | \protected\def\blx@imc@biblinkstart{% 349 | \@ifnextchar[%] 350 | {\blx@biblinkstart} 351 | {\blx@biblinkstart[\abx@field@entrykey]}} 352 | \def\blx@biblinkstart[#1]{% 353 | \blx@sfsave\hyper@natlinkstart{\the\c@refsection @#1}\blx@sfrest} 354 | \protected\def\blx@imc@biblinkend{% 355 | \blx@sfsave\hyper@natlinkend\blx@sfrest} 356 | \blx@regimcs{\biblinkstart \biblinkend} 357 | \makeatother 358 | 359 | \newbool{cbx:link} 360 | 361 | % Include parentheses around labelyear in \textcite only in 362 | % single citations without pre- and postnotes 363 | \def\iflinkparens{% 364 | \ifboolexpr{ test {\ifnumequal{\value{multicitetotal}}{0}} and 365 | test {\ifnumequal{\value{citetotal}}{1}} and 366 | test {\iffieldundef{prenote}} and 367 | test {\iffieldundef{postnote}} }} 368 | 369 | \xpatchbibmacro{textcite} 370 | {\printnames{labelname}} 371 | {\iflinkparens 372 | {\DeclareFieldAlias{bibhyperref}{default}% 373 | \global\booltrue{cbx:link}\biblinkstart% 374 | \printnames{labelname}} 375 | {\printtext[bibhyperref]{\printnames{labelname}}}} 376 | {} 377 | {\PackageWarning{biblatex-patch} 378 | {Failed to patch textcite bibmacro}} 379 | 380 | \xpatchbibmacro{textcite} 381 | {\usebibmacro{cite:label}} 382 | {\iflinkparens 383 | {\DeclareFieldAlias{bibhyperref}{default}% 384 | \global\booltrue{cbx:link}\biblinkstart% 385 | \usebibmacro{cite:label}} 386 | {\usebibmacro{cite:label}}} 387 | {} 388 | {\PackageWarning{biblatex-patch} 389 | {Failed to patch textcite bibmacro}} 390 | 391 | \xpretobibmacro{textcite:postnote} 392 | {\ifbool{cbx:link} 393 | {\ifbool{cbx:parens} 394 | {\bibcloseparen\global\boolfalse{cbx:parens}} 395 | {}% 396 | \biblinkend\global\boolfalse{cbx:link}} 397 | {}} 398 | {} 399 | {\PackageWarning{biblatex-patch} 400 | {Failed to patch textcite:postnote bibmacro}} 401 | \else 402 | \fi 403 | 404 | %---------------------------------------------------------------------------------------- 405 | % CITATION ENVIRONMENTS 406 | %---------------------------------------------------------------------------------------- 407 | 408 | % TODO: create a fancy environment for this. Perhaps printing also the 409 | % abstract. 410 | 411 | % Cite commands (assuming biblatex is loaded) 412 | \DeclareCiteCommand{\fullcite}{% 413 | \defcounter{maxnames}{99}% 414 | \usebibmacro{prenote}} 415 | {\clearfield{url}% 416 | \clearfield{pages}% 417 | \clearfield{pagetotal}% 418 | \clearfield{edition}% 419 | \clearfield{issn}% 420 | \clearfield{doi}% 421 | \usedriver 422 | {\DeclareNameAlias{sortname}{default}} 423 | {\thefield{entrytype}} 424 | } 425 | {\multicitedelim} 426 | {\usebibmacro{postnote}} 427 | -------------------------------------------------------------------------------- /kaobook.cls: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % kaobook 3 | % LaTeX Class 4 | % Version 0.9.8 (2021/08/23) 5 | % 6 | % This template originates from: 7 | % https://www.LaTeXTemplates.com 8 | % 9 | % For the latest template development version and to make contributions: 10 | % https://github.com/fmarotta/kaobook 11 | % 12 | % Authors: 13 | % Federico Marotta (federicomarotta@mail.com) 14 | % Based on the doctoral thesis of Ken Arroyo Ohori (https://3d.bk.tudelft.nl/ken/en) 15 | % and on the Tufte-LaTeX class. 16 | % Modified for LaTeX Templates by Vel (vel@latextemplates.com) 17 | % 18 | % License: 19 | % LPPL (see included MANIFEST.md file) 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | 23 | %---------------------------------------------------------------------------------------- 24 | % CLASS CONFIGURATION 25 | %---------------------------------------------------------------------------------------- 26 | 27 | \NeedsTeXFormat{LaTeX2e} 28 | \ProvidesClass{kaobook}[2021/08/23 v0.9.8 kaobook] 29 | \newcommand{\@baseclass}{scrbook} % Base class name 30 | 31 | % Set the default options 32 | \PassOptionsToClass{a4paper}{\@baseclass} 33 | \PassOptionsToClass{fontsize=10pt}{\@baseclass} 34 | \PassOptionsToClass{parskip=half}{\@baseclass} 35 | \PassOptionsToClass{headings=optiontoheadandtoc}{\@baseclass} 36 | 37 | % Pass through any other options to the base class 38 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@baseclass}} 39 | 40 | \ProcessOptions\relax % Process the options 41 | 42 | \LoadClass{\@baseclass} % Load the base class 43 | 44 | \RequirePackage{kao} % Load the code common to all classes 45 | 46 | %---------------------------------------------------------------------------------------- 47 | % FRONT-, MAIN-, BACK- MATTERS BEHAVIOUR 48 | %---------------------------------------------------------------------------------------- 49 | 50 | % Front matter 51 | \let\oldfrontmatter\frontmatter % Store the old command 52 | \renewcommand{\frontmatter}{% 53 | \oldfrontmatter% First of all, call the old command 54 | \pagestyle{plain.scrheadings}% Use a plain style for the header and the footer 55 | \pagelayout{wide}% Use a wide page layout 56 | \setchapterstyle{plain} % Choose the default chapter heading style 57 | % \sloppy % Required to better break long lines 58 | } 59 | 60 | %------------------------------------------------ 61 | 62 | % Main matter 63 | \let\oldmainmatter\mainmatter % Store the old command 64 | \renewcommand{\mainmatter}{% 65 | \oldmainmatter% Call the old command 66 | \pagestyle{scrheadings}% Use a fancy style for the header and the footer 67 | \pagelayout{margin}% Use a 1.5 column layout 68 | \setchapterstyle{kao} % Choose the default chapter heading style 69 | } 70 | 71 | %------------------------------------------------ 72 | 73 | % Appendix 74 | \let\oldappendix\appendix% Store the old command 75 | \renewcommand{\appendix}{% 76 | \oldappendix% Call the old command 77 | \bookmarksetup{startatroot}% Reset the bookmark depth 78 | } 79 | 80 | %------------------------------------------------ 81 | 82 | % Back matter 83 | \let\oldbackmatter\backmatter% Store the old command 84 | \renewcommand{\backmatter}{% 85 | \oldbackmatter% Call the old command 86 | \bookmarksetup{startatroot}% Reset the bookmark depth 87 | \pagestyle{plain.scrheadings}% Use a plain style for the header and the footer 88 | \pagelayout{wide}% Use a wide page layout 89 | \setchapterstyle{plain} % Choose the default chapter heading style 90 | } 91 | 92 | %---------------------------------------------------------------------------------------- 93 | % CHAPTER HEADING STYLES 94 | %---------------------------------------------------------------------------------------- 95 | 96 | % Command to easily switch between chapter styles 97 | \DeclareDocumentCommand{\setchapterstyle}{m}{% 98 | \ifthenelse{\equal{plain}{#1}}{\chapterstyleplain}{} 99 | \ifthenelse{\equal{bar}{#1}}{\chapterstylebar}{} 100 | \ifthenelse{\equal{lines}{#1}}{\chapterstylelines}{} 101 | \ifthenelse{\equal{kao}{#1}}{\chapterstylekao}{} 102 | } 103 | 104 | % The default definition in KOMA script 105 | \DeclareDocumentCommand{\chapterstyleplain}{}{% 106 | \renewcommand{\chapterlinesformat}[3]{% 107 | \@hangfrom{##2}{##3}} 108 | \renewcommand*{\chapterformat}{% 109 | \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter% 110 | \autodot\IfUsePrefixLine{}{\enskip}}} 111 | \RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter} 112 | \setlength{\mtocshift}{-1\vscale} 113 | } 114 | 115 | % Gray bar 116 | \DeclareDocumentCommand{\chapterstylebar}{}{% 117 | \renewcommand*{\chapterformat}{% 118 | \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter% 119 | \autodot\IfUsePrefixLine{}{\enskip}}% 120 | } 121 | \renewcommand{\chapterlinesformat}[3]{% 122 | \begin{tikzpicture}[remember picture, overlay] 123 | \node[ 124 | anchor=south west, 125 | xshift=\dimexpr - \hoffset - \oddsidemargin - 1in -1mm,%-30\hscale, 126 | yshift=4.3mm, 127 | rectangle, 128 | fill=gray!20!white, 129 | fill opacity=0.8, 130 | inner ysep=5\vscale, 131 | inner xsep=\dimexpr \hoffset + \oddsidemargin + 1in,%30\hscale, 132 | text opacity=1, 133 | text width=\paperwidth-40\hscale, 134 | ]{\@hangfrom{##2}{##3}}; 135 | \end{tikzpicture} 136 | } 137 | \RedeclareSectionCommand[beforeskip=-55\vscale,afterskip=6\vscale]{chapter} 138 | \setlength{\mtocshift}{-1\vscale} 139 | } 140 | 141 | % Lines 142 | \renewcommand{\hrulefill}[1][0.4pt]{% 143 | \leavevmode\leaders\hrule height #1\hfill\kern\z@% 144 | } 145 | \DeclareDocumentCommand{\chapterstylelines}{}{% 146 | \renewcommand*{\chapterformat}{% 147 | \chapappifchapterprefix{\nobreakspace}\scalebox{3.5}{\thechapter\autodot}% 148 | }% 149 | \renewcommand\chapterlinesformat[3]{% 150 | %\vspace*{-1cm}% 151 | \leavevmode% 152 | \makebox[0pt][l]{% 153 | \makebox[\textwidth][l]{\hrulefill[1pt]##2}%\hfill%\par%\bigskip 154 | \makebox[\marginparsep][l]{}% 155 | \makebox[\marginparwidth][l]{}% 156 | }\\ 157 | %\vspace{.5cm} 158 | \makebox[0pt][l]{% 159 | \makebox[\textwidth][l]{##3}% 160 | \makebox[\marginparsep][l]{}% 161 | \makebox[\marginparwidth][l]{}% 162 | }\\ 163 | \makebox[0pt][l]{% 164 | \makebox[\textwidth+\marginparsep+\marginparwidth][l]{\hrulefill[1.1pt]}% 165 | }% 166 | }% 167 | \RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter} 168 | \setlength{\mtocshift}{-1\vscale}% 169 | } 170 | 171 | % The Kao style 172 | \DeclareDocumentCommand{\chapterstylekao}{}{% 173 | \IfWideLayout{% 174 | \renewcommand*{\chapterformat}{% 175 | \mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}% 176 | }% 177 | \renewcommand\chapterlinesformat[3]{% 178 | \vspace{3.5\vscale}% 179 | \if@twoside% 180 | \Ifthispageodd{% 181 | \smash{\makebox[0pt][l]{% 182 | \parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}% 183 | \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 184 | \parbox[b]{\marginparwidth}{##2}% 185 | }}% 186 | }{ 187 | \smash{\makebox[\textwidth + 6.2\hscale][r]{% 188 | \parbox[b]{47.7\hscale + 6.2\hscale}{\flushright{##2}}% 189 | \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 190 | \parbox[b]{\textwidth}{\flushleft{##3}}% 191 | }}% 192 | } 193 | \else% 194 | \smash{\makebox[0pt][l]{% 195 | \parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}% 196 | \makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 197 | \parbox[b]{\marginparwidth}{##2}% 198 | }}% 199 | \fi% 200 | }% 201 | }{% 202 | \renewcommand*{\chapterformat}{% 203 | \mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}% 204 | }% 205 | \renewcommand\chapterlinesformat[3]{% 206 | \vspace{3.5\vscale}% 207 | \if@twoside% 208 | \Ifthispageodd{% 209 | \smash{\makebox[0pt][l]{% 210 | \parbox[b]{\textwidth}{\flushright{##3}}% 211 | \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 212 | \parbox[b]{\marginparwidth}{##2}% 213 | }}% 214 | }{ 215 | \smash{\makebox[\textwidth][r]{% 216 | \parbox[b]{\marginparwidth}{\flushright{##2}}% 217 | \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 218 | \parbox[b]{\textwidth}{\flushleft{##3}}% 219 | }}% 220 | } 221 | \else% 222 | \smash{\makebox[0pt][l]{% 223 | \parbox[b]{\textwidth}{\flushright{##3}}% 224 | \makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}% 225 | \parbox[b]{\marginparwidth}{##2}% 226 | }}% 227 | \fi% 228 | }% 229 | }% 230 | \RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}% 231 | \setlength{\mtocshift}{-3.5\vscale}% 232 | } 233 | 234 | % Takes as input the image path and optionally the "beforeskip" 235 | \DeclareDocumentCommand{\setchapterimage}{O{55\vscale} m}{% 236 | \setchapterpreamble[o]{% 237 | \vspace*{-27\vscale}\hspace*{\dimexpr - \hoffset - \oddsidemargin - 1in}% 238 | \includegraphics[width=\paperwidth,height=#1+27\vscale,keepaspectratio=false]{#2}% 239 | }% 240 | \chapterstylebar% 241 | % beforeskip=-(figure_height-top_margin) 242 | \RedeclareSectionCommand[beforeskip=-#1, afterskip=6\vscale]{chapter}% 243 | \setlength{\mtocshift}{0cm}% 244 | } 245 | 246 | % By default start with the plain style 247 | \chapterstyleplain 248 | 249 | %---------------------------------------------------------------------------------------- 250 | % FONTS AND STYLES 251 | %---------------------------------------------------------------------------------------- 252 | 253 | % Set KOMA fonts for book-specific elements 254 | \addtokomafont{part}{\normalfont\scshape\bfseries} 255 | \addtokomafont{partentry}{\normalfont\scshape\bfseries} 256 | \addtokomafont{chapter}{\normalfont\bfseries} 257 | \addtokomafont{chapterentry}{\normalfont\bfseries} 258 | 259 | % Set KOMA fonts for elements common to all classes 260 | \addtokomafont{section}{\normalfont\bfseries} 261 | \addtokomafont{subsection}{\normalfont\bfseries} 262 | \addtokomafont{subsubsection}{\normalfont\bfseries} 263 | \addtokomafont{paragraph}{\normalfont\bfseries} 264 | \setkomafont{descriptionlabel}{\normalfont\bfseries} 265 | 266 | %---------------------------------------------------------------------------------------- 267 | % TOC, LOF & LOT 268 | %---------------------------------------------------------------------------------------- 269 | 270 | % Set default options regarding the table of contents 271 | \PassOptionsToClass{toc=listof}{\@baseclass} 272 | \PassOptionsToClass{toc=index}{\@baseclass} 273 | \PassOptionsToClass{toc=bibliography}{\@baseclass} 274 | 275 | %---------------------------------------------------------------------------------------- 276 | % NUMBERING 277 | %---------------------------------------------------------------------------------------- 278 | 279 | %\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering depth 280 | 281 | \counterwithin*{sidenote}{chapter} % Uncomment to reset the sidenote counter at each chapter 282 | %\counterwithout{sidenote}{chapter} % Uncomment to have one sidenote counter for the whole document 283 | -------------------------------------------------------------------------------- /kaohandt.cls: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % kaobook 3 | % LaTeX Class 4 | % Version 0.9.8 (2021/08/23) 5 | % 6 | % This template originates from: 7 | % https://www.LaTeXTemplates.com 8 | % 9 | % For the latest template development version and to make contributions: 10 | % https://github.com/fmarotta/kaobook 11 | % 12 | % Authors: 13 | % Federico Marotta (federicomarotta@mail.com) 14 | % Based on the doctoral thesis of Ken Arroyo Ohori (https://3d.bk.tudelft.nl/ken/en) 15 | % and on the Tufte-LaTeX class. 16 | % Modified for LaTeX Templates by Vel (vel@latextemplates.com) 17 | % 18 | % License: 19 | % LPPL (see included MANIFEST.md file) 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | 23 | %---------------------------------------------------------------------------------------- 24 | % CLASS CONFIGURATION 25 | %---------------------------------------------------------------------------------------- 26 | 27 | \NeedsTeXFormat{LaTeX2e} 28 | \ProvidesClass{kaohandt}[2021/08/23 v0.9.8 kaohandt] 29 | \newcommand{\@baseclass}{scrartcl} % Base class name 30 | 31 | % Set the default options 32 | \PassOptionsToClass{a4paper}{\@baseclass} 33 | 34 | % Pass through any other options to the base class 35 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@baseclass}} 36 | 37 | \ProcessOptions\relax % Process the options 38 | 39 | \LoadClass{\@baseclass} % Load the base class 40 | 41 | \RequirePackage{kao} % Load the code common to all classes 42 | 43 | %---------------------------------------------------------------------------------------- 44 | % TITLE-RELATED SETTINGS 45 | %---------------------------------------------------------------------------------------- 46 | 47 | % Left-align title, authors and date 48 | \xpatchcmd{\@maketitle}{\begin{center}}{\begin{flushleft}}{}{} 49 | \xpatchcmd{\@maketitle}{\end{center}}{\end{flushleft}}{}{} 50 | \xpatchcmd{\@maketitle}{\begin{tabular}[t]{c}}{\begin{tabular}[t]{@{}l@{}}}{}{} 51 | 52 | % Set the font for the title 53 | \addtokomafont{title}{\normalfont\bfseries} 54 | 55 | % Customise the abstract 56 | \RequirePackage[style]{abstract} 57 | 58 | \setlength{\absleftindent}{0pt}% No indentation in the abstract 59 | \if@abstrt 60 | \renewcommand{\abstitlestyle}[1]{% 61 | \vspace{-0.6cm}% 62 | \begin{center}% 63 | {\normalfont\bfseries\hspace{-3em} \abstractname\vspace{-.5em}\vspace{\z@}}% 64 | \end{center}% 65 | } 66 | \else 67 | \renewcommand{\abstitlestyle}[1]{\vspace{-.5em}\vspace{\z@}}% 68 | \fi 69 | 70 | % Set KOMA fonts 71 | \addtokomafont{section}{\normalfont\bfseries} 72 | \addtokomafont{subsection}{\normalfont\bfseries} 73 | \addtokomafont{subsubsection}{\normalfont\bfseries} 74 | \addtokomafont{paragraph}{\normalfont\bfseries} 75 | \setkomafont{descriptionlabel}{\normalfont\bfseries} 76 | 77 | %---------------------------------------------------------------------------------------- 78 | % TOC 79 | %---------------------------------------------------------------------------------------- 80 | 81 | % Adjust the positions of margintoc and marginnotes 82 | \setlength{\mtocshift}{-0.6cm} 83 | \renewcommand{\marginnotevadjust}{-4pt} 84 | 85 | % Do not add lists to the TOC 86 | \PassOptionsToClass{toc=nolistof}{\@baseclass} 87 | \unsettoc{toc}{totoc} 88 | 89 | %---------------------------------------------------------------------------------------- 90 | % NUMBERING 91 | %---------------------------------------------------------------------------------------- 92 | 93 | %\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering depth 94 | 95 | \counterwithin*{sidenote}{section} % Uncomment to reset the sidenote counter at each section 96 | %\counterwithout{sidenote}{section} % Uncomment to have one sidenote counter for the whole document 97 | -------------------------------------------------------------------------------- /kaorefs.sty: -------------------------------------------------------------------------------- 1 | \ProvidesPackage{kaorefs} 2 | 3 | %---------------------------------------------------------------------------------------- 4 | % PACKAGE OPTIONS AND DEPENDENCIES 5 | %---------------------------------------------------------------------------------------- 6 | 7 | % Easily label and reference elements with this package 8 | % Note that, in figures and tables, \label must appear after \caption 9 | % Load this package last 10 | 11 | % Pass this package's options to hyperref and varioref 12 | \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{varioref}} 13 | \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{hyperref}} 14 | \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{cleveref}} 15 | \ProcessOptions\relax 16 | 17 | \let\thmname\relax % Workaround to get rid of an annoying error 18 | \RequirePackage{amsthm} % Needed by cleveref 19 | \RequirePackage{varioref} 20 | \RequirePackage{hyperref} 21 | \RequirePackage[capitalise,nameinlink,noabbrev]{cleveref} 22 | 23 | 24 | %---------------------------------------------------------------------------------------- 25 | % LANGUAGE-SPECIFIC STRINGS 26 | %---------------------------------------------------------------------------------------- 27 | 28 | % #LANGUAGE 29 | \newcommand{\chapternameshort}{} 30 | \newcommand{\sectionname}{} 31 | \newcommand{\sectionnameshort}{} 32 | \newcommand{\subsectionname}{} 33 | \newcommand{\subsectionnameplural}{} 34 | \newcommand{\subsectionnameshort}{} 35 | \newcommand{\figurenameshort}{} 36 | \newcommand{\tablenameshort}{} 37 | \newcommand{\eqname}{} 38 | \newcommand{\eqnameshort}{} 39 | \newcommand{\defname}{} 40 | \newcommand{\assumname}{} 41 | \newcommand{\thmname}{} 42 | \newcommand{\propname}{} 43 | \newcommand{\lemmaname}{} 44 | \newcommand{\remarkname}{} 45 | \newcommand{\examplename}{} 46 | \newcommand{\exercisename}{} 47 | 48 | \addto\captionsgerman{% 49 | \renewcommand{\chapternameshort}{Kap.} 50 | \renewcommand{\sectionname}{Abschnitt} 51 | \renewcommand{\sectionnameshort}{Abschn.} 52 | \renewcommand{\subsectionname}{Unterabschnitt} 53 | \renewcommand{\subsectionnameplural}{Unterabschnitte} 54 | \renewcommand{\subsectionnameshort}{Unterabschn.} 55 | \renewcommand{\figurenameshort}{Abb.} 56 | \renewcommand{\tablenameshort}{Tab.} 57 | \renewcommand{\eqname}{Gleichung} 58 | \renewcommand{\eqnameshort}{Gl.} 59 | \renewcommand{\defname}{Definition} 60 | \renewcommand{\assumname}{Hypothese} 61 | \renewcommand{\thmname}{Satz} 62 | \renewcommand{\propname}{Proposition} 63 | \renewcommand{\lemmaname}{Lemma} 64 | \renewcommand{\remarkname}{Bemerkung} 65 | \renewcommand{\examplename}{Beispiel} 66 | \renewcommand{\exercisename}{Übung} 67 | } 68 | \addto\captionsdanish{% 69 | \renewcommand{\chapternameshort}{Kap.} 70 | \renewcommand{\sectionname}{Sektion} 71 | \renewcommand{\sectionnameshort}{Sek.} 72 | \renewcommand{\subsectionname}{Undersektion} 73 | \renewcommand{\subsectionnameplural}{Undersectioner} 74 | \renewcommand{\subsectionnameshort}{Undersek.} 75 | \renewcommand{\figurenameshort}{Fig.} 76 | \renewcommand{\tablenameshort}{Tab.} 77 | \renewcommand{\eqname}{Formel} 78 | \renewcommand{\eqnameshort}{Frml.} 79 | \renewcommand{\defname}{Definition} 80 | \renewcommand{\assumname}{Hypotese} 81 | \renewcommand{\thmname}{Sætning} 82 | \renewcommand{\propname}{Postulat} 83 | \renewcommand{\lemmaname}{Hjælpesætning} 84 | \renewcommand{\remarkname}{Bemærkning} 85 | \renewcommand{\examplename}{Eksempel} 86 | \renewcommand{\exercisename}{Øvelse} 87 | } 88 | \addto\captionsenglish{% 89 | \renewcommand{\chapternameshort}{Chap.} 90 | \renewcommand{\sectionname}{Section} 91 | \renewcommand{\sectionnameshort}{Sec.} 92 | \renewcommand{\subsectionname}{Subsection} 93 | \renewcommand{\subsectionnameplural}{Subsections} 94 | \renewcommand{\subsectionnameshort}{Subsec.} 95 | \renewcommand{\figurenameshort}{Fig.} 96 | \renewcommand{\tablenameshort}{Tab.} 97 | \renewcommand{\eqname}{Equation} 98 | \renewcommand{\eqnameshort}{Eq.} 99 | \renewcommand{\defname}{Definition} 100 | \renewcommand{\assumname}{Assumption} 101 | \renewcommand{\thmname}{Theorem} 102 | \renewcommand{\propname}{Proposition} 103 | \renewcommand{\lemmaname}{Lemma} 104 | \renewcommand{\remarkname}{Remark} 105 | \renewcommand{\examplename}{Example} 106 | \renewcommand{\exercisename}{Exercise} 107 | } 108 | \addto\captionsitalian{% 109 | \renewcommand{\chapternameshort}{Cap.} 110 | \renewcommand{\sectionname}{Sezione} 111 | \renewcommand{\sectionnameshort}{Sez.} 112 | \renewcommand{\subsectionname}{Sottosezione} 113 | \renewcommand{\subsectionnameplural}{Sottosezioni} 114 | \renewcommand{\subsectionnameshort}{Sottosezione} 115 | \renewcommand{\figurenameshort}{Fig.} 116 | \renewcommand{\tablenameshort}{Tab.} 117 | \renewcommand{\eqname}{Equazione} 118 | \renewcommand{\eqnameshort}{Eq.} 119 | \renewcommand{\defname}{Definizione} 120 | \renewcommand{\assumname}{Assunzione} 121 | \renewcommand{\thmname}{Teorema} 122 | \renewcommand{\propname}{Proposizione} 123 | \renewcommand{\lemmaname}{Lemma} 124 | \renewcommand{\remarkname}{Osservazione} 125 | \renewcommand{\examplename}{Esempio} 126 | \renewcommand{\exercisename}{Esercizio} 127 | } 128 | \addto\captionsrussian{% 129 | \renewcommand{\chapternameshort}{Гл.} 130 | \renewcommand{\sectionname}{Раздел} 131 | \renewcommand{\sectionnameshort}{Разд.} 132 | \renewcommand{\subsectionname}{Подраздел} 133 | \renewcommand{\subsectionnameplural}{Подразделы} 134 | \renewcommand{\subsectionnameshort}{Подразд.} 135 | \renewcommand{\figurenameshort}{Рис.} 136 | \renewcommand{\tablenameshort}{Табл.} 137 | \renewcommand{\eqname}{Формула} 138 | \renewcommand{\eqnameshort}{Ф-ла} 139 | \renewcommand{\defname}{Определение} 140 | \renewcommand{\assumname}{Гипотеза} 141 | \renewcommand{\thmname}{Теорема} 142 | \renewcommand{\propname}{Утверждение} 143 | \renewcommand{\lemmaname}{Лемма} 144 | \renewcommand{\remarkname}{Замечание} 145 | \renewcommand{\examplename}{Пример} 146 | \renewcommand{\exercisename}{Упражнение} 147 | } 148 | % Do you speak other languages? Please, feel free to add the captions! 149 | 150 | 151 | %---------------------------------------------------------------------------------------- 152 | % LABELLING COMMANDS 153 | %---------------------------------------------------------------------------------------- 154 | 155 | \newcommand{\labpage}[1]{\label{page:#1}} 156 | \newcommand{\labpart}[1]{\label{part:#1}} 157 | \newcommand{\labch}[1]{\label{ch:#1}} 158 | \newcommand{\labsec}[1]{\label{sec:#1}} 159 | \newcommand{\labsubsec}[1]{\label{subsec:#1}} 160 | \newcommand{\labfig}[1]{\label{fig:#1}} 161 | \newcommand{\labtab}[1]{\label{tab:#1}} 162 | \newcommand{\labeq}[1]{\label{eq:#1}} 163 | \newcommand{\labdef}[1]{\label{def:#1}} 164 | \newcommand{\labthm}[1]{\label{thm:#1}} 165 | \newcommand{\labassum}[1]{\label{assum:#1}} 166 | \newcommand{\labprop}[1]{\label{prop:#1}} 167 | \newcommand{\lablemma}[1]{\label{lemma:#1}} 168 | \newcommand{\labremark}[1]{\label{remark:#1}} 169 | \newcommand{\labexample}[1]{\label{example:#1}} 170 | \newcommand{\labexercise}[1]{\label{exercise:#1}} 171 | 172 | 173 | %---------------------------------------------------------------------------------------- 174 | % REFERENCING COMMANDS 175 | %---------------------------------------------------------------------------------------- 176 | 177 | \newcommand{\refpage}[1]{\hyperref[#1]{\pagename}\xspace\pageref{page:#1}} % Page 84 178 | \newcommand{\vrefpage}[1]{\vpageref*{page:#1}} % on the following page, on page 84 179 | 180 | % For unnumbered parts 181 | \newcommand{\arefpart}[1]{\hyperref[part:#1]{\partname}\xspace`\nameref{part:#1}'} % Part `Name of the Part' 182 | \newcommand{\avrefpart}[1]{\hyperref[part:#1]{\partname}\xspace`\nameref{part:#1}' \vpageref{part:#1}} % Part `Name of the Part' on page 84 183 | 184 | % For numbered parts 185 | \newcommand{\refpart}[1]{\hyperref[part:#1]{\partname}\xspace\ref{part:#1}} % Part IV 186 | \newcommand{\vrefpart}[1]{\hyperref[part:#1]{\partname}\xspace\vref{part:#1}} % Part IV, Part IV on the following page, Part IV on page 84 187 | \newcommand{\nrefpart}[1]{\hyperref[part:#1]{\partname}\xspace\ref{part:#1} (\nameref{part:#1})} 188 | \newcommand{\frefpart}[1]{\hyperref[part:#1]{\partname\xspace\ref{part:#1} (\nameref{part:#1}) \vpageref{part:#1}}} % Part IV (Name of the Part), Part IV (Name of the Part) on the following page, Part IV (Name of the Part) on page 84) 189 | 190 | %\newcommand{\refch}[1]{\hyperref[#1]{\chaptername\xspace\usekomafont{chapter}\normalsize\nameref{ch:#1}}\xspace\vpageref{ch:#1}\,} 191 | \newcommand{\refchshort}[1]{\hyperref[ch:#1]{\chapternameshort\xspace\ref{ch:#1}}} 192 | \newcommand{\refch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1}}} 193 | \newcommand{\vrefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} \vpageref{ch:#1}}} 194 | \newcommand{\nrefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} (\nameref{ch:#1})}} 195 | \newcommand{\frefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} (\nameref{ch:#1}) \vpageref{ch:#1}}} 196 | 197 | %\newcommand{\refsec}[1]{Section~{\usekomafont{section}\normalsize\nameref{sec:#1}}\xspace\vpageref{sec:#1}\,} 198 | \newcommand{\refsecshort}[1]{\hyperref[sec:#1]{\sectionnameshort\xspace\ref{sec:#1}}} 199 | \newcommand{\refsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1}}} 200 | \newcommand{\vrefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\vref{sec:#1}}} 201 | \newcommand{\nrefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1} (\nameref{sec:#1})}} 202 | \newcommand{\frefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1} (\nameref{sec:#1}) \vpageref{sec:#1}}} 203 | 204 | \newcommand{\refsubsecshort}[1]{\hyperref[subsec:#1]{\sectionnameshort\xspace\ref{subsec:#1}}} 205 | \newcommand{\refsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1}}} 206 | \newcommand{\vrefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\vref{subsec:#1}}} 207 | \newcommand{\nrefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1} (\nameref{subsec:#1})}} 208 | \newcommand{\frefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1} (\nameref{subsec:#1}) \vpageref{subsec:#1}}} 209 | 210 | %\newcommand{\reffig}[1]{{\hypersetup{colorlinks=false}\usekomafont{captionlabel}\hyperref[fig:#1]{Figure}\xspace\ref{fig:#1}}} 211 | \newcommand{\reffigshort}[1]{\hyperref[fig:#1]{\figurenameshort\xspace\ref{fig:#1}}} 212 | \newcommand{\reffig}[1]{\hyperref[fig:#1]{\figurename}\xspace\ref{fig:#1}} 213 | \newcommand{\vreffig}[1]{\hyperref[fig:#1]{\figurename\xspace\vref{fig:#1}}} 214 | 215 | %\newcommand{\reftab}[1]{{\hypersetup{colorlinks=false}\usekomafont{captionlabel}\hyperref[tab:#1]{Table}\xspace\ref{tab:#1}}} 216 | \newcommand{\reftab}[1]{\hyperref[tab:#1]{\tablename}\xspace\ref{tab:#1}} 217 | \newcommand{\vreftab}[1]{\hyperref[tab:#1]{\tablename\xspace\vref{tab:#1}}} 218 | 219 | \newcommand{\refeqshort}[1]{\hyperref[eq:#1]\eqnameshort\xspace(\ref{eq:#1})} 220 | \newcommand{\refeq}[1]{\hyperref[eq:#1]\eqname\xspace\ref{eq:#1}} 221 | \newcommand{\vrefeq}[1]{\hyperref[eq:#1]\eqname\xspace\vref{eq:#1}} 222 | 223 | \newcommand{\refdef}[1]{\hyperref[def:#1]\defname\xspace\ref{def:#1}} 224 | \newcommand{\vrefdef}[1]{\hyperref[def:#1]\defname\xspace\vref{def:#1}} 225 | 226 | \newcommand{\refassum}[1]{\hyperref[assum:#1]\assumname\xspace\ref{assum:#1}} 227 | \newcommand{\vrefassum}[1]{\hyperref[assum:#1]\assumname\xspace\vref{assum:#1}} 228 | 229 | \newcommand{\refthm}[1]{\hyperref[thm:#1]\thmname\xspace\ref{thm:#1}} 230 | \newcommand{\vrefthm}[1]{\hyperref[thm:#1]\thmname\xspace\vref{thm:#1}} 231 | 232 | \newcommand{\refprop}[1]{\hyperref[prop:#1]\propname\xspace\ref{prop:#1}} 233 | \newcommand{\vrefprop}[1]{\hyperref[prop:#1]\propname\xspace\vref{prop:#1}} 234 | 235 | \newcommand{\reflemma}[1]{\hyperref[lemma:#1]\lemmaname\xspace\ref{lemma:#1}} 236 | \newcommand{\vreflemma}[1]{\hyperref[lemma:#1]\lemmaname\xspace\vref{lemma:#1}} 237 | 238 | \newcommand{\refremark}[1]{\hyperref[remark:#1]\remarkname\xspace\ref{remark:#1}} 239 | \newcommand{\vrefremark}[1]{\hyperref[remark:#1]\remarkname\xspace\vref{remark:#1}} 240 | 241 | \newcommand{\refexample}[1]{\hyperref[example:#1]\examplename\xspace\ref{example:#1}} 242 | \newcommand{\vrefexample}[1]{\hyperref[example:#1]\examplename\xspace\vref{example:#1}} 243 | 244 | \newcommand{\refexercise}[1]{\hyperref[exercise:#1]\exercisename\xspace\ref{exercise:#1}} 245 | \newcommand{\vrefexercise}[1]{\hyperref[exercise:#1]\exercisename\xspace\vref{exercise:#1}} 246 | 247 | 248 | %---------------------------------------------------------------------------------------- 249 | % CLEVEREF CUSTOMISATION 250 | %---------------------------------------------------------------------------------------- 251 | 252 | % Hyperlink the page reference as well 253 | \let\oldvpageref\vpageref 254 | \renewcommand{\vpageref}[1]{\hyperref[#1]{\oldvpageref{#1}}} 255 | 256 | % Remove parentheses around equations 257 | \creflabelformat{equation}{#2\textup{#1}#3} 258 | 259 | % Set the refname for subsections 260 | \crefname{subsection}{\subsectionname}{\subsectionnameplural} 261 | \Crefname{subsection}{\subsectionname}{\subsectionnameplural} 262 | -------------------------------------------------------------------------------- /kaotheorems.sty: -------------------------------------------------------------------------------- 1 | \ProvidesPackage{kaotheorems} 2 | 3 | %---------------------------------------------------------------------------------------- 4 | % PACKAGE OPTIONS AND DEPENDENCIES 5 | %---------------------------------------------------------------------------------------- 6 | 7 | \RequirePackage{kvoptions} % Handle package options 8 | \SetupKeyvalOptions{ 9 | family = kaotheorems, 10 | prefix = kaotheorems@ 11 | } 12 | 13 | \DeclareBoolOption{framed}% If true, put theorems into colorful boxes, otherwise write them like normal text 14 | 15 | % Define the options to finely tune the background color of each element. 16 | % 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. 17 | \newcommand{\kaotheorems@defaultbg}{Goldenrod!45!white} 18 | \DeclareStringOption[\kaotheorems@defaultbg]{background} 19 | \DeclareStringOption[\kaotheorems@defaultbg]{theorembackground} 20 | \DeclareStringOption[\kaotheorems@defaultbg]{propositionbackground} 21 | \DeclareStringOption[\kaotheorems@defaultbg]{lemmabackground} 22 | \DeclareStringOption[\kaotheorems@defaultbg]{corollarybackground} 23 | \DeclareStringOption[\kaotheorems@defaultbg]{definitionbackground} 24 | \DeclareStringOption[\kaotheorems@defaultbg]{assumptionbackground} 25 | \DeclareStringOption[\kaotheorems@defaultbg]{remarkbackground} 26 | \DeclareStringOption[\kaotheorems@defaultbg]{examplebackground} 27 | \DeclareStringOption[\kaotheorems@defaultbg]{exercisebackground} 28 | 29 | \ProcessKeyvalOptions{kaotheorems} % Process the options 30 | 31 | \let\openbox\relax % Workaround to avoid a nasty error 32 | \RequirePackage{amsmath} % Improved mathematics 33 | \RequirePackage{amsthm} % Mathematical environments 34 | \RequirePackage{thmtools} % Theorem styles 35 | 36 | %---------------------------------------------------------------------------------------- 37 | % STYLE DEFINITIONS 38 | %---------------------------------------------------------------------------------------- 39 | 40 | \ifkaotheorems@framed% Define the style of the mdframed boxes for theorems 41 | \RequirePackage[most]{tcolorbox} 42 | 43 | % Box style 44 | \tcbset{tcbkao/.style={ 45 | breakable, 46 | before skip=\topskip, 47 | after skip=\topskip, 48 | left skip=0pt, 49 | right skip=0pt, 50 | top=5pt, 51 | bottom=3pt, 52 | left=2pt, 53 | right=2pt, 54 | sharp corners, 55 | boxrule=0pt, 56 | frame hidden, 57 | }} 58 | 59 | % Theorem styles 60 | \declaretheoremstyle[ 61 | %spaceabove=.5\thm@preskip, 62 | %spacebelow=.5\thm@postskip, 63 | %headfont=\normalfont\bfseries,%\scshape, 64 | %notefont=\normalfont, notebraces={ (}{)}, 65 | bodyfont=\normalfont\itshape, 66 | %headformat={\NAME\space\NUMBER\space\NOTE}, 67 | headpunct={}, 68 | %postheadspace={.5em plus .1em minus .1em}, 69 | %prefoothook={\hfill\qedsymbol} 70 | ]{kaoplain} 71 | \declaretheoremstyle[ 72 | %spaceabove=.5\thm@preskip, 73 | %spacebelow=.5\thm@postskip, 74 | %headfont=\normalfont\bfseries,%\scshape, 75 | %notefont=\normalfont, notebraces={ (}{)}, 76 | bodyfont=\normalfont\itshape, 77 | %headformat={\NAME\space\NUMBER\space\NOTE}, 78 | headpunct={}, 79 | postheadspace={.5em plus .1em minus .1em}, 80 | %prefoothook={\hfill\qedsymbol} 81 | ]{kaodefinition} 82 | \declaretheoremstyle[ 83 | %spaceabove=.5\thm@preskip, 84 | %spacebelow=.5\thm@postskip, 85 | %headfont=\normalfont\bfseries,%\scshape, 86 | %notefont=\normalfont, notebraces={ (}{)}, 87 | bodyfont=\normalfont\itshape, 88 | %headformat={\NAME\space\NUMBER\space\NOTE}, 89 | headpunct={}, 90 | postheadspace={.5em plus .1em minus .1em}, 91 | %prefoothook={\hfill\qedsymbol} 92 | ]{kaoassumption} 93 | \declaretheoremstyle[ 94 | %spaceabove=.5\thm@preskip, 95 | %spacebelow=.5\thm@postskip, 96 | %headfont=\normalfont\bfseries, 97 | %notefont=\normalfont, notebraces={ (}{)}, 98 | %bodyfont=\normalfont, 99 | %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE}, 100 | %headformat={\NAME\space\NUMBER\space\NOTE}, 101 | headpunct={}, 102 | postheadspace={.5em plus .1em minus .1em}, 103 | %refname={theorem,theorems}, 104 | %Refname={Theorem,Theorems}, 105 | ]{kaoremark} 106 | \declaretheoremstyle[ 107 | %spaceabove=.5\thm@preskip, 108 | %spacebelow=.5\thm@postskip, 109 | %headfont=\normalfont\bfseries, 110 | %notefont=\normalfont, notebraces={ (}{)}, 111 | %bodyfont=\normalfont, 112 | %headformat={\NAME\space\NUMBER\space\NOTE}, 113 | headpunct={}, 114 | postheadspace={.5em plus .1em minus .1em}, 115 | %prefoothook={\hfill\qedsymbol} 116 | %refname={theorem,theorems}, 117 | %Refname={Theorem,Theorems}, 118 | ]{kaoexample} 119 | \declaretheoremstyle[ 120 | %spaceabove=.5\thm@preskip, 121 | %spacebelow=.5\thm@postskip, 122 | %headfont=\normalfont\bfseries, 123 | %notefont=\normalfont, notebraces={ (}{)}, 124 | %bodyfont=\small, 125 | %headformat={\NAME\space\NUMBER\space\NOTE}, 126 | headpunct={}, 127 | postheadspace={.5em plus .1em minus .1em}, 128 | %prefoothook={\hfill\qedsymbol} 129 | %refname={theorem,theorems}, 130 | %Refname={Theorem,Theorems}, 131 | ]{kaoexercise} 132 | 133 | % Theorems using the 'kaoplain' style 134 | \theoremstyle{kaoplain} 135 | \declaretheorem[ 136 | name=Theorem, 137 | style=kaoplain, 138 | %refname={theorem,theorems}, 139 | refname={Theorem,Theorems}, 140 | Refname={Theorem,Theorems}, 141 | numberwithin=section, 142 | ]{theorem} 143 | \tcolorboxenvironment{theorem}{ 144 | colback=\kaotheorems@theorembackground,tcbkao 145 | } 146 | \declaretheorem[ 147 | name=Proposition, 148 | %refname={proposition,propositions}, 149 | refname={Proposition,Propositions}, 150 | Refname={Proposition,Propositions}, 151 | sibling=theorem, 152 | ]{proposition} 153 | \tcolorboxenvironment{proposition}{ 154 | colback=\kaotheorems@propositionbackground,tcbkao 155 | } 156 | \declaretheorem[ 157 | name=Lemma, 158 | %refname={lemma,lemmas}, 159 | refname={Lemma,Lemmas}, 160 | Refname={Lemma,Lemmas}, 161 | sibling=theorem, 162 | ]{lemma} 163 | \tcolorboxenvironment{lemma}{ 164 | colback=\kaotheorems@lemmabackground,tcbkao 165 | } 166 | \declaretheorem[ 167 | name=Corollary, 168 | %refname={corollary,corollaries}, 169 | refname={Corollary,Corollaries}, 170 | Refname={Corollary,Corollaries}, 171 | sibling=theorem, 172 | ]{corollary} 173 | \tcolorboxenvironment{corollary}{ 174 | colback=\kaotheorems@corollarybackground,tcbkao 175 | } 176 | 177 | % Theorems using the 'kaodefinition' style 178 | \theoremstyle{kaodefinition} 179 | \declaretheorem[ 180 | name=Definition, 181 | %refname={definition,definitions}, 182 | refname={Definition,Definitions}, 183 | Refname={Definition,Definitions}, 184 | numberwithin=section, 185 | ]{definition} 186 | \tcolorboxenvironment{definition}{ 187 | colback=\kaotheorems@definitionbackground,tcbkao 188 | } 189 | 190 | % Theorems using the 'kaoassumption' style 191 | \theoremstyle{kaoassumption} 192 | \declaretheorem[ 193 | name=Assumption, 194 | %refname={assumption,assumptions}, 195 | refname={Assumption,Assumptions}, 196 | Refname={Assumption,Assumptions}, 197 | numberwithin=section, 198 | ]{assumption} 199 | \tcolorboxenvironment{assumption}{ 200 | colback=\kaotheorems@assumptionbackground,tcbkao 201 | } 202 | 203 | % Theorems using the 'kaoremark' style 204 | \theoremstyle{kaoremark} 205 | \declaretheorem[ 206 | name=Remark, 207 | %refname={remark,remarks}, 208 | refname={Remark,Remarks}, 209 | Refname={Remark,Remarks}, 210 | numberwithin=section, 211 | ]{remark} 212 | \tcolorboxenvironment{remark}{ 213 | colback=\kaotheorems@remarkbackground,tcbkao 214 | } 215 | 216 | % Theorems using the 'kaoexample' style 217 | \theoremstyle{kaoexample} 218 | \declaretheorem[ 219 | name=Example, 220 | %refname={example,examples}, 221 | refname={Example,Examples}, 222 | Refname={Example,Examples}, 223 | numberwithin=section, 224 | ]{example} 225 | \tcolorboxenvironment{example}{ 226 | colback=\kaotheorems@examplebackground,tcbkao 227 | } 228 | 229 | % Theorems using the 'kaoexercise' style 230 | \theoremstyle{kaoexercise} 231 | \declaretheorem[ 232 | name=Exercise, 233 | %refname={exercise,exercises}, 234 | refname={Exercise,Exercises}, 235 | Refname={Exercise,Exercises}, 236 | numberwithin=section, 237 | ]{exercise} 238 | \tcolorboxenvironment{exercise}{ 239 | colback=\kaotheorems@exercisebackground,tcbkao 240 | } 241 | 242 | %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}} 243 | %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}} 244 | %\renewcommand{\qedsymbol}{$\blacksquare$} 245 | \else % If not using mdframed 246 | % Theorem styles 247 | \declaretheoremstyle[ 248 | spaceabove=.6\thm@preskip, 249 | spacebelow=.1\thm@postskip, 250 | %headfont=\normalfont\bfseries,%\scshape, 251 | %notefont=\normalfont, notebraces={ (}{)}, 252 | bodyfont=\normalfont\itshape, 253 | %headformat={\NAME\space\NUMBER\space\NOTE}, 254 | headpunct={}, 255 | %postheadspace={.5em plus .1em minus .1em}, 256 | %prefoothook={\hfill\qedsymbol} 257 | ]{kaoplain} 258 | \declaretheoremstyle[ 259 | spaceabove=.6\thm@preskip, 260 | spacebelow=.1\thm@postskip, 261 | %headfont=\normalfont\bfseries,%\scshape, 262 | %notefont=\normalfont, notebraces={ (}{)}, 263 | bodyfont=\normalfont\itshape, 264 | %headformat={\NAME\space\NUMBER\space\NOTE}, 265 | headpunct={}, 266 | %postheadspace={.5em plus .1em minus .1em}, 267 | %prefoothook={\hfill\qedsymbol} 268 | ]{kaodefinition} 269 | \declaretheoremstyle[ 270 | spaceabove=.6\thm@preskip, 271 | spacebelow=.1\thm@postskip, 272 | %headfont=\normalfont\bfseries,%\scshape, 273 | %notefont=\normalfont, notebraces={ (}{)}, 274 | bodyfont=\normalfont\itshape, 275 | %headformat={\NAME\space\NUMBER\space\NOTE}, 276 | headpunct={}, 277 | %postheadspace={.5em plus .1em minus .1em}, 278 | %prefoothook={\hfill\qedsymbol} 279 | ]{kaoassumption} 280 | \declaretheoremstyle[ 281 | spaceabove=.6\thm@preskip, 282 | spacebelow=.1\thm@postskip, 283 | %headfont=\normalfont\bfseries, 284 | %notefont=\normalfont, notebraces={ (}{)}, 285 | %bodyfont=\normalfont, 286 | %headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE}, 287 | %headformat={\NAME\space\NUMBER\space\NOTE}, 288 | headpunct={}, 289 | %postheadspace={.5em plus .1em minus .1em}, 290 | %refname={theorem,theorems}, 291 | %Refname={Theorem,Theorems}, 292 | ]{kaoremark} 293 | \declaretheoremstyle[ 294 | spaceabove=.6\thm@preskip, 295 | spacebelow=.1\thm@postskip, 296 | %headfont=\normalfont\bfseries, 297 | %notefont=\normalfont, notebraces={ (}{)}, 298 | %bodyfont=\normalfont, 299 | %headformat={\NAME\space\NUMBER\space\NOTE}, 300 | headpunct={}, 301 | %postheadspace={.5em plus .1em minus .1em}, 302 | %prefoothook={\hfill\qedsymbol} 303 | %refname={theorem,theorems}, 304 | %Refname={Theorem,Theorems}, 305 | ]{kaoexample} 306 | \declaretheoremstyle[ 307 | %spaceabove=.5\thm@preskip, 308 | %spacebelow=.5\thm@postskip, 309 | %headfont=\normalfont\bfseries, 310 | %notefont=\normalfont, notebraces={ (}{)}, 311 | %bodyfont=\normalfont, 312 | %headformat={\NAME\space\NUMBER\space\NOTE}, 313 | headpunct={}, 314 | postheadspace={.5em plus .1em minus .1em}, 315 | %prefoothook={\hfill\qedsymbol} 316 | %refname={theorem,theorems}, 317 | %Refname={Theorem,Theorems}, 318 | ]{kaoexercise} 319 | 320 | % Theorems using the 'kaoplain' style 321 | \theoremstyle{kaoplain} 322 | \declaretheorem[ 323 | name=Theorem, 324 | refname={Theorem,Theorems}, 325 | Refname={Theorem,Theorems}, 326 | numberwithin=section, 327 | ]{theorem} 328 | \declaretheorem[ 329 | name=Proposition, 330 | refname={Proposition,Propositions}, 331 | Refname={Proposition,Propositions}, 332 | sibling=theorem, 333 | ]{proposition} 334 | \declaretheorem[ 335 | name=Lemma, 336 | refname={Lemma,Lemmas}, 337 | Refname={Lemma,Lemmas}, 338 | sibling=theorem, 339 | ]{lemma} 340 | \declaretheorem[ 341 | name=Corollary, 342 | refname={Corollary,Corollaries}, 343 | Refname={Corollary,Corollaries}, 344 | sibling=theorem, 345 | ]{corollary} 346 | 347 | % Theorems using the 'kaodefinition' style 348 | \theoremstyle{kaodefinition} 349 | \declaretheorem[ 350 | name=Definition, 351 | refname={Definition,Definitions}, 352 | Refname={Definition,Definitions}, 353 | numberwithin=section, 354 | ]{definition} 355 | 356 | % Theorems using the 'kaoassumption' style 357 | \theoremstyle{kaoassumption} 358 | \declaretheorem[ 359 | name=Assumption, 360 | refname={Assumption,Assumptions}, 361 | Refname={Assumption,Assumptions}, 362 | numberwithin=section, 363 | ]{assumption} 364 | 365 | % Theorems using the 'kaoremark' style 366 | \theoremstyle{kaoremark} 367 | \declaretheorem[ 368 | name=Remark, 369 | refname={Remark,Remarks}, 370 | Refname={Remark,Remarks}, 371 | numberwithin=section, 372 | ]{remark} 373 | 374 | % Theorems using the 'kaoexample' style 375 | \theoremstyle{kaoexample} 376 | \declaretheorem[ 377 | name=Example, 378 | refname={Example,Examples}, 379 | Refname={Example,Examples}, 380 | numberwithin=section, 381 | ]{example} 382 | 383 | % Theorems using the 'kaoexercise' style 384 | \theoremstyle{kaoexercise} 385 | \declaretheorem[ 386 | name=Exercise, 387 | refname={Exercise,Exercises}, 388 | Refname={Exercise,Exercises}, 389 | numberwithin=section, 390 | ]{exercise} 391 | 392 | %\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}} 393 | %\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}} 394 | %\renewcommand{\qedsymbol}{$\blacksquare$} 395 | \fi 396 | 397 | --------------------------------------------------------------------------------