From 6ead6169d2461ebfcf948da4af12e015b69350ac Mon Sep 17 00:00:00 2001
From: Silvio Rhatto <rhatto@riseup.net>
Date: Mon, 16 Sep 2024 22:05:40 -0300
Subject: Fix: TOC spacing

---
 structure/book/en/00-header.tex | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'structure/book/en/00-header.tex')

diff --git a/structure/book/en/00-header.tex b/structure/book/en/00-header.tex
index ded10bd..64dcca6 100644
--- a/structure/book/en/00-header.tex
+++ b/structure/book/en/00-header.tex
@@ -42,6 +42,31 @@
 %     https://tex.stackexchange.com/questions/624033/long-sidenotes-break-marginfix-or-how-to-make-breakable-sidenotes
 \usepackage{marginfix}
 
+% TOC customization
+% The tufte-latex package relies on titletoc for TOC formatting.
+%
+% But the spacing between the section number and the section name is too small
+% if the section name is too big.
+%
+% Example: "10.10Section name" instead of "10.10 Section name"
+%
+% Therefore we need to reset \titlecontents for section.
+%
+% The original code is full of "FIXMEs", so maybe this should be filled
+% upstream as a bug, along with a Minimum Working Example (MVE).
+%
+% See https://ctan.org/pkg/tufte-latex
+%     https://github.com/Tufte-LaTeX/tufte-latex
+%     https://ctan.org/pkg/titletoc
+%     https://github.com/Tufte-LaTeX/tufte-latex/blob/efb8c8e836890bad71fb5834acdd316ebde6db12/tufte-common.def#L1672
+\titlecontents{section}%
+  [0em] % distance from left margin
+  {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry)
+  {\hspace*{2em}\contentslabel{2.5em}} % before w/label (label = ``2.6'')
+  {\hspace*{2em}} % before w/o label
+  {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+  [\end{fullwidth}] % after
+
 % Workaround to theorems work correctly
 % Maybe this is not needed anymore
 % See https://stackoverflow.com/questions/46942352/r-bookdown-document-with-theorem-does-not-render-when-output-file-is-specified
-- 
cgit v1.2.3

