From 339417801abecb556c688ebb2fffb1de75af1ae8 Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@inrae.fr>
Date: Wed, 28 Feb 2024 14:28:58 +0100
Subject: [PATCH] refactor: templates organization based on basic template

After #19

Refs #11
---
 inst/templates/basic/after_body.tex      |  0
 inst/templates/basic/before_body.tex     |  0
 inst/templates/basic/in_header.tex       | 52 ++++++++++++++
 inst/templates/inrae/in_header.tex       |  3 +-
 inst/templates/inrae/preambule_inrae.tex | 87 ++----------------------
 inst/templates/umr_geau/in_header.tex    |  1 +
 6 files changed, 61 insertions(+), 82 deletions(-)
 create mode 100644 inst/templates/basic/after_body.tex
 create mode 100644 inst/templates/basic/before_body.tex
 create mode 100644 inst/templates/basic/in_header.tex

diff --git a/inst/templates/basic/after_body.tex b/inst/templates/basic/after_body.tex
new file mode 100644
index 0000000..e69de29
diff --git a/inst/templates/basic/before_body.tex b/inst/templates/basic/before_body.tex
new file mode 100644
index 0000000..e69de29
diff --git a/inst/templates/basic/in_header.tex b/inst/templates/basic/in_header.tex
new file mode 100644
index 0000000..420c91c
--- /dev/null
+++ b/inst/templates/basic/in_header.tex
@@ -0,0 +1,52 @@
+% Basic report template
+
+\usepackage[utf8]{inputenc}
+
+% Page margin definitions
+\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
+
+% Citations renderer
+\usepackage[style=authoryear,]{biblatex}
+% Keep lower case in biblatex French
+% https://tex.stackexchange.com/questions/438423/keep-lowercase-in-biblatex
+\iflanguage{french}{\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}}
+
+% Quotations
+% @see https://fr.sharelatex.com/learn/Typesetting_quotations
+% @usage the environment displayquote prints a display quotation and the command \textquote an in-line quotation
+\usepackage{csquotes}
+
+% Table format
+% https://bookdown.org/yihui/bookdown/tables.html#cb48
+% https://bookdown.org/yihui/bookdown/yaml-options.html#cb112
+\usepackage{booktabs}
+\usepackage{longtable}
+
+% Extra space for numbered titles in table of contents
+% http://tex.stackexchange.com/a/13691/124910
+% \usepackage{tocstyle} % tocstyle is deprecated see https://ctan.org/pkg/tocstyle
+\usepackage{tocbasic}
+
+\usepackage{textcomp} % Unicode degree symbol °
+
+% Ecrire les siècles
+\iflanguage{french}{\def\siecle#1{\textsc{\romannumeral #1}\textsuperscript{e}~siècle}}
+
+% Supprime les liens moches et permet le retour à la ligne du ToC
+\PassOptionsToPackage{hyphens}{url}\usepackage[hidelinks,breaklinks]{hyperref}
+
+%How to create fixed width table columns with text raggedright/centered/raggedleft?
+% @see https://tex.stackexchange.com/a/12712
+% @example \begin{tabular}{| c | L{3cm} | C{3cm} | R{3cm} |}
+\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
+\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
+\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
+
+% Avoir la possibilité de ne pas avoir de césure sur un bloc de texte (pour le titre en page de garde) http://tex.stackexchange.com/a/5003
+% @example \nohyphens{(text block)}
+\usepackage{hyphenat}
+
+% pour fixer l'emplacement des figures
+% \begin{figure}[H]
+% Voir http://tex.stackexchange.com/a/8633
+\usepackage{float}
diff --git a/inst/templates/inrae/in_header.tex b/inst/templates/inrae/in_header.tex
index 688f8bb..c9e2ef6 100644
--- a/inst/templates/inrae/in_header.tex
+++ b/inst/templates/inrae/in_header.tex
@@ -5,10 +5,9 @@
 \newcommand{\insertthirdlogo}{}
 \newcommand{\insertfourthlogo}{}
 
+\input{../../templates/basic/in_header}
 \input{../../templates/inrae/preambule_inrae.tex}
 
-%\usepackage[french]{babel}
-
 \newcommand{\service}{UMR G-EAU}
 \newcommand{\site}{
     UMR G-EAU
diff --git a/inst/templates/inrae/preambule_inrae.tex b/inst/templates/inrae/preambule_inrae.tex
index 93f21f0..1ec3178 100644
--- a/inst/templates/inrae/preambule_inrae.tex
+++ b/inst/templates/inrae/preambule_inrae.tex
@@ -5,82 +5,7 @@
 % @date Avril 2017
 %*******************************************************************************
 
-% Citations renderer
-\usepackage[style=authoryear,]{biblatex}
-% Keep lower case in biblatex French
-% https://tex.stackexchange.com/questions/438423/keep-lowercase-in-biblatex
-%\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
 
-% Beau tableau
-\usepackage{booktabs}
-
-\usepackage{tikz}
-
-% Quotations
-% @see https://fr.sharelatex.com/learn/Typesetting_quotations
-% @usage the environment displayquote prints a display quotation and the command \textquote an in-line quotation
-\usepackage{csquotes}
-% displayquote in italic
-\renewcommand{\mkbegdispquote}[2]{\itshape}
-
-% Gestion de la bibliographie avec biblatex
-% \input{rapport/preambule_biblatex}
-
-
-% Extra space for numbered titles in table of contents
-% http://tex.stackexchange.com/a/13691/124910
-% \usepackage{tocstyle} % tocstyle is deprecated see https://ctan.org/pkg/tocstyle
-\usepackage{tocbasic}
-% In case of `no room for new \write` issue
-% \usepackage{scrwfile}
-
-% Ajout de la gestion des couleurs
-% The \usepackage is obvious, but the initialization of additional commands like usenames allows you to use names of the default colors, the same 16 base colors as used in HTML. The dvipsnames allows you access to more colors, another 64, and svgnames allows access to about 150 colors. The initialization of "table" allows colors to be added to tables by placing the color command just before the table. https://en.wikibooks.org/wiki/LaTeX/Colors
-% @see http://mirrors.ircam.fr/pub/CTAN/macros/latex/contrib/xcolor/xcolor.pdf
-% \usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
-
-\usepackage{textcomp} % Unicode degree symbol °
-
-% Ecrire les siècles
-\def\siecle#1{\textsc{\romannumeral #1}\textsuperscript{e}~siècle}
-
-% Supprime les liens moches et permet le retour à la ligne du ToC
-\PassOptionsToPackage{hyphens}{url}\usepackage[hidelinks,breaklinks]{hyperref}
-
-% Définition des marges
-\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
-
-% Table's definition
-% http://www.xm1math.net/doculatex/tableaux.html
-\usepackage{array,multirow,makecell}
-
-%How to create fixed width table columns with text raggedright/centered/raggedleft?
-% @see https://tex.stackexchange.com/a/12712
-% @example \begin{tabular}{| c | L{3cm} | C{3cm} | R{3cm} |}
-\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
-\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
-\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
-
-% Avoir la possibilité de ne pas avoir de césure sur un bloc de texte (pour le titre en page de garde) http://tex.stackexchange.com/a/5003
-% @example \nohyphens{(text block)}
-\usepackage{hyphenat}
-
-% pour fixer l'emplacement des figures
-% \begin{figure}[H]
-% Voir http://tex.stackexchange.com/a/8633
-\usepackage{float}
-
-%subfigures http://tex.stackexchange.com/a/37597
-\usepackage{subcaption}
-
-% Liens colorés http://tex.stackexchange.com/a/12408
-\usepackage{url}
-\hypersetup{
-    colorlinks,
-    linkcolor={blue!50!black},
-    citecolor={blue!50!black},
-    urlcolor={blue!80!black}
-}
 
 % Forcer les figures à apparaître dans la section en cours
 % http://tex.stackexchange.com/a/32605
@@ -121,8 +46,6 @@
 % \input{rapport/headfoot_content}
 % }
 
-\usepackage[utf8]{inputenc}
-
 % Définition de la police du document http://stackoverflow.com/q/877597
 \usepackage{times}
 \renewcommand{\familydefault}{\sfdefault}
@@ -130,6 +53,7 @@
 \urlstyle{same} %http://tex.stackexchange.com/questions/261434/changing-url-font
 
 % Première de couverture
+\usepackage{tikz}
 \usepackage{titling}
 \makeatletter
 \def\maketitle{%
@@ -158,6 +82,8 @@
 \definecolor{titreColor}{HTML}{008C8E}  % inraeDark
 \definecolor{linkColor}{HTML}{423089}  % inraeBlue
 
+% Liens colorés http://tex.stackexchange.com/a/12408
+\usepackage{url}
 \hypersetup{
     colorlinks,
     linkcolor={linkColor},
@@ -202,9 +128,6 @@
 \usepackage{enumitem}
 \setlist[itemize]{label=\raisebox{0.25ex}{$\bullet$}}
 
-% Acronymes
-\usepackage[printonlyused,withpage]{acronym}
-
 % List of figures and tables as sections in a report https://texblog.org/2014/03/25/table-of-contents-list-of-figures-and-tables-as-sections-in-a-report/
 \makeatletter
 \renewcommand\listoftables{%
@@ -216,3 +139,7 @@
     \@starttoc{lof}%
 }
 \makeatother
+
+% Acronymes
+\usepackage[printonlyused,withpage]{acronym}
+
diff --git a/inst/templates/umr_geau/in_header.tex b/inst/templates/umr_geau/in_header.tex
index 900866a..9a9b524 100644
--- a/inst/templates/umr_geau/in_header.tex
+++ b/inst/templates/umr_geau/in_header.tex
@@ -22,6 +22,7 @@
 \url{www.inrae.fr}
 }
 
+\input{../../templates/basic/in_header}
 \input{../../templates/inrae/preambule_inrae.tex}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- 
GitLab