LaTeX kaobook template

By | 2022년 06월 29일

LaTeX 을 사용하여 다양한 형식의 문서를 작성할 수 있는데, 책 모양의 문서를 작성하는 것에도 사용할 수 있다. 여러가지 책 형태 중 Tufte 양식에 기반을 둔 Kao 책양식에서 사용되는 명령어를 간단히 정리한다. Kao 양식대한 자세한 설명은 github kaobook site 에서 볼수 있다.

1. Commends

사용되는 명령어를 간단히 정리해 보자면

1.1 Notes

Sidenotes

\sidenote[mark][offset]{Text}
\sidenote[][*-1]{Text of the sidenote.}

Marginotes

\marginnote[offset]{Text}
\marginnote[-12pt]{Text} 
\marginnote[*-3]{Text}

Footnotes

\footnote{  }

Marginlisting

\begin{marginlisting}[-0.5cm]
    \caption{My caption}
    \vspace{0.2cm} 
    \begin{lstlisting}[language=Python,style=kaolstplain] ... code ...
    \end{lstlisting}
\end{marginlisting}

Margin figure and tables

\begin{marginfigure}
   \includegraphics{figName}
   \caption[The caption]{The caption.}     
   \labfig{marginmonalisa}
\end{marginfigure}

\begin{marginfigure}[offset]
   \includegraphics{figName}
   \caption[The caption]{The caption.}   
   \labfig{marginmonalisa}
\end{marginfigure}

Wide figure and tables

For wide table,

\begin{table*}[h!]
    \caption{  }
    \begin{tabular}{p{1.0cm} p{1.0cm} p{1.0cm} p{1.0cm} p{1.0cm} p {1.0cm} p{1.5cm}}
     .
     .
     .

    \end{tabular}
\end{table*}

For wide figure,

\begin{figure*}[h!]
   \includegraphics{figName}
   \caption[The caption]{The caption.}     
   \labfig{marginmonalisa}
\end{figure*}

1.2 Chapter and section

Chapter

Margintoc

\margintoc[offset]
\setchapterpreamble[u]{\margintoc}

The margintoc includes sections and subsections

To show only sections,

\setcounter{margintocdepth}{\sectiontocdepth}

in the preamble.

For chapter

\chapter{Chapter Title}

Section

\section[alternative-title-for-toc]{title-as-written-in-text}[alternative-title-for-margintoc]

2. tex file structure

2.1 Documentclass options

\documentclass[
    a4papers, % Page size
    fontsize=10pt, % Base font size
    twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside)
    %open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages
    %chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents
    secnumdepth=1, % How deep to number headings. Defaults to 1 (sections)
    numbers=noenddot, % Comment to output dots after chapter numbers

]{kaobook}

2.2 Packages

%------------------------------------------------
%   PACKAGES 
%------------------------------------------------

% Load packages for testing
\usepackage{blindtext} % Print text without any meaning for testing purposes
%\usepackage{showframe} % Uncomment to show boxes around the text area, margin, header and footer
%\usepackage{showlabels} % Uncomment to output the content of \label commands to the document where they are used

% Load the bibliography package
\usepackage{kaobiblio}
\addbibresource{minimal.bib} % Bibliography file

% Load mathematical packages for theorems and related environments
\usepackage{kaotheorems}

% Load the package for hyperreferences
\usepackage{kaorefs}

\graphicspath{{documentations/images/}{images/}} % Paths in which to look for images

\makeindex[columns=3, title=Alphabetical Index, intoc] % Make LaTeX produce the files required to compile the index

\makeglossaries % Make LaTeX produce the files required to compile the glossary
\input{glossary.tex} % Include the glossary definitions

\makenomenclature % Make LaTeX produce the files required to compile the nomenclature

% Reset sidenote counter at chapters
%\counterwithin*{sidenote}{chapter}

3. Begin document

\begin{document}

4. Book information (Title)

%------------------------------------------------
%   BOOK INFORMATION
%------------------------------------------------

\titlehead{The Book Heading}
\subject{Short Explanation}
%
\title[The {\normalfont\texttt{KaoBook}} Title]{the title \\ of the {\normalfont\texttt{kaobook}} }
\subtitle{Customise this page}
%
\author[author name]{author name\thanks{affiliation}}
%
\date{\today}
%
\publishers{My Publisher}

5. Frontmatter

%------------------------------------------------
\frontmatter % Denotes the start of the pre-document content, uses roman numerals
%------------------------------------------------
%   OPENING PAGE
%------------------------------------------------

%\makeatletter
%\extratitle{
%   % In the title page, the title is vspaced by 9.5\baselineskip
%   \vspace*{9\baselineskip}
%   \vspace*{\parskip}
%   \begin{center}
%       % In the title page, \huge is set after the komafont for title
%       \usekomafont{title}\huge\@title
%   \end{center}
%}
%\makeatother

6. Copyright

%------------------------------------------------
%   COPYRIGHT PAGE
%------------------------------------------------

\makeatletter
\uppertitleback{\@titlehead} % Header

\lowertitleback{
    \textbf{Disclaimer}\\
    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.

    \medskip

    \textbf{No copyright}\\
    \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.

    To view a copy of the CC0 code, visit: \\\url{http://creativecommons.org/publicdomain/zero/1.0/}

    \medskip

    \textbf{Colophon} \\
    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.

    The source code of this book is available at:\\\url{https://github.com/fmarotta/kaobook}

    (You are welcome to contribute!)

    \medskip

    \textbf{Publisher} \\
    First printed in May 2019 by \@publishers

}
\makeatother

7. Dedication

%------------------------------------------------
%   DEDICATION
%------------------------------------------------

\dedication{
    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.\\
    \flushright -- D'Arcy Wentworth Thompson
}

7. Maketitle

%------------------------------------------------
%   OUTPUT TITLE PAGE AND PREVIOUS
%------------------------------------------------

% Note that \maketitle outputs the pages before here

\maketitle

8. Preface

%------------------------------------------------
%   PREFACE
%------------------------------------------------

\input{chapters/preface.tex}
\index{preface}

9. Table of contents

%------------------------------------------------
%   TABLE OF CONTENTS & LIST OF FIGURES/TABLES
%------------------------------------------------

\begingroup % Local scope for the following commands

% Define the style for the TOC, LOF, and LOT
%\setstretch{1} % Uncomment to modify line spacing in the ToC
%\hypersetup{linkcolor=blue} % Uncomment to set the colour of links in the ToC
\setlength{\textheight}{230\hscale} % Manually adjust the height of the ToC pages

% Turn on compatibility mode for the etoc package
\etocstandarddisplaystyle % "toc display" as if etoc was not loaded
\etocstandardlines % "toc lines as if etoc was not loaded

\tableofcontents % Output the table of contents
%
\listoffigures % Output the list of figures

% Comment both of the following lines to have the LOF and the LOT on 
% different pages
\let\cleardoublepage\bigskip
\let\clearpage\bigskip

\listoftables % Output the list of tables
%
\listoflstlistings % Output the list of listings
%
\endgroup

10. Main body

%------------------------------------------------
%   MAIN BODY
%------------------------------------------------

\mainmatter % Denotes the start of the main document content, resets page numbering and uses arabic numbers
\setchapterstyle{kao} % Choose the default chapter heading style

\input{chapters/introduction.tex}
% or \chapter{Introduction}
% texts ....
%

\pagelayout{wide} % No margins
\addpart{Class Options, Commands and Environments}
\pagelayout{margin} % Restore margins

\input{chapters/options.tex}
\input{chapters/textnotes.tex}
\input{chapters/figsntabs.tex}
\input{chapters/references.tex}
% .
% .
% .

\appendix % From here onwards, chapters are numbered with letters

\pagelayout{wide} % No margins
\addpart{Appendix}
\pagelayout{margin} % Restore margins

\input{chapters/appendix.tex}

\pagelayout{wide}
\setchapterstyle{kao}
\chapter{Test}
\blindtext

%------------------------------------------------

11. Back matter

\backmatter % Denotes the end of the main document content
\setchapterstyle{plain} % Output plain chapters from this point onwards

12. Bibliography

%------------------------------------------------
%   BIBLIOGRAPHY
%------------------------------------------------

% The bibliography needs to be compiled with biber using your LaTeX editor, or on the command line with 'biber main' 

\defbibnote{bibnote}{Here are the references in citation order.\par\bigskip} % Prepend this text to the bibliography
\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

13. Nomenclature

%------------------------------------------------
%   NOMENCLATURE
%------------------------------------------------

% The nomenclature needs to be compiled on the command line with 'makeindex main.nlo -s nomencl.ist -o main.nls' from the template directory

\nomenclature{$c$}{Speed of light in a vacuum inertial frame}
\nomenclature{$h$}{Planck constant}

\renewcommand{\nomname}{Notation} % Rename the default 'Nomenclature'
\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

\printnomenclature % Output the nomenclature

14. Glossary

%------------------------------------------------
%   GLOSSARY
%------------------------------------------------

% The glossary needs to be compiled on the command line with 'makeglossaries main' from the template directory

\setglossarystyle{listgroup} % Set the style of the glossary (see https://en.wikibooks.org/wiki/LaTeX/Glossary for a reference)
\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

15. Glossary

%------------------------------------------------
%   GLOSSARY
%------------------------------------------------

% The glossary needs to be compiled on the command line with 'makeglossaries main' from the template directory

\setglossarystyle{listgroup} % Set the style of the glossary (see https://en.wikibooks.org/wiki/LaTeX/Glossary for a reference)
\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

16. Index

%------------------------------------------------
%   INDEX
%------------------------------------------------

% The index needs to be compiled on the command line with 'makeindex main' from the template directory

\printindex % Output the index

17. Backcover

%------------------------------------------------
%   BACK COVER
%------------------------------------------------

% If you have a PDF/image file that you want to use as a back cover, uncomment the following lines

%\clearpage
%\thispagestyle{empty}
%\null%
%\clearpage
%\includepdf{cover-back.pdf}

18. End of document

%------------------------------------------------
\end{document}
%------------------------------------------------

답글 남기기