summaryrefslogtreecommitdiff
path: root/info/formation-latex-ul/source/formation-latex-ul.tex
blob: 618ceb786c55fb3e98550fc0c4e4ebeda68d9886 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
%%% Copyright (C) 2020 Vincent Goulet
%%%
%%% Ce fichier fait partie du projet
%%% «Rédaction avec LaTeX»
%%% https://gitlab.com/vigou3/formation-latex-ul
%%%
%%% Cette création est mise à disposition sous licence
%%% Attribution-Partage dans les mêmes conditions 4.0
%%% International de Creative Commons.
%%% https://creativecommons.org/licenses/by-sa/4.0/

\documentclass[letterpaper,11pt,x11names,english,french]{memoir}
  \usepackage{natbib,url,bibentry}
  \usepackage{babel}
  \usepackage[autolanguage]{numprint}
  \usepackage{amsmath,amsthm}
  \usepackage[shortlabels]{enumitem}
  \usepackage{graphicx}
  \usepackage{manfnt}                  % \mantriangleright (puce)
  \usepackage{dirtree}                 % arbre pour exercice sur \include
  \usepackage{metalogo}                % logo de \XeLaTeX
  \usepackage{mflogo}                  % logo de Metafont
  \usepackage{relsize}                 % \smaller et al.
  \usepackage{fontawesome5}            % plusieurs icônes
  \usepackage{awesomebox}              % boites info, important, etc.
  \usepackage{applekeys}               % touches Mac
  \usepackage{answers}                 % exercices et solutions
  \usepackage{listings}                % code informatique
  \usepackage[absolute]{textpos}       % disposition d'images
  \usepackage{ifthen}                  % exécution conditionnelle
  \usepackage{soul}                    % base pour boites autour des caractères


  %%% =============================
  %%%  Informations de publication
  %%% =============================
  \title{Rédaction avec \LaTeX}
  \author{Vincent Goulet}
  \renewcommand{\year}{2020}
  \renewcommand{\month}{10}
  \newcommand{\ctanurl}{https://ctan.org/pkg/formation-latex-ul/}
  \newcommand{\reposurl}{https://gitlab.com/vigou3/formation-latex-ul/}

  %%% ===================
  %%%  Style du document
  %%% ===================

  %% Polices de caractères
  \usepackage{fontspec}
  \usepackage{unicode-math}
  \defaultfontfeatures
  {
    Scale = 0.92
  }
  \setmainfont{Lucida Bright OT}
  [
    Ligatures = TeX,
    Numbers = OldStyle
  ]
  \setmathfont{Lucida Bright Math OT}
  \setmonofont{Lucida Grande Mono DK}
  \setsansfont{FiraSans}
  [
    Extension = .otf,
    UprightFont = *-Book,
    ItalicFont = *-BookItalic,
    BoldFont = *-SemiBold,
    BoldItalicFont = *-SemiBoldItalic,
    Scale = 0.95,
    Numbers = OldStyle
  ]
  \newfontfamily\fullcaps{FiraSans}
  [
    Extension = .otf,
    UprightFont = *-Book,
    Scale = 0.95,
    Numbers = Uppercase
  ]
  \usepackage[babel=true]{microtype}
  \usepackage{icomma}

  %% Polices additionnelles pour le chapitre trucs et astuces
  \newfontfamily\CM[Ligatures=TeX]{cmunrm.otf}        % Computer Modern
  \newfontfamily\Times{texgyretermes-regular.otf}     % Times
  \newfontfamily\Palatino{texgyrepagella-regular.otf} % Palatino
  \newfontfamily\Bookman{texgyrebonum-regular.otf}    % Bookman
  \newfontfamily\NewCent{texgyreschola-regular.otf}   % New Cent. Sch.
  \newfontfamily\Charter{XCharter-Roman.otf}          % Charter
  \newfontfamily\Helvet{texgyreheros-regular.otf}     % Helvetica

  %% Couleurs
  \usepackage{xcolor}
  \definecolor{comments}{rgb}{0.5,0.55,0.6} % commentaires
  \definecolor{link}{rgb}{0,0.4,0.6}        % liens internes
  \definecolor{url}{rgb}{0.6,0,0}           % liens externes
  \definecolor{citation}{rgb}{0,0.5,0}      % citations
  \definecolor{ULlinkcolor}{rgb}{0,0,0.3}   % de ulthese.cls
  \definecolor{rouge}{rgb}{0.90,0,0.1}      % rouge bandeau UL
  \definecolor{or}{rgb}{1,0.8,0}            % or bandeau UL

  %% Hyperliens
  \usepackage{hyperref}
  \hypersetup{%
    pdfauthor = \theauthor,
    pdftitle = {Rédaction avec LaTeX},
    colorlinks = {true},
    linktocpage = {true},
    urlcolor = {url},
    linkcolor = {link},
    citecolor = {citation},
    pdfpagemode = {UseOutlines},
    pdfstartview = {Fit}}
  \setlength{\XeTeXLinkMargin}{1pt}

  %% Affichage de la table des matières du PDF
  \usepackage{bookmark}
  \bookmarksetup{%
    open = true,
    depth = 3,
    numbered = true}

  %% Étiquettes de \autoref (redéfinitions compatibles avec babel).
  %% Attention! Les % à la fin des lignes sont importants sinon des
  %% blancs apparaissent dès que la commande \selectlanguage est
  %% utilisée, notamment dans la bibliographie.
  \addto\extrasfrench{%
    \def\subsectionautorefname{section}%
    \def\figureautorefname{figure}%
    \def\tableautorefname{tableau}%
    \def\exempleautorefname{exemple}%
    \def\exerciceautorefname{exercice}%
    \def\appendixautorefname{annexe}%
  }

  %% Table des matières et al. (inspiré de classicthesis.sty)
  \renewcommand{\cftchapterleader}{\hspace{1.5em}}
  \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \renewcommand{\cftsectionleader}{\hspace{1.5em}}
  \renewcommand{\cftsectionafterpnum}{\cftparfillskip}
  \renewcommand{\cfttableleader}{\hspace{1.5em}}
  \renewcommand{\cfttableafterpnum}{\cftparfillskip}
  \renewcommand{\cftfigureleader}{\hspace{1.5em}}
  \renewcommand{\cftfigureafterpnum}{\cftparfillskip}
  \setlength{\cftfigurenumwidth}{3.2em}

  %% Titres des chapitres
  \chapterstyle{hangnum}
  \renewcommand{\chaptitlefont}{\normalfont\Huge\sffamily\bfseries\raggedright}

  %% Marges, entêtes et pieds de page
  \setlength{\marginparsep}{7mm}
  \setlength{\marginparwidth}{20mm}
  \setlength{\headwidth}{\textwidth}
  \addtolength{\headwidth}{\marginparsep}
  \addtolength{\headwidth}{\marginparwidth}
  \addtolength{\marginparwidth}{15mm} % plus d'espace pour titres de documentation

  %% Titres des sections et sous-sections
  \setsecheadstyle{\normalfont\Large\sffamily\bfseries\raggedright}
  \setsubsecheadstyle{\normalfont\large\sffamily\bfseries\raggedright}
  \maxsecnumdepth{subsection}
  \setsecnumdepth{subsection}

  %% Listes. Paramétrage avec enumitem.
  \setlist[enumerate]{leftmargin=*,align=left}
  \setlist[enumerate,2]{label=\alph*),labelsep=*,leftmargin=1.5em}
  \setlist[enumerate,3]{label=\roman*),labelsep=*,leftmargin=1.5em,align=right}
  \setlist[itemize]{leftmargin=*,align=left}

  %% Paramétrage de babel
  \frenchbsetup{%
    StandardItemizeEnv=true,       % format standard des listes
    ThinSpaceInFrenchNumbers=true, % espace fine dans les nombres
    ItemLabeli=\mantriangleright,  % puce premier niveau
    ItemLabelii=\textendash,       % puce second niveau
    og=«, fg=»                     % caractères « et » sont les guillemets
  }
  \addto\captionsfrench{\def\figurename{{\scshape Fig.}}}
  \addto\captionsfrench{\def\tablename{{\scshape Tab.}}}
  \addto\captionsfrench{\def\listfigurename{Liste des figures}}

  %% Sections de code source
  \lstloadlanguages{[LaTeX]TeX}
  \lstset{language=[LaTeX]TeX,
    basicstyle=\ttfamily\NoAutoSpacing,
    keywordstyle=\mdseries,
    commentstyle=\color{comments}\slshape,
    emphstyle=\bfseries,
    escapeinside=`',
    extendedchars=true,
    showstringspaces=false,
    backgroundcolor=\color{LightYellow1},
    frame=leftline,
    framerule=2pt,
    framesep=5pt,
    xleftmargin=7.4pt
  }

  %%% =========================
  %%%  Nouveaux environnements
  %%% =========================

  %% Exemples
  \theoremstyle{definition}
  \newtheorem{exemple}{Exemple}[chapter]

  %% Exercices et réponses
  \Newassociation{sol}{solution}{solutions}
  \newcounter{exercice}[chapter]
  \renewcommand{\theexercice}{\thechapter.\arabic{exercice}}
  \newenvironment{exercice}[1][]{%
    \begin{list}{}{%
        \refstepcounter{exercice}
        \ifthenelse{\equal{#1}{nosol}}{%
          \renewcommand{\makelabel}{\bfseries\theexercice}}{%
          \hypertarget{ex:\theexercice}{}
          \Writetofile{solutions}{\protect\hypertarget{sol:\theexercice}{}}
          \renewcommand{\makelabel}{%
            \bfseries\protect\hyperlink{sol:\theexercice}{\theexercice}}}
        \settowidth{\labelwidth}{\bfseries\theexercice}
        \setlength{\leftmargin}{\labelwidth}
        \addtolength{\leftmargin}{\labelsep}
        \setlist[enumerate,1]{label=\alph*),labelsep=*,leftmargin=1.5em}
        \setlist[enumerate,2]{label=\roman*),labelsep=0.5em,align=right}}
      \item}
    {\end{list}}
  \renewenvironment{solution}[1]{%
    \begin{list}{}{%
        \renewcommand{\makelabel}{%
          \bfseries\protect\hyperlink{ex:#1}{#1}}
        \settowidth{\labelwidth}{\bfseries #1}
        \setlength{\leftmargin}{\labelwidth}
        \addtolength{\leftmargin}{\labelsep}
        \setlist[enumerate,1]{label=\alph*),labelsep=*,leftmargin=1.5em}
        \setlist[enumerate,2]{label=\roman*),labelsep=0.5em,align=right}}
      \item}
    {\end{list}}

  %% Démo de code LaTeX. Le code de 'texample' et 'eqxample' est
  %% repris de amsldoc.tex avec des petits ajustements.
  \newenvironment{demo}{%
    \begin{trivlist}\item}{%
    \end{trivlist}}
  \newenvironment{texample}[1][0.5\linewidth]{%
    \noindent\begin{minipage}{#1}%
      \def\producing{\end{minipage}\hfill\begin{minipage}{\dimexpr0.97\linewidth-#1}%
        \hbox\bgroup\kern-.2pt%
        \vbox\bgroup\parindent0pt\relax
        % The 3pt is to cancel the -\lineskip from \displ@y
        \abovedisplayskip3pt \abovedisplayshortskip\abovedisplayskip
        \belowdisplayskip0pt \belowdisplayshortskip\belowdisplayskip
        \noindent}
    }{%
      \par
      % Ensure that a lonely \[\] structure doesn't take up width less than
      % \hsize.
      \hrule height0pt width\hsize
      \egroup\kern-.2pt\egroup
    \end{minipage}%
    \par
  }
  \newenvironment{eqxample}{%
    \noindent\begin{minipage}{.5\columnwidth}%
      \def\producing{\end{minipage}\hfill\begin{minipage}{.45\columnwidth}%
        \hbox\bgroup\kern-.2pt\vrule width.2pt%
        \vbox\bgroup\parindent0pt\relax
        % The 3pt is to cancel the -\lineskip from \displ@y
        \abovedisplayskip3pt \abovedisplayshortskip\abovedisplayskip
        \belowdisplayskip0pt \belowdisplayshortskip\belowdisplayskip
        \noindent}
    }{%
      \par
      % Ensure that a lonely \[\] structure doesn't take up width less than
      % \hsize.
      \hrule height0pt width\hsize
      \egroup\vrule width.2pt\kern-.2pt\egroup
    \end{minipage}%
    \par
  }

  %% Un exemple du chapitre Trucs et astuces nécessite des
  %% environnements 'lstlisting' imbriqués, ce que ne digère pas
  %% LaTeX. La ruse consiste à définir un environnement équivalent qui
  %% porte simplement un autre nom.
  \lstnewenvironment{vglisting}{\lstset{deletetexcs={int,include}}}{}

  %% Exemples de notices bibliographiques
  \newenvironment{bibexample}[1][\linewidth]{%
    \begin{minipage}[t]{#1}%
      \begin{trivlist}}
      {\end{trivlist}\end{minipage}}

  %%% =======
  %%%  Index
  %%% =======
  \renewcommand{\preindexhook}{%
    Cet index contient des références aux commandes et environnements
    {\LaTeX}, ainsi qu'aux noms de paquetages et de classes. %
    Le premier numéro indique habituellement, mais pas toujours,
    la page où un concept est introduit, défini ou expliqué.%
    \vskip\onelineskip}
  \lstset{language=[AlLaTeX]TeX,
    morekeywords={align,align*,aligned,bmatrix,cases,equation*,%
      figure,gather,lstlisting,multline,quote,split,%
      table,tabular,tabularx},
    deletekeywords={document},   % répéter dans deletetexcs
    moretexcs={toprule,midrule,bottomrule,%
      includegraphics,reflectbox,resizebox,rotatebox,scalebox,%
      includepdf,frenchfigurename,frenchtablename,%
      newsubfloat,subcaption,%
      bm,dfrac,tfrac,iint,text,mathcal,mathbb,eqref,symbf,%
      citet,citep,citeauthor,citeyear,%
      setmainfont,setsansfont,setmonofont,setmathfont,%
      color,textcolor,definecolor,colorlet,hypersetup},
    deletetexcs={document,documentclass,usepackage,begin,end,LaTeX,TeX,%
      normalfont,bfseries,textbf,itshape,scshape,sffamily,ttfamily,texttt,%
      emph,small,Huge,raggedright,%
      hfill,def,a,b,c,d,em,i,j,l,r,t},
    index=[1][keywords],        % environnements
    indexstyle=[1]\ixenv,
    index=[2][texcs],           % commandes
    indexstyle=[2]\ixcmd}
  \newcommand{\ixenv}[1]{\index{#1 env@\Pe{#1}}%
    \index{environnement!#1@\Pe{#1}}}
  \newcommand{\ixcmd}[1]{\index{#1@\string\cs{#1}}}
  \makeindex

  %%% =====================
  %%%  Nouvelles commandes
  %%% =====================

  %% Noms de fonctions, code, environnement, etc.
  \newcommand{\code}[1]{\texttt{#1}}
  \newcommand{\fichier}[1]{\texttt{#1}}
  \newcommand{\class}[1]{\textsf{#1}\index{#1 class@\textsf{#1}}%
    \index{classe!#1}}
  \newcommand{\pkg}[1]{\textbf{#1}\index{#1 pkg@\textbf{#1}}%
    \index{paquetage!#1}}
  \newcommand{\Pe}[1]{\code{#1}}         % tiré de la doc de memoir
  \newcommand{\Ie}[1]{\Pe{#1}\ixenv{#1}} % idem
  \newcommand{\mat}[1]{\symbf{#1}}       % en mode mathématique

  %% Modification de commandes tirées de memoir.cls servant à afficher
  %% des noms de commandes.
  %% - \cmdprint est modifiée pour que le nom de la commande ne soit
  %%   pas en italique;
  %% - \cmd est modifiée pour utiliser @ comme séparateur dans \index
  %%   et pour utiliser \cs plutôt que \cmdprint pour afficher le nom de
  %%   la commande (afin d'obtenir le même format d'entrée d'index
  %%   qu'avec \ixcmd ci-dessus);
  %% - \pixbsbs et \pixabang servent respectivement à afficher et
  %%   indexer \\ et \! ;
  %% - \pixbar sert à afficher et indexer \| avec un hack pour
  %%   contourner un problème d'insertion de l'hyperlien vers le
  %%   numéro de page: l'entrée est triée sur le symbole [ plutôt que
  %%   sur |.
  \renewcommand{\cmdprint}[1]{\textup{\texttt{\string#1}}}
  \makeatletter
  \renewcommand{\cmd}[1]{\cmdprint{#1}%
    \index{\expandafter\@gobble\string#1@\string\cs{\expandafter\@gobble\string#1}}}
  \makeatother
  \newcommand*{\pixbsbs}{\cmdprint{\\}\index{"\ @\string\cs{}\bs}}
  \newcommand*{\pixabang}{\cmdprint{\!}\index{"!@\string\cs{}\texttt{"!}}}
  \newcommand*{\pixbar}{\cmdprint{\|}\index{[@\string\cs{}\texttt{\textbar}}}

  %% Boite additionnelle (basée sur awesomebox.sty) pour liens vers
  %% des vidéos
  \newcommand{\videobox}[1]{%
    \awesomebox{\aweboxrulewidth}{\faYoutube}{url}{#1}}

  %% Hyperlien avec symbole de lien externe juste après
  \newcommand{\link}[2]{\href{#1}{#2~\smaller\faExternalLink*}}

  %% Lien vers documentation dans la marge
  %% usage: \doc[documentation]{nom_fichier}{url}
  \newcommand{\doc}[3][documentation]{\link{#3}{#1}%
    \ifthenelse{\equal{#2}{}}{}{\marginpar%
      [\hfill\faBookmark~\fichier{#2}]%
      {\faBookmark~\fichier{#2}}}}

  %% Suppression de l'hyperlien
  \newcommand{\nolink}[1]{\begin{NoHyper}#1\end{NoHyper}}

  %% Lien vers Gitlab dans la page de notices
  \newcommand{\viewsource}[1]{%
    \href{#1}{\faGitlab\ Voir sur Gitlab}}

  %% Pour le tableau des commandes d'espacement en mode mathématique.
  %% Pris de la doc de amsmath.
  \newcommand{\lspx}{\mathord{\dashv\mkern-3mu}}
  \newcommand{\rspx}{\mathord{\mkern-2mu\vdash}}
  \newcommand{\spx}[1]{$\lspx #1\rspx$}

  %% Logo BIBTeX; tiré de https://bit.ly/1RQqUnG
  \newcommand{\BibTeX}{\rmfamily B\kern-.05em{\scshape i\kern-.025em b}\kern-.08em \TeX}

  %% Chapitre sur les bibliographies: des références bibliographiques
  %% sont insérées dans le texte avec \bibentry. Certaines commandes
  %% de francaisbst.tex sont alors utilisées, mais non encore
  %% définies. Répétées ici. De plus, il faut définir ici la commande
  %% \enquote plutôt que dans francais.bst. C'est pourquoi il y a une
  %% version modifiée de ce fichier dans ces sources.
  %% Voir https://bit.ly/1MORZmp
  \global\def\bbland{et}
  \global\def\bbledn{\'ed.}
  \global\def\bblfourtho{4{\ieme}}
  \global\def\bblth{{\ieme}}
  \global\def\bblvol{vol.}
  \def\bblno{\no{}}
  \def\bblpp{p.}
  \newcommand{\enquote}[1]{\guillemotleft#1\guillemotright}

  %%% =======
  %%%  Varia
  %%% =======

  %% Style de la bibliographie
  \bibliographystyle{francais}

  %% Longueurs pour la composition des pages couvertures avant et
  %% arrière.
  \newlength{\banderougewidth} \newlength{\banderougeheight}
  \newlength{\bandeorwidth}    \newlength{\bandeorheight}
  \newlength{\imageheight}
  \newlength{\logoheight}
  \newlength{\gapwidth}

%  \includeonly{}

\begin{document}

\frontmatter

%% Page couverture avant.
\pagestyle{empty}
\input{couverture-avant}
\null\cleardoublepage           % cf. section 2.2 textpos.pdf

%% Page de copyright
\include{notices}
\clearpage

%% Corps du document
\pagestyle{companion}

\include{introduction}

\cleartorecto
\tableofcontents
\cleartorecto
\listoftables
\cleartorecto
\listoffigures

\mainmatter

\include{presentation}
\include{bases}
\include{organisation}
\include{apparence}
\include{boites}
\include{tableaux+figures}
\include{mathematiques}
\include{bibliographie}
\include{commandes}
\include{trucs+astuces}

\appendix
\include{ulthese}               % éléments spécifiques à ulthese
\include{solutions}

\bibliography{formation-latex-ul}

\cleardoublepage
\printindex

\cleartoverso

\input{colophon}

\cleartoverso

%% Page couverture arrière.
\pagestyle{empty}
\input{couverture-arriere}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-engine: xetex
%%% TeX-master: t
%%% coding: utf-8
%%% End: