aboutsummaryrefslogtreecommitdiff
path: root/structure/book/pt-br/00-header.tex
blob: 64dcca6e79a091d086fc174b075e6e9e1780a03f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
% Bookdown LaTeX header file

% Inclusion of external PDF documents (such as a cover image)
% See https://www.ctan.org/pkg/pdfpages
\usepackage{pdfpages}

% To properly handle URLs in bibliographies
% See https://tex.stackexchange.com/questions/484176/biblatex-overflowing-url
\usepackage{xurl}

% PDF bookmarks
% See https://ctan.org/pkg/bookmark
%     https://texdoc.org/serve/bookmark.pdf/0
\usepackage[depth=2]{bookmark}

% Indexing
% See https://en.wikibooks.org/wiki/LaTeX/Indexing
%     https://www.ctan.org/pkg/makeidx
%     https://bookdown.org/yihui/bookdown/latex-index.html
%\usepackage{imakeidx}
\usepackage{makeidx}
\makeindex

% No matter what is said in the docs, this was required
% But maybe because tufte::tufte_book was being used instead of bookdown::tufte_book2
% So perhaps this is not needed anymore
% See https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#theorems
%     https://ctan.math.illinois.edu/macros/latex/contrib/thmtools/doc/thmtools-manual.pdf
\usepackage{amsthm,thmtools}

% Bookdown docs recommends to not mess with this
% See https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#theorems
%\newtheorem{definition}{Definição}[chapter]
%\newtheorem{hiphotesis}{Hipótese}[chapter]
%\newtheorem{conjecture}{Conjectura}[chapter]
%\newtheorem{demonstration}{Demonstração}[chapter]
%\newtheorem{etimology}{Etimologia}[chapter]

% Fix positions of margin notes
% See https://ctan.org/pkg/marginfix
%     https://tex.stackexchange.com/questions/119726/horizontal-margins-for-margin-notes-in-the-tufte-classes
%     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
\let\BeginKnitrBlock\begin \let\EndKnitrBlock\end

% Set page size
%
% This command conflicts with something and gives an error
%\usepackage[paperwidth=6in, paperheight=9in]{geometry}
%
% This command needs tuning for the margins
%\newgeometry{paperwidth=6in, paperheight=9in}
%
% This also needs tuning
% See https://tex.stackexchange.com/questions/201893/change-paper-size-in-tufte-book-class#380699
%\newgeometry{
%  % showframe,
%  paperwidth=6in,
%  paperheight=9in,
%  left=0.55in,
%  right=0.45in,
%  top=.5in,
%  bottom=.5in,
%  marginparsep=0.25in,
%  marginparwidth=0.65in,
%  includemp,
%  includehead,
%  % The text width and height are calculated automatically.
%}
%
% This should work, but we're setting this at 00-header.md
%\newgeometry{b5paper}

% Coverpage and copyright notice before title in R bookdown
% See https://stackoverflow.com/questions/45963505/coverpage-and-copyright-notice-before-title-in-r-bookdown
\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}

% Custom header
\IfFileExists{snippets/header.tex}{\input{snippets/header.tex}}{}