### KaoBook Chapter Organization Example Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Provides an example of how to organize content using parts and chapters in KaoBook, including switching page layouts between parts and defining regular and appendix chapters. ```latex % Organize content with parts \pagelayout{wide} \addpart{Part Title} \pagelayout{margin} % Regular chapters \chapter{Chapter Title} \input{chapters/chapter1.tex} % Appendix chapters \appendix \chapter{Appendix Title} ``` -------------------------------- ### Configure Kaotheorems Package for Themed Environments Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md This code configures the 'kaotheorems' package to apply distinct background colors and framing to various theorem-like environments such as theorems, definitions, propositions, lemmas, and examples. ```latex \usepackage[ framed=true, theorembackground=blue!15, definitionbackground=green!10, propositionbackground=orange!10, lemmabackground=yellow!15, corollarybackground=purple!10, remarkbackground=gray!10, examplebackground=cyan!10, exercisebackground=red!10, ]{kaotheorems} ``` -------------------------------- ### LaTeX Bibliography Setup with Biblatex Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Details the setup for bibliography management using Biblatex and Biber within the KaoBook environment. It includes loading the kaobiblio package, specifying bibliography files, and configuring citation styles and backend options. ```latex % In preamble \usepackage{kaobiblio} \addbibresource{main.bib} % Bibliography file \addbibresource{extra.bib} % Additional files % Choose citation style \usepackage[ style=numeric-comp, % Numeric citations [1,2,3] sorting=none, % Order by appearance backend=biber, % Use biber backend hyperref=true, % Hyperlinked citations backref=true, % Back references ]{biblatex} ``` -------------------------------- ### LaTeX Theorem Environments Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates the usage of various theorem-like environments provided by the KaoBook package, including theorems, propositions, lemmas, definitions, assumptions, remarks, examples, and exercises. These environments allow for structured presentation of mathematical content. ```latex \begin{theorem}[Optional Name] Every vector space has a basis. \labthm{basis-theorem} \end{theorem} \begin{proposition}[Optional Name] This follows from the theorem. \labprop{corollary-prop} \end{proposition} \begin{lemma}[Optional Name] A useful intermediate result. \lablemma{useful-lemma} \end{lemma} \begin{corollary}[Optional Name] An immediate consequence. \end{corollary} \begin{definition}[Vector Space] A vector space over a field $F$ is a set $V$ together with... \labdef{vector-space} \end{definition} \begin{assumption}[Linearity] We assume all functions are linear. \labassum{linearity} \end{assumption} \begin{remark} This is worth noting. \labremark{important-note} \end{remark} \begin{example}[Euclidean Space] Consider $\mathbb{R}^3$ with the standard inner product. \labexample{euclidean} \end{example} \begin{exercise} Prove that every finite-dimensional vector space has a basis. \labexercise{basis-exercise} \end{exercise} ``` -------------------------------- ### Kaobook Example Project Layouts Source: https://github.com/anastassaoui/kaobook1/blob/main/MANIFEST.md Illustrates the directory structures for various example projects using Kaobook, including a minimal book, a report, a documentation project with extensive sub-chapters, and a machine learning project. These examples showcase how to organize project files. ```File Structure kaobook/ `-- examples/ |-- minimal_book/ | `-- main.tex |-- minimal_report/ | `-- main.tex |-- documentation/ | |-- main.tex | |-- main.bib | |-- glossary.tex | `-- chapters/ | |-- appendix.tex | |-- figsntabs.tex | |-- introduction.tex | |-- layout.tex | |-- mathematics.tex | |-- options.tex | |-- preface.tex | |-- references.tex | `-- textnotes.tex `-- machine_learning_project/ |-- sections/ | |-- introduction.tex | |-- data.tex | |-- results.tex | `-- discussion.tex |-- main.tex `-- main.bib ``` -------------------------------- ### Multilingual Book Template Setup in LaTeX Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates setting up a multilingual document using the KaoBook LaTeX class with Italian and English language support. It includes package configurations for bibliography, theorems, and references, showcasing chapter and theorem environments in different languages. ```latex \documentclass[ a4paper, fontsize=10pt, twoside=true, ]{kaobook} % Language setup \usepackage[italian,english]{babel} \usepackage{kaobiblio} \usepackage{kaotheorems} \usepackage{kaorefs} % Bibliography \addbibresource{references.bib} \title{Multilingual Document} \author{Author Name} \begin{document} \frontmatter \maketitle \tableofcontents \mainmatter \chapter{English Chapter} This chapter is in English\sidenote{English sidenote}. \begin{theorem} This theorem is stated in English. \end{theorem} See \refthm{italian-theorem} for the Italian version. \selectlanguage{italian} \chapter{Capitolo Italiano} \labch{capitolo-italiano} Questo capitolo è in italiano\sidenote{Nota a margine in italiano}. \begin{theorem}[Teorema Principale] Questo teorema è enunciato in italiano. \labthm{italian-theorem} \end{theorem} Vedi \refch{capitolo-italiano} per riferimenti. \selectlanguage{english} \backmatter \printbibliography \end{document} ``` -------------------------------- ### LaTeX: Margin Tables (Compact) Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md An example of a compact table placed in the margin. It uses the `margintable` environment with a basic `tabular` structure and caption. ```latex \begin{margintable} \centering \caption{Compact margin table} \begin{tabular}{cc} \toprule A & B \\ \midrule 1 & 2 \\ 3 & 4 \\ \bottomrule \end{tabular} \labtab{margin-table} \end{margintable} ``` -------------------------------- ### Minimal KaoBook Document Structure Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md A minimal LaTeX document setup using the `kaobook` class. It includes essential packages for bibliography, theorems, and cross-referencing, along with basic document structure commands like ` rontmatter`, `mainmatter`, and `ackmatter`. ```latex \documentclass[ a4paper, % Paper size fontsize=10pt, % Base font size twoside=true, % Two-sided layout ]{kaobook} % Essential packages \usepackage{kaobiblio} % Bibliography \usepackage{kaotheorems} % Theorem environments \usepackage{kaorefs} % Cross-referencing \addbibresource{main.bib} % Bibliography file \begin{document} \frontmatter \maketitle \tableofcontents \mainmatter \chapter{Introduction} Your content here... \backmatter \printbibliography \end{document} ``` -------------------------------- ### BibTeX Bibliography Entries Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Examples of BibTeX entries for articles, books, and incollections. These entries define the metadata for bibliographic items. ```bibtex @article{einstein1905, author = {Einstein, Albert}, title = {Zur Elektrodynamik bewegter K{"o}rper}, journal = {Annalen der Physik}, volume = {17}, number = {10}, pages = {891--921}, year = {1905}, doi = {10.1002/andp.19053221004} } @book{knuth1984, author = {Knuth, Donald E.}, title = {The {TeX}book}, publisher = {Addison-Wesley}, year = {1984}, isbn = {0-201-13447-0} } @incollection{chapter2020, author = {Smith, John}, title = {Modern Techniques}, booktitle = {Handbook of Advanced Methods}, editor = {Johnson, Mary}, publisher = {Academic Press}, year = {2020}, pages = {123--156} } ``` -------------------------------- ### KaoBook Cross-Referencing: Labeling Commands Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands provided by kaorefs.sty for systematically labeling structural elements, floats, and mathematical environments with specific prefixes. ```latex % Structural elements \labpage{intro} % \label{page:intro} \labpart{fundamentals} % \label{part:fundamentals} \labch{introduction} % \label{ch:introduction} \labsec{methods} % \label{sec:methods} \labsubsec{analysis} % \label{subsec:analysis} % Floats \labfig{results-plot} % \label{fig:results-plot} \labtab{data-summary} % \label{tab:data-summary} \labeq{main-equation} % \label{eq:main-equation} % Mathematical environments \labdef{vector-space} % \label{def:vector-space} \labthm{main-theorem} % \label{thm:main-theorem} \labprop{useful-prop} % \label{prop:useful-prop} \lablemma{key-lemma} % \label{lemma:key-lemma} \labremark{important} % \label{remark:important} \labexample{simple} % \label{example:simple} ``` -------------------------------- ### LaTeX Package Loading Order Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates the correct order for loading packages like amsmath, graphicx, kaotheorems, and kaorefs to avoid conflicts and ensure proper functionality. ```latex \usepackage{amsmath} % Before kaotheorems \usepackage{graphicx} % Before kao \usepackage{kaotheorems} \usepackage{kaorefs} % Load last (contains hyperref) ``` -------------------------------- ### LaTeX Proof Environments Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates the usage of the proof environment for presenting mathematical proofs. It shows how to associate a proof with a specific theorem using labels and how to use custom QED symbols. ```latex % Proof with Theorem Reference \begin{proof}[Proof of Theorem~\ref{thm:basis-theorem}] Let $V$ be a vector space. Consider the collection... Therefore, every vector space has a basis. \end{proof} % Proof with custom QED symbol \begin{proof} The proof follows directly. \qedhere \end{proof} ``` -------------------------------- ### LaTeX Mathematical Environments in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates theorem-like, definition-like, informal, and proof environments provided by the KaoBook LaTeX class. These environments help structure mathematical content with distinct formatting. ```latex % Theorem-like environments \begin{theorem}[name] ... \end{theorem} \begin{proposition}[name] ... \end{proposition} \begin{lemma}[name] ... \end{lemma} \begin{corollary}[name] ... \end{corollary} % Definition-like environments \begin{definition}[name] ... \end{definition} \begin{assumption}[name] ... \end{assumption} % Informal environments \begin{remark} ... \end{remark} \begin{example}[name] ... \end{example} \begin{exercise} ... \end{exercise} % Proof environment \begin{proof}[name] ... \end{proof} ``` -------------------------------- ### Basic KaoBook LaTeX Document Template Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md A fundamental template for a book using the KaoBook LaTeX class. It includes essential packages, document metadata, frontmatter, mainmatter, and backmatter setup for a complete book structure. ```latex \documentclass[ a4paper, fontsize=10pt, twoside=true, numbers=noenddot, ]{kaobook} % Load packages \usepackage[english]{babel} \usepackage{kaobiblio} \usepackage[framed=true]{kaotheorems} \usepackage{kaorefs} % Bibliography \addbibresource{main.bib} % Document metadata \title{My Book Title} \author{Author Name} \date{\today} \begin{document} \frontmatter \maketitle \tableofcontents \mainmatter \setchapterstyle{kao} \chapter{Introduction} \labch{intro} This is the first chapter\sidenote{This is a sidenote}. \chapter{Main Content} \labch{main} \begin{theorem}[Main Result] This is an important theorem. \labthm{main-result} \end{theorem} \backmatter \printbibliography \end{document} ``` -------------------------------- ### LaTeX Advanced Customization in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Provides examples of advanced customization, including defining custom chapter styles (`\DeclareDocumentCommand`), page layouts (`\newgeometry`), theorem styles (`\declaretheoremstyle`), and caption formats (`\DeclareCaptionFormat`). ```latex % Custom chapter style \DeclareDocumentCommand{\setchapterstyle}{m}{...} % Custom page layout \newcommand{\customlayout}{% \newgeometry{...}% \recalchead% } % Custom theorem style \declaretheoremstyle[options]{style-name} \declaretheorem[style=style-name]{environment-name} % Custom caption format \DeclareCaptionFormat{format-name}{formatting} \captionsetup{format=format-name} ``` -------------------------------- ### LaTeX: Standard Tables Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates the creation of standard tables within the main text body using the `table` environment and `tabular` for content. Includes `caption` and `labtab` for labeling. ```latex \begin{table}[htbp] \centering \caption{Standard table} \begin{tabular}{lcc} \toprule Item & Value 1 & Value 2 \\ \midrule A & 1 & 2 \\ B & 3 & 4 \\ \bottomrule \end{tabular} \labtab{standard-table} \end{table} ``` -------------------------------- ### LaTeX: Margin Table of Contents Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Provides examples for generating a Table of Contents in the margin. This includes basic usage, custom offsets, placement within chapter preambles, and controlling the depth of the TOC. ```latex % Basic margin TOC \margintoc % With custom offset \margintoc[-5mm] % In chapter preamble \setchapterpreamble[u]{\margintoc} \chapter{Chapter with Margin TOC} % Custom depth \setcounter{margintocdepth}{1} % Only sections, not subsections ``` -------------------------------- ### KaoBook Cross-Referencing: Reference Commands Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands from kaorefs.sty for referencing chapters, sections, figures, tables, equations, and mathematical environments, with options for short or verbose output. ```latex % Chapters \refch{introduction} % Chapter 1 \vrefch{introduction} % Chapter 1 on page 15 \nrefch{introduction} % Chapter 1 (Introduction) \frefch{introduction} % Chapter 1 (Introduction) on page 15 \refchshort{introduction} % Chap. 1 % Sections \refsec{methods} % Section 2.1 \vrefsec{methods} % Section 2.1 on page 25 \nrefsec{methods} % Section 2.1 (Methods) \frefsec{methods} % Section 2.1 (Methods) on page 25 \refsecshort{methods} % Sec. 2.1 % Figures and Tables \reffig{results-plot} % Figure 3.2 \vreffig{results-plot} % Figure 3.2 on page 45 \reffigshort{results-plot} % Fig. 3.2 \reftab{data-summary} % Table 2.1 \vreftab{data-summary} % Table 2.1 on page 30 % Equations \refeq{main-equation} % Equation 4.1 \vrefeq{main-equation} % Equation 4.1 on page 67 \refeqshort{main-equation} % Eq. 4.1 % Mathematical Environments \refdef{vector-space} % Definition 1.1 \vrefdef{vector-space} % Definition 1.1 on page 12 \refthm{main-theorem} % Theorem 2.3 \vrefthm{main-theorem} % Theorem 2.3 on page 34 \refprop{useful-prop} % Proposition 2.4 \reflemma{key-lemma} % Lemma 2.5 \refremark{important} % Remark 2.1 \refexample{simple} % Example 2.2 ``` -------------------------------- ### Troubleshoot Glossary Compilation Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Bash commands for troubleshooting glossary compilation problems. This involves checking for the existence of `.glo` files and manually compiling glossaries using `makeglossaries`. ```bash # Check if .glo file exists ls -la main.glo # Manual glossary compilation makeglossaries -d . main ``` -------------------------------- ### LaTeX: Wide Tables Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Shows how to create tables that span the full page width, accommodating more columns. Uses the `table*` environment for this purpose. ```latex \begin{table*}[htbp] \centering \caption{Wide table spanning full width} \begin{tabular}{lccccc} \toprule Item & Col1 & Col2 & Col3 & Col4 & Col5 \\ \midrule Data & 1 & 2 & 3 & 4 & 5 \\ \bottomrule \end{tabular} \labtab{wide-table} \end{table*} ``` -------------------------------- ### Use Special Text Commands Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Provides semantic markup commands for common technical terms like LaTeX commands, environments, packages, classes, options, and file paths. ```latex \Command{includegraphics} % LaTeX commands \Environment{theorem} % Environment names \Package{amsmath} % Package names \Class{article} % Document classes \Option{twoside} % Class options \Path{/home/user/file.tex} % File paths ``` -------------------------------- ### Troubleshoot Font Warnings with XeLaTeX/LuaLaTeX Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands for addressing font warnings when using XeLaTeX or LuaLaTeX. This involves ensuring fonts are installed or specifying alternative fonts using \setmainfont, \setsansfont, and \setmonofont. ```latex % Ensure fonts are installed or use alternatives \setmainfont{Latin Modern Roman} \setsansfont{Latin Modern Sans} \setmonofont{Latin Modern Mono} ``` -------------------------------- ### LaTeX: Margin Listings with Python Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates placing code listings in the margin using the `marginlisting` environment. It integrates with the `listings` package to format code, specifying the language like Python. ```latex \begin{marginlisting}[offset] \begin{lstlisting}[language=Python] def hello_world(): print("Hello, World!") \end{lstlisting} \caption{Python code} \end{marginlisting} ``` -------------------------------- ### LaTeX: Long Tables Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates creating tables that span multiple pages using the `longtable` environment. It includes standard headers, footers, and continuation notices for multi-page tables. ```latex \begin{longtable}{lcc} \caption{Long table with page breaks} \\ \toprule Column 1 & Column 2 & Column 3 \\ \midrule \endfirsthead \multicolumn{3}{c}{\tablename\ \thetable{} -- continued} \\ \toprule Column 1 & Column 2 & Column 3 \\ \midrule \endhead \midrule \multicolumn{3}{r}{Continued on next page} \\ \endfoot \bottomrule \endlastfoot Row 1 & Data 1 & Data 2 \\ Row 2 & Data 3 & Data 4 \\ % ... many more rows \end{longtable} ``` -------------------------------- ### LaTeX Color Customization in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates how to customize colors for hyperlinks (`\hypersetup`) and backgrounds of theorem environments (e.g., `theorembackground`) and headings (`\addtokomafont`) within the KaoBook LaTeX class. ```latex % Hyperlink colors \hypersetup{ linkcolor=color, % Internal links citecolor=color, % Citations urlcolor=color, % URLs } % Theorem colors (kaotheorems options) theorembackground=color definitionbackground=color examplebackground=color % ... etc for each theorem type % Heading colors \addtokomafont{chapter}{\color{color}} \addtokomafont{section}{\color{color}} ``` -------------------------------- ### LaTeX UTF-8 Encoding Setup Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Ensures UTF-8 encoding for LaTeX documents, specifying the use of \usepackage[utf8]{inputenc} for pdfLaTeX and noting native UTF-8 support in XeLaTeX/LuaLaTeX. Also advises checking editor file encoding. ```latex % Ensure UTF-8 encoding \usepackage[utf8]{inputenc} % For pdfLaTeX % XeLaTeX/LuaLaTeX handle UTF-8 natively % Check file encoding in your editor ``` -------------------------------- ### TeXstudio Configuration for Bibliography and Glossary Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Instructions for configuring TeXstudio to use Biber for bibliography and makeglossaries for glossary compilation. This involves setting commands and default tools within TeXstudio's options. ```apidoc TeXstudio Configuration: 1. Options → Configure TeXstudio 2. Commands → Bibliography: `biber %` 3. Build → User Commands → Add: `makeglossaries %` 4. Build → Default Bibliography Tool: `Biber` ``` -------------------------------- ### LaTeX Glossary and Index Commands in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Explains how to define and use glossary entries (`\newglossaryentry`, `\gls`, `\acrfull`) and index entries (`\index`) for managing terminology and creating an index within a document. ```latex % Glossary entries (in glossary.tex) \newglossaryentry{label}{name=name,description=description} \newacronym{label}{abbrev}{full form} % Using glossary entries \gls{label} % First use: full form, subsequent: abbreviation \glspl{label} % Plural form \Gls{label} % Capitalized \acrfull{label} % Always full form \acrshort{label} % Always abbreviation % Index entries \index{term} % Basic index entry \index{term!subterm} % Subentry \index{term|textbf} % Bold page number ``` -------------------------------- ### Configure pdfLaTeX Fonts Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Sets up Palatino-based fonts for text and math, along with the Beramono font for monospaced text, when using the pdfLaTeX engine. ```latex % Palatino-based font setup \RequirePackage[scaled=.97,helvratio=.93,p,theoremfont]{newpxtext} \RequirePackage[vvarbb,smallerops,bigdelims]{newpxmath} \RequirePackage[scaled=.85]{beramono} ``` -------------------------------- ### Full LaTeX Compilation Sequence Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Details a comprehensive compilation process for LaTeX documents that utilize features like nomenclature, indexing, bibliography, and glossaries. This sequence ensures all components are correctly generated and cross-referenced. ```bash # Complete sequence for all features pdflatex -interaction=nonstopmode main.tex makeindex main.nlo -s nomencl.ist -o main.nls # Nomenclature makeindex main.idx # Index biber main # Bibliography pdflatex main.tex makeglossaries main # Glossary pdflatex main.tex # Final pass ``` -------------------------------- ### KaoBook Page Layout Modes Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Shows the LaTeX commands for switching between KaoBook's distinct page layout modes: margin, wide, and fullwidth, each with specific design characteristics. ```latex \pagelayout{margin} % Text width: 107mm % Margin width: 47.7mm % Margin separation: 6.2mm % Used for: Main content with margin annotations \pagelayout{wide} % Full page width with symmetric margins % Used for: Title pages, TOC, bibliography \pagelayout{fullwidth} % Complete page coverage % Used for: Special pages, large figures ``` -------------------------------- ### KaoBook Document Class and Essential Packages Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Defines the document class as 'kaobook' with specified options and lists essential packages for KaoBook, including kaobiblio for bibliography, kaotheorems for mathematical environments, and kaorefs for cross-referencing. ```latex % Document class \documentclass[options]{kaobook} % Essential packages \usepackage{kaobiblio} % Bibliography with margin citations \usepackage{kaotheorems} % Mathematical environments \usepackage{kaorefs} % Cross-referencing system ``` -------------------------------- ### Troubleshoot Margin Content Positioning Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands to fix margin content positioning issues, typically resolved by performing additional compilation passes with pdflatex. ```latex % Usually fixed with additional LaTeX passes pdflatex main.tex pdflatex main.tex ``` -------------------------------- ### LaTeX Nomenclature Commands in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates defining and printing nomenclature lists for symbols and abbreviations using `\nomenclature` and `\printnomenclature` to maintain a list of symbols used in the document. ```latex % Define nomenclature entries \nomenclature{$c$}{Speed of light} \nomenclature{$h$}{Planck constant} % Print nomenclature \printnomenclature ``` -------------------------------- ### KaoBook File Structure Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates the typical directory and file organization for a project using the KaoBook LaTeX class. This structure helps manage document components, images, and bibliography files effectively. ```text project/ ├── kaobook.cls # Main book class ├── kaohandt.cls # Report/handout class (if available) ├── kao.sty # Core definitions ├── kaobiblio.sty # Bibliography handling ├── kaotheorems.sty # Mathematical environments ├── kaorefs.sty # Cross-referencing commands ├── main.tex # Your document ├── main.bib # Bibliography database ├── glossary.tex # Glossary definitions ├── chapters/ # Chapter files │ ├── chapter1.tex │ ├── chapter2.tex │ └── ... └── images/ # Image directory ├── figure1.jpg └── ... ``` -------------------------------- ### Set Typography Settings Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Adjusts line spacing, paragraph spacing, and paragraph indentation for improved readability. It also enables microtype package for typographical refinements. ```latex % Line spacing \linespread{1.07} % Slightly increased for Palatino % Paragraph settings \setlength{\parskip}{0.5\baselineskip} % Space between paragraphs \setlength{\parindent}{0pt} % No paragraph indentation % Microtype improvements \RequirePackage{microtype} ``` -------------------------------- ### LaTeX: Margin Tables Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates embedding tables in the margin using the `margintable` environment. It supports standard LaTeX table structures, including `tabular`, `caption`, and `labtab`. ```latex \begin{margintable}[offset] \centering \begin{tabular}{cc} A & B \\ C & D \\ \end{tabular} \caption{Table caption} \labtab{margin-table} \end{margintable} ``` -------------------------------- ### KaoBook Document Structure Commands Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Illustrates the LaTeX commands used to define the structural parts of a document in KaoBook, such as front matter, main matter, appendices, and back matter. ```latex \frontmatter % Roman page numbers, plain style % Title page, preface, TOC, LOF, LOT \mainmatter % Arabic page numbers, fancy headers, margin layout % Chapters, sections, main content \appendix % Appendices (still main matter) % Appendix chapters \backmatter % Plain style, wide layout % Bibliography, index, glossary ``` -------------------------------- ### Add Chapter Preambles Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Allows adding custom content before the chapter title, such as a table of contents in the margin or an image. It uses the \setchapterpreamble command with optional arguments for placement. ```latex \setchapterpreamble[u]{\margintoc} % Margin TOC \setchapterpreamble[o]{% % Custom content \vspace*{-20mm}% \includegraphics[width=\paperwidth]{image.jpg}% } \chapter{Chapter Title} ``` -------------------------------- ### Basic LaTeX Compilation Sequence Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Outlines the fundamental sequence of commands required to compile a LaTeX document that includes bibliography processing. It involves multiple passes of pdflatex to resolve cross-references and citations correctly. ```bash # Basic sequence pdflatex main.tex # First pass biber main # Process bibliography pdflatex main.tex # Second pass pdflatex main.tex # Third pass (fix references) ``` -------------------------------- ### PowerShell Script for LaTeX Compilation Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md A Windows PowerShell script to automate the complete LaTeX compilation workflow. It manages dependencies like nomenclature, index, bibliography, and glossary generation, ensuring a robust build process. ```powershell # File: compile.ps1 Write-Host "Compiling KaoBook document..." -ForegroundColor Green # First LaTeX pass Write-Host "First LaTeX pass..." -ForegroundColor Yellow pdflatex -interaction=nonstopmode main # Process nomenclature if (Test-Path main.nlo) { Write-Host "Processing nomenclature..." -ForegroundColor Yellow makeindex main.nlo -s nomencl.ist -o main.nls } # Process index if (Test-Path main.idx) { Write-Host "Processing index..." -ForegroundColor Yellow makeindex main } # Process bibliography Write-Host "Processing bibliography..." -ForegroundColor Yellow biber main # Second LaTeX pass Write-Host "Second LaTeX pass..." -ForegroundColor Yellow pdflatex -interaction=nonstopmode main # Process glossary if (Test-Path main.glo) { Write-Host "Processing glossary..." -ForegroundColor Yellow makeglossaries main } # Final LaTeX pass Write-Host "Final LaTeX pass..." -ForegroundColor Yellow pdflatex -interaction=nonstopmode main Write-Host "Compilation complete!" -ForegroundColor Green ``` -------------------------------- ### Set Chapter Styles Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates how to set different chapter styles in KOMA-Script. Options include 'kao', 'bar', 'lines', and 'plain', each offering distinct visual appearances for chapter headings. ```latex \setchapterstyle{kao} ``` ```latex \setchapterstyle{bar} ``` ```latex \setchapterstyle{lines} ``` ```latex \setchapterstyle{plain} ``` -------------------------------- ### KaoBook Scaling System for Paper Sizes Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Details the LaTeX code for defining and setting scaling factors used by KaoBook to adapt layouts for different paper sizes, using A4 as the base. ```latex % Scaling factors \newlength{\hscale} % Horizontal scale \newlength{\vscale} % Vertical scale % A4 paper (base) \setlength{\hscale}{1mm} \setlength{\vscale}{1mm} % A5 paper \setlength{\hscale}{0.704mm} \setlength{\vscale}{0.704mm} ``` -------------------------------- ### LaTeX: Standard Figures Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Shows the standard LaTeX way to include figures in the main text body. Uses the `figure` environment with `includegraphics`, `caption`, and `labfig` for placement and labeling. ```latex \begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{image.jpg} \caption{Standard figure caption} \labfig{standard-figure} \end{figure} ``` -------------------------------- ### KaoBook Cross-Referencing: Smart Reference Behavior Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates smart referencing capabilities in kaorefs.sty, including varioref integration for context-aware page references and cleveref integration for automatic reference type determination. ```latex % Varioref Integration \vrefch{intro} % Output depends on distance: % - Same page: "Chapter 1" % - Next page: "Chapter 1 on the following page" % - Specific page: "Chapter 1 on page 15" % Cleveref Integration \cref{eq:main-equation} % Equation (1.1) \Cref{fig:plot} % Figure 1.2 (capitalized) \cref{thm:main,prop:help} % Theorem 2.1 and Proposition 2.2 ``` -------------------------------- ### LaTeX Bibliography and Citation Commands in KaoBook Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Covers setting up bibliography with `biblatex` and using various citation commands, including standard (`\cite`, `\textcite`, `\parencite`) and KaoBook-specific margin citations (`\sidecite`, `\sidetextcite`, `\sideparencite`). ```latex % Bibliography setup \addbibresource{file.bib} \printbibliography[options] % Standard citations \cite[prenote][postnote]{key} \textcite[prenote][postnote]{key} \parencite[prenote][postnote]{key} % Margin citations (KaoBook special) \sidecite[prenote][postnote]{key} \sidetextcite[prenote][postnote]{key} \sideparencite[prenote][postnote]{key} % Multiple citations \cite{key1,key2,key3} \sidecite{key1,key2,key3} ``` -------------------------------- ### Define Custom Reference Commands Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md This snippet illustrates how to create custom commands for referencing chapters, including the chapter number, name, and a hyperlink. It uses \hyperref and \nameref to create interactive references. ```latex % Define custom reference command \newcommand{\myrefch}[1]{ \hyperref[ch:#1]{Chapter~\ref{ch:#1}: ``\nameref{ch:#1}''}% } % Usage \myrefch{introduction} % Example output: Chapter 1: "Introduction" ``` -------------------------------- ### Create Basic Sidenotes Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Adds numbered notes to the margin using the \sidenote command. It supports custom marks and vertical offsets for precise placement relative to the main text. ```latex This is main text\sidenote{This is a sidenote}. % With custom mark Text\sidenote[†]{Custom symbol sidenote}. % With vertical offset Text\sidenote[][2mm]{Sidenote moved down 2mm}. Text\sidenote[][*-2]{Sidenote moved up 2 baselineskips}. ``` -------------------------------- ### Troubleshoot Bibliography Issues Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands and checks for bibliography problems. Includes verifying biber version compatibility, clearing the cache, ensuring the correct backend is used with biblatex, and checking citation linking with hyperref. ```latex % Check biber version compatibility % In terminal: biber --version % Clear biber cache if needed % In terminal: % biber --cache % rm -rf [cache directory] % Ensure correct bibliography backend \usepackage[backend=biber]{biblatex} % NOT: \usepackage[backend=bibtex]{biblatex} % Ensure hyperref is loaded (usually automatic) \usepackage{hyperref} % Check citation key exists in .bib file % Compile sequence: pdflatex → biber → pdflatex → pdflatex % Ensure kaobiblio is loaded \usepackage{kaobiblio} % Use correct command syntax \sidecite{key} % Correct \cite{key} % Wrong for margin citations ``` -------------------------------- ### KaoBook Document Class Options Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Demonstrates the primary options for configuring the KaoBook LaTeX document class, including paper size, font size, and layout preferences for two-sided documents. ```latex \documentclass[ % Paper options a4paper, % Default paper size a5paper, % Smaller format letterpaper, % US letter size % Font options fontsize=9pt, % Small font (9-12pt supported) fontsize=10pt, % Default font size fontsize=11pt, % Large font % Layout options twoside=true, % Two-sided (book-style) oneside, % One-sided layout open=right, % Chapters start on right pages open=any, % Chapters can start on any page % TOC options chapterentrydots=true, % Dots in chapter TOC entries numbers=noenddot, % No dots after chapter numbers % Section numbering secnumdepth=2, % Number down to subsections ]{kaobook} ``` -------------------------------- ### KaoBook Custom Boxes Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Shows how to create custom colored boxes with optional titles (`kaobox`) and numbered comment boxes (`kaocounter`) using the KaoBook LaTeX class for distinct content highlighting. ```latex % Basic colored box \begin{kaobox}[frametitle=Title] ... \end{kaobox} % Numbered comment box \begin{kaocounter} ... \end{kaocounter} ``` -------------------------------- ### Troubleshoot Biber Bibliography Compilation Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Bash commands to diagnose and resolve issues with Biber bibliography compilation. Includes checking Biber logs, clearing the cache, and removing cache files. ```bash # Check biber log biber --debug main # Common solution: clear cache biber --cache rm -rf `biber --cache` ``` -------------------------------- ### Bash Script for LaTeX Compilation Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md A shell script designed for Unix-like systems (macOS, Linux) to automate the full LaTeX compilation process. It handles multiple passes of pdflatex, nomenclature, index, bibliography, and glossary generation. ```bash #!/bin/bash # File: compile.sh echo "Compiling KaoBook document..." # First LaTeX pass echo "First LaTeX pass..." pdflatex -interaction=nonstopmode main # Process nomenclature if [ -f main.nlo ]; then echo "Processing nomenclature..." makeindex main.nlo -s nomencl.ist -o main.nls fi # Process index if [ -f main.idx ]; then echo "Processing index..." makeindex main fi # Process bibliography echo "Processing bibliography..." biber main # Second LaTeX pass echo "Second LaTeX pass..." pdflatex -interaction=nonstopmode main # Process glossary if [ -f main.glo ]; then echo "Processing glossary..." makeglossaries main fi # Final LaTeX pass echo "Final LaTeX pass..." pdflatex -interaction=nonstopmode main echo "Compilation complete!" ``` -------------------------------- ### Use Latin Phrases and Abbreviations Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md Defines commands for common Latin phrases and abbreviations used in academic writing, such as 'i.e.', 'e.g.', 'et al.', 'etc.', 'vs', and 'ad hoc'. ```latex \ie % i.e. (that is) \eg % e.g. (for example) \etal % et al. (and others) \etc % etc. (and so forth) \vs % vs (versus) \adhoc % ad hoc ``` -------------------------------- ### Troubleshoot Layout and Positioning Problems Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md LaTeX commands to adjust layout and positioning, including margin spacing, using FloatBarrier, and adding manual spacing with \marginnote. Also covers chapter style resets and header recalculations. ```latex % Solution 1: Adjust margin content spacing \setlength{\kaomarginskipabove}{5mm} \setlength{\kaomarginskipbelow}{5mm} % Solution 2: Use FloatBarrier before problematic content \FloatBarrier \begin{marginfigure} % content \end{marginfigure} % Solution 3: Add manual spacing \marginnote[10mm]{Content with extra spacing} % Reset to plain style if issues persist \setchapterstyle{plain} % Recalculate header dimensions after layout changes \recalchead ``` -------------------------------- ### LaTeX: Margin Figures (Specific Offset) Source: https://github.com/anastassaoui/kaobook1/blob/main/KAOBOOK_COMPREHENSIVE_DOCUMENTATION.md An example of including a small figure in the margin with a specific negative offset. This allows precise vertical positioning of margin figures. ```latex \begin{marginfigure}[-2cm] \includegraphics[width=\linewidth]{small-image.jpg} \caption{Small margin figure} \labfig{margin-fig} \end{marginfigure} ```