Better LaTeX setup

This commit is contained in:
2025-02-04 23:10:59 +01:00
parent a8e88ce746
commit 7074b2bf04
5 changed files with 331 additions and 267 deletions

152
setup.org
View File

@@ -95,6 +95,12 @@ Do not modify itemize/enumerate environments by default
\onehalfspacing
#+end_src
** List of figures
#+begin_src latex
\usepackage{tocloft}
\setlength{\cftfignumwidth}{2.5em} % Adjust this value as needed
#+end_src
** Tables
#+begin_src latex
\usepackage{booktabs}
@@ -119,40 +125,6 @@ I reduce the size of tables so that longer tables can still fit into an A4 (redu
\displaywidowpenalty = 10000
#+end_src
** Headers
#+begin_src latex
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
#+end_src
** Section/Figure format
#+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}}
\setcounter{secnumdepth}{\subsubsectionnumdepth}
#+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}}
% 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
#+end_src
** 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.
@@ -169,28 +141,6 @@ See more information [[https://tex.stackexchange.com/questions/68516/avoid-that-
\pretocmd{\section}{\clearpage}{}{}
#+end_src
** Hyperref and Bookmarks
#+begin_src latex
\usepackage[ %
colorlinks=true, %
citecolor=BrickRed, %
linkcolor=BrickRed, %
urlcolor=BrickRed, %
unicode %
]{hyperref}
\usepackage{hypcap}
#+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
** Use pdf instead of png
#+begin_src latex
\makeatletter
@@ -388,7 +338,7 @@ And reduce the distance between a minted listing and its caption.
\AtEndEnvironment{listing}{\vspace{-16pt}}
#+end_src
#+begin_src matlab
#+begin_src latex
\let\OldTexttt\texttt
\renewcommand{\texttt}[1]{{\ttfamily\hl{\mbox{\,#1\,}}}}
#+end_src
@@ -426,6 +376,94 @@ Add the cover image as background to the first page. Only do so when outputting
\sethlcolor{my-pale-grey}
#+end_src
** Headers
#+begin_src latex
% \usepackage[headsepline]{scrlayer-scrpage}
% \pagestyle{scrheadings}
#+end_src
Config to have the chapter name until there is a section, and then displays the sections (from the doc)
#+begin_src latex
\usepackage[autooneside=false,headsepline]{scrlayer-scrpage}
% \pagestyle{scrheadings}
% \automark[section]{chapter}
#+end_src
#+begin_src latex
% 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
#+end_src
Kind of working solution:
#+begin_src latex
% \automark{section}
% \renewhead*{headings}{
% \ifstr{\headmark}{}{}{%
% \headmark\hfill
% }
% }
#+end_src
** Section/Figure format
#+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}}
\setcounter{secnumdepth}{\subsubsectionnumdepth}
#+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}}
% 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
#+end_src
** Hyperref and Bookmarks
#+begin_src latex
\usepackage[ %
colorlinks=true, %
citecolor=BrickRed, %
linkcolor=BrickRed, %
urlcolor=BrickRed, %
unicode %
]{hyperref}
\usepackage{hypcap}
#+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
** Index and glossaries
#+begin_src latex
\makeindex