2021-05-19 19:05:52 +02:00
#+TITLE : Setup file
#+PROPERTY : header-args:latex :tangle config.tex
2025-02-04 18:11:58 +01:00
* Config
:PROPERTIES:
:header-args:latex: :tangle config.tex
:END:
** Units
2021-05-19 19:05:52 +02:00
#+begin_src latex
2025-02-04 18:11:58 +01:00
\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}
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** Mathematics
2021-05-19 19:05:52 +02:00
#+begin_src latex
2025-02-04 18:11:58 +01:00
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{dsfont}
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
Fix the spacing of =\left= and =\right= .
Use these with the proper bracket in order to ensure that they scale automatically.
2021-05-19 19:05:52 +02:00
#+begin_src latex
2025-02-04 18:11:58 +01:00
\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** Glossary
2021-05-19 19:05:52 +02:00
#+begin_src latex
\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}
#+end_src
2025-02-04 18:11:58 +01:00
* Config Extra
:PROPERTIES:
:header-args:latex: :tangle config_extra.tex
:END:
** Babel
#+begin_src latex
\usepackage[french,english]{babel}
#+end_src
** Figures
#+begin_src latex
\usepackage{graphicx}
\graphicspath{{figs/}}
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** Captions
#+begin_src latex
\usepackage{caption}
\usepackage{subcaption}
\captionsetup{subrefformat=parens}
\captionsetup[figure]{labelfont=bf}
\captionsetup[subfigure]{labelfont=bf}
\captionsetup[listing]{labelfont=bf}
\captionsetup[table]{labelfont=bf}
#+end_src
** Lists
2021-05-19 19:05:52 +02:00
Do not modify itemize/enumerate environments by default
#+begin_src latex
\usepackage[olditem,oldenum]{paralist}
#+end_src
2025-02-04 18:11:58 +01:00
** Spacing
2021-05-19 19:05:52 +02:00
#+begin_src latex
\RequirePackage{setspace}
\onehalfspacing
#+end_src
2025-02-04 18:11:58 +01:00
** Tables
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage{booktabs}
\usepackage{multirow}
2021-12-09 15:56:34 +01:00
\usepackage{tabularx}
2021-05-19 19:05:52 +02:00
#+end_src
2021-05-19 19:21:46 +02:00
I reduce the size of tables so that longer tables can still fit into an A4 (reduce font and make sans serif).
#+begin_src latex
\usepackage{floatrow}
\floatsetup[table]{font={footnotesize,sf},capposition=top}
#+end_src
2025-02-04 18:11:58 +01:00
** Geometry
2021-05-19 19:05:52 +02:00
# \usepackage[paperheight=24.41cm,paperwidth=17.21cm,bottom=3cm,left=1.4cm,right=2cm,heightrounded]{geometry}
2025-02-04 18:11:58 +01:00
** Penalties
2021-05-19 19:05:52 +02:00
#+begin_src latex
\clubpenalty = 10000
\widowpenalty = 10000
\displaywidowpenalty = 10000
#+end_src
2025-02-04 18:11:58 +01:00
** Headers
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
#+end_src
2025-02-04 18:11:58 +01:00
** Section/Figure format
2021-05-19 19:05:52 +02:00
#+begin_src latex
\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}}
2021-12-09 17:22:40 +01:00
\setcounter{secnumdepth}{\subsubsectionnumdepth}
2021-05-19 19:05:52 +02:00
#+end_src
Improve chapter font colors and font size.
The following commands make chapter numbers BrickRed.
#+begin_src latex
\makeatletter
\renewcommand*{\chapterformat}{ \mbox{\chapappifchapterprefix{\nobreakspace}{\color{BrickRed}\fontsize{40}{45}\selectfont\thechapter}\autodot\enskip}}
2021-12-09 17:22:40 +01:00
% 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}}
2021-05-19 19:05:52 +02:00
\makeatother
#+end_src
2025-02-04 18:11:58 +01:00
** Floating images configuration
2021-05-19 19:05:52 +02:00
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.
#+begin_src latex
\renewcommand{\floatpagefraction}{.8}%
#+end_src
See more information [[https://tex.stackexchange.com/questions/68516/avoid-that-figure-gets-its-own-page ][here ]].
2025-02-04 18:11:58 +01:00
** Etoolbox package
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage{etoolbox}
2025-02-04 18:11:58 +01:00
\pretocmd{\section}{\clearpage}{}{}
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** Hyperref and Bookmarks
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage[ %
colorlinks=true, %
citecolor=BrickRed, %
linkcolor=BrickRed, %
urlcolor=BrickRed, %
unicode %
]{hyperref}
2025-02-04 18:11:58 +01:00
\usepackage{hypcap}
2021-05-19 19:05:52 +02:00
#+end_src
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.
#+begin_src latex
\usepackage{bookmark}
\bookmarksetup{depth=2}
#+end_src
2025-02-04 18:11:58 +01:00
** Use pdf instead of png
#+begin_src latex
\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
#+end_src
** Bibliography
2021-05-19 19:05:52 +02:00
#+begin_src latex
2021-12-09 16:54:14 +01:00
\usepackage{xpatch} % Recommanded for biblatex
2021-05-19 19:05:52 +02:00
\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}
#+end_src
#+begin_src latex
2021-12-09 16:54:14 +01:00
\defbibenvironment{mypubs}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
2021-05-19 19:05:52 +02:00
#+end_src
Remove ISSN, DOI and URL to shorten the bibliography.
#+begin_src latex
\AtEveryBibitem{%
\clearfield{urlyear}
\clearfield{urlmonth}
\clearfield{note}
\clearfield{issn} % Remove issn
\clearfield{doi} % Remove doi
\ifentrytype{online}{}{% Remove url except for @online
\clearfield{url}
}
}
#+end_src
And increase the spacing between the entries, as per default they are too small.
#+begin_src latex
\setlength\bibitemsep{1.1\itemsep}
#+end_src
Also reduce the font-size
#+begin_src latex
\renewcommand*{\bibfont}{\footnotesize}
#+end_src
2025-02-04 18:11:58 +01:00
** Table of Contents for each chapter
2021-12-09 15:56:34 +01:00
Note that this is marked as deprecated for koma-script.
2021-05-19 19:21:46 +02:00
#+begin_src latex
\usepackage{minitoc}
2021-12-09 17:22:40 +01:00
% Change section font
\renewcommand{\mtcSfont}{\small}
% Change indentation
\setlength{\mtcindent}{0pt}
2021-12-09 16:54:14 +01:00
% \usepackage[nottoc]{tocbibind}
2021-05-19 19:21:46 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** TODO Fonts
2021-05-19 19:05:52 +02:00
#+begin_src latex
2024-04-12 09:32:02 +02:00
\ifxetexorluatex
2025-02-04 18:11:58 +01:00
% \usepackage{unicode-math} % It seems I don't need that as I don't want to use unicode char
\usepackage{fontspec}
2024-04-12 09:32:02 +02:00
\setmainfont{EB Garamond}
2025-02-04 18:11:58 +01:00
% \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}
2024-04-12 09:32:02 +02:00
\else
2025-02-04 18:11:58 +01:00
% \usepackage[lf]{ebgaramond} % https://tug.org/FontCatalogue/quattrocento/
2024-04-12 09:32:02 +02:00
\usepackage[oldstyle,scale=0.7]{sourcecodepro} % https://tug.org/FontCatalogue/sourcecodepro/
\singlespacing
\fi
2021-05-19 19:05:52 +02:00
#+end_src
2025-02-04 18:11:58 +01:00
** Colors
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage[usenames,dvipsnames]{xcolor}
2025-02-04 18:11:58 +01:00
\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}
#+end_src
** CS Quotes
2021-05-19 19:05:52 +02:00
The [[https://ctan.org/pkg/csquotes ][csquotes ]] package offers context sensitive quotation facilities, improving the typesetting of inline quotes.
#+begin_src latex
\usepackage{csquotes}
#+end_src
To enclose quote environments with quotes from csquotes, see [[https://tex.stackexchange.com/questions/365231/enclose-a-custom-quote-environment-in-quotes-from-csquotes ][the following TeX SE thread ]].
#+begin_src latex
\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}}
#+end_src
And then use quotes as:
#+begin_example
# 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
#+end_example
Note that org-ref links won't work here because the attr latex will be pasted as-is in the .tex file.
2025-02-04 18:11:58 +01:00
** Setspace for controlling line spacing
2021-05-19 19:05:52 +02:00
#+begin_src latex
\usepackage{setspace}
\setstretch{1.25}
#+end_src
2025-02-04 18:11:58 +01:00
** Parskip
2021-05-19 19:05:52 +02:00
Fine tuning of spacing between paragraphs. See [[https://tex.stackexchange.com/questions/161254/smaller-parskip-than-half-for-koma-script ][thread here ]].
#+begin_src latex
\setparsizes{0em}{0.1\baselineskip plus .1\baselineskip}{1em plus 1fil}
#+end_src
2025-02-04 18:11:58 +01:00
** Possible Equation improvements
2021-05-19 19:05:52 +02:00
Make the equation numbers follow the chapter, not the whole thesis.
#+begin_src latex
\numberwithin{equation}{chapter}
#+end_src
2025-02-04 18:11:58 +01:00
** Minted
2021-05-19 19:05:52 +02:00
The minted package is used for highlighting source code.
#+begin_src latex
\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}
#+end_src
And reduce the distance between a minted listing and its caption.
#+begin_src latex
\AtEndEnvironment{listing}{\vspace{-16pt}}
#+end_src
2025-02-04 18:11:58 +01:00
#+begin_src matlab
\let\OldTexttt\texttt
\renewcommand{\texttt}[1]{{\ttfamily\hl{\mbox{\,#1\,}}}}
#+end_src
** Scrhack
2021-05-19 19:05:52 +02:00
This package fixes some incompatibility errors between KOMAScript and other packages (namely minted). It has to be loaded at the end.
#+begin_src latex
\usepackage{scrhack}
#+end_src
2025-02-04 18:11:58 +01:00
** Background cover page
2021-05-19 19:05:52 +02:00
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.
#+begin_src latex :tangle no
\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}
}%
}
#+end_src
2025-02-04 18:11:58 +01:00
** Various
#+begin_src latex
\usepackage{float}
\usepackage{enumitem}
% highlight
\usepackage{soul}
\sethlcolor{my-pale-grey}
#+end_src
** Index and glossaries
#+begin_src latex
\makeindex
\makeglossaries
#+end_src