phd-thesis/setup.org

12 KiB

Setup file

Config

Units

\usepackage[binary-units=true]{siunitx}

\sisetup{%
  detect-all           = true,
  detect-family        = true,
  detect-mode          = true,
  detect-shape         = true,
  detect-weight        = true,
  detect-inline-weight = math,
}

\DeclareSIUnit\px{px}
\DeclareSIUnit\rms{rms}

Mathematics

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{dsfont}

Fix the spacing of \left and \right. Use these with the proper bracket in order to ensure that they scale automatically.

\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}

Glossary

\usepackage[      %
    acronym,      % Separate acronyms and glossary
    toc,          % appear in ToC
    automake,     % auto-use the makeglossaries command (requires shell-escape)
    nonumberlist, % don't back reference pages
    nogroupskip,  % don't group by letter
    nopostdot     % don't add a dot at the end of each element
]{glossaries}

\usepackage[stylemods=longextra]{glossaries-extra}

\setabbreviationstyle[acronym]{long-short}
\setglossarystyle{long-name-desc}

Config Extra

Babel

\usepackage[french,english]{babel}

Figures

\usepackage{graphicx}
\graphicspath{{figs/}}

Captions

\usepackage{caption}
\usepackage{subcaption}
\captionsetup{subrefformat=parens}

\captionsetup[figure]{labelfont=bf}
\captionsetup[subfigure]{labelfont=bf}
\captionsetup[listing]{labelfont=bf}
\captionsetup[table]{labelfont=bf}

Lists

Do not modify itemize/enumerate environments by default

\usepackage[olditem,oldenum]{paralist}

Spacing

\RequirePackage{setspace}
\onehalfspacing

List of figures

\usepackage{tocloft}
\setlength{\cftfignumwidth}{2.5em}  % Adjust this value as needed

Tables

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}

I reduce the size of tables so that longer tables can still fit into an A4 (reduce font and make sans serif).

\usepackage{floatrow}
\floatsetup[table]{font={footnotesize,sf},capposition=top}

Geometry

Penalties

\clubpenalty         = 10000
\widowpenalty        = 10000
\displaywidowpenalty = 10000

Floating images configuration

By default, if a figure consumes 60% of the page it will get its own float-page. To change that we have to adjust the value of the floatpagefraction derivative.

\renewcommand{\floatpagefraction}{.8}%

See more information here.

Etoolbox package

\usepackage{etoolbox}

\pretocmd{\section}{\clearpage}{}{}

Use pdf instead of png

\makeatletter
\preto\Gin@extensions{png,}
\DeclareGraphicsRule{.png}{pdf}{.pdf}{\noexpand\Gin@base.pdf}
\preto\Gin@extensions{gif,}
\DeclareGraphicsRule{.gif}{png}{.png}{\noexpand\Gin@base.png}
\makeatother

Bibliography

\usepackage{xpatch} % Recommanded for biblatex
\usepackage[        % use biblatex for bibliography
    backend=biber,  % use biber backend (bibtex replacement) or bibtex
    style=ieee,     % bib style
    hyperref=true,  % activate hyperref support
    backref=true,   % activate backrefs
    isbn=false,     % don't show isbn tags
    url=false,      % don't show url tags
    doi=false,      % don't show doi tags
    urldate=long,   % display type for dates
    maxnames=3,     %
    minnames=1,     %
    maxbibnames=5,  %
    minbibnames=3,  %
    maxcitenames=2, %
    mincitenames=1  %
    ]{biblatex}
\defbibenvironment{mypubs}
 {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

Remove ISSN, DOI and URL to shorten the bibliography.

\AtEveryBibitem{%
  \clearfield{urlyear}
  \clearfield{urlmonth}
  \clearfield{note}
 \clearfield{issn} % Remove issn
 \clearfield{doi} % Remove doi
\ifentrytype{online}{}{% Remove url except for @online
  \clearfield{url}
}
}

And increase the spacing between the entries, as per default they are too small.

\setlength\bibitemsep{1.1\itemsep}

Also reduce the font-size

\renewcommand*{\bibfont}{\footnotesize}

Table of Contents for each chapter

Note that this is marked as deprecated for koma-script.

\usepackage{minitoc}
% Change section font
\renewcommand{\mtcSfont}{\small}
% Change indentation
\setlength{\mtcindent}{0pt}
% \usepackage[nottoc]{tocbibind}

TODO Fonts

\ifxetexorluatex
  % \usepackage{unicode-math} % It seems I don't need that as I don't want to use unicode char
  \usepackage{fontspec}
  \setmainfont{EB Garamond}
  % \setmathfont{Garamond Math}

  % % Load some missing symbols from another font.
  % \setmathfont{STIX Two Math}[%
  % range = {
  % \sharp,
  % \natural,
  % \flat,
  % \clubsuit,
  % \spadesuit,
  % \checkmark
  % }
  %   ]
  %   \setmonofont[Scale=MatchLowercase]{Source Code Pro}
\else
  % \usepackage[lf]{ebgaramond} % https://tug.org/FontCatalogue/quattrocento/
  \usepackage[oldstyle,scale=0.7]{sourcecodepro} % https://tug.org/FontCatalogue/sourcecodepro/
  \singlespacing
\fi

Colors

\usepackage[usenames,dvipsnames]{xcolor}

\definecolor{my-blue}{HTML}{6b7adb}
\definecolor{my-pale-blue}{HTML}{e6e9f9}
\definecolor{my-red}{HTML}{db6b6b}
\definecolor{my-pale-red}{HTML}{f9e6e6}
\definecolor{my-green}{HTML}{6bdbb6}
\definecolor{my-pale-green}{HTML}{e6f9f3}
\definecolor{my-yellow}{HTML}{dbd26b}
\definecolor{my-pale-yellow}{HTML}{f9f7e6}
\definecolor{my-orange}{HTML}{dba76b}
\definecolor{my-pale-orange}{HTML}{f9f0e6}
\definecolor{my-grey}{HTML}{a3a3a3}
\definecolor{my-pale-grey}{HTML}{f0f0f0}
\definecolor{my-turq}{HTML}{6bc7db}
\definecolor{my-pale-turq}{HTML}{e6f6f9}

CS Quotes

The csquotes package offers context sensitive quotation facilities, improving the typesetting of inline quotes.

\usepackage{csquotes}

To enclose quote environments with quotes from csquotes, see the following TeX SE thread.

\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip1em
    \hbox{}\nobreak\hfill #1%
    \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newsavebox\mybox
\newenvironment{aquote}[1]
{\savebox\mybox{#1}\begin{quote}\openautoquote\hspace*{-.7ex}}
  {\unskip\closeautoquote\vspace*{1mm}\signed{\usebox\mybox}\end{quote}}

And then use quotes as:

# The options derivative adds text after the environment. We use it to add the author.
#+ATTR_LATEX: :options {\cite{Frahm1994}}
#+begin_aquote
/Current (fMRI) applications often rely on "effects" or "statistically significant differences", rather than on a proper analysis of the relationship between neuronal activity, haemodynamic consequences, and MRI physics./
#+end_aquote

Note that org-ref links won't work here because the attr latex will be pasted as-is in the .tex file.

Setspace for controlling line spacing

\usepackage{setspace}
\setstretch{1.25}

Parskip

Fine tuning of spacing between paragraphs. See thread here.

\setparsizes{0em}{0.1\baselineskip plus .1\baselineskip}{1em plus 1fil}

Possible Equation improvements

Make the equation numbers follow the chapter, not the whole thesis.

\numberwithin{equation}{chapter}

Minted

The minted package is used for highlighting source code.

\usepackage{listings}
\usepackage{minted}
\setminted{autogobble=true,fontsize=\small,baselinestretch=0.8}
\setminted[python]{python3=true,tabsize=4}
\usemintedstyle{trac}
\lstset{abovecaptionskip=0}
\renewcommand{\listingscaption}{Code Snippet}

And reduce the distance between a minted listing and its caption.

\AtEndEnvironment{listing}{\vspace{-16pt}}
\let\OldTexttt\texttt
\renewcommand{\texttt}[1]{{\ttfamily\hl{\mbox{\,#1\,}}}}

Scrhack

This package fixes some incompatibility errors between KOMAScript and other packages (namely minted). It has to be loaded at the end.

\usepackage{scrhack}

Background cover page

Add the cover image as background to the first page. Only do so when outputting a final version, because it significantly slows down the compilation times.

\usepackage[pages=some]{background}
\backgroundsetup{
  scale=1,
  color=black,
  opacity=0.9,
  angle=0,
  contents={%
    \includegraphics[width=\paperwidth,height=\paperheight]{/Users/user/Desktop/TectonicPlatesXVI.png}
  }%
}

Various

\usepackage{float}
\usepackage{enumitem}

% highlight
\usepackage{soul}
\sethlcolor{my-pale-grey}

Headers

% \usepackage[headsepline]{scrlayer-scrpage}
% \pagestyle{scrheadings}

Config to have the chapter name until there is a section, and then displays the sections (from the doc)

\usepackage[autooneside=false,headsepline]{scrlayer-scrpage}
% \pagestyle{scrheadings}
% \automark[section]{chapter}
% Clear default header styles
\clearpairofpagestyles
\automark[section]{chapter}

% Set the header content
\ihead{\headmark}  % Chapter (or section on even pages) aligned to the left
\ohead{\pagemark}  % Page number aligned to the right

% Enable the page style
\pagestyle{scrheadings}

\setkomafont{headsepline}{\color{black}}  % Change color if desired
\ModifyLayer[addvoffset=\dp\strutbox]{headsepline}  % Fine-tune position

Kind of working solution:

% \automark{section}
% \renewhead*{headings}{
%   \ifstr{\headmark}{}{}{%
%     \headmark\hfill
%   }
% }

Section/Figure format

\renewcommand{\partformat}{\huge\partname~\thepart\autodot}
\renewcommand{\raggedpart}{\flushleft}

\setkomafont{part}{\normalfont\huge\scshape}

\setkomafont{sectioning}{\normalfont\scshape}
\setkomafont{descriptionlabel}{\normalfont\bfseries}

\setkomafont{caption}{\small}
\setkomafont{captionlabel}{\usekomafont{caption}}

\setcounter{secnumdepth}{\subsubsectionnumdepth}

Improve chapter font colors and font size. The following commands make chapter numbers BrickRed.

\makeatletter
\renewcommand*{\chapterformat}{  \mbox{\chapappifchapterprefix{\nobreakspace}{\color{BrickRed}\fontsize{40}{45}\selectfont\thechapter}\autodot\enskip}}
% Section with color
% \renewcommand\@seccntformat[1]{\color{BrickRed} {\csname the#1\endcsname}\hspace{0.3em}}
\renewcommand\@seccntformat[1]{{\csname the#1\endcsname}\hspace{0.3em}}
\makeatother

Hyperref and Bookmarks

\usepackage[            %
    colorlinks=true,    %
    citecolor=BrickRed, %
    linkcolor=BrickRed, %
    urlcolor=BrickRed,  %
    unicode             %
    ]{hyperref}

\usepackage{hypcap}

The bookmark package implements a new bookmark (outline) organisation for package hyperref. This lets us change the "tree-navigation" associated with the generated pdf and constrain the menu only to H:2.

\usepackage{bookmark}

\bookmarksetup{depth=2}

Index and glossaries

\makeindex
\makeglossaries