summaryrefslogtreecommitdiff
path: root/info/guide-latex-fr/Chapitres/commandes.tex
blob: ec62918fe5042fba6aaa5009c3e23f7831aad2be (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
% Commandes créées

% Page de garde et mind map
\definecolor{BlueFR}{RGB}{0,35,149}
\definecolor{RedFR}{RGB}{237,41,57}
\definecolor{NewOrange}{RGB}{247,111,43}
\definecolor{Gold}{RGB}{255,215,0}

% Aperçu Texmaker (Aide_LaTeX1.png) -- Hred = Red - Hyellow = Gold
\definecolor{Horange}{RGB}{255,156,0}
\definecolor{Hgreen}{RGB}{0,167,0}
\definecolor{Hblue}{RGB}{0,234,255}
\definecolor{Hpurple}{RGB}{169,15,219}

% Signature
\definecolor{lightningcyan}{RGB}{59,195,235}


% Raccourcis
\newcommand{\Windows}{\texttt{Windows}}
\newcommand{\Linux}{\texttt{Linux}}
\newcommand{\Apple}{\texttt{Apple}}
\newcommand{\LinkedIn}{\texttt{LinkedIn}}
\newcommand{\MiKTeX}{\texttt{MiKTeX}}
\newcommand{\Texmaker}{\texttt{Texmaker}}
\newcommand{\TikZ}{Ti\textit{k}Z}
\newcommand{\Beamer}{\texttt{Beamer}}
\newcommand{\Paint}{\texttt{Paint}}
\newcommand{\GIMP}{\texttt{GIMP}}
\newcommand{\Inkscape}{\texttt{Inkscape}}

\newcommand{\folder}{\textcolor[RGB]{255,231,157}{\faFolder}}


% Tableau bilan
\newenvironment{tableaubilan}[4]{
	\begin{longtable}{p{#1}p{#2}}
	% Définition des headers & footers du longtable
	{\hspace*{\fill}\textsc{#3}\hspace*{\fill}} & {\hspace*{\fill}\textsc{#4}\hspace*{\fill}} \\ \midrule
	\endhead
	\multicolumn{2}{r}{\textit{(suite sur la page suivante)}} \\
	\endfoot
	\multicolumn{2}{@{\hrulefill}c@{\hrulefill}}{\raisebox{-3pt}{~~\textsc{Fin du tableau}~~}}
	\endlastfoot
}{\end{longtable}}


% "Boîtes" -- Package tcolorbox
% Boîtes types
\newtcolorbox{boitetype}[4][]{enhanced, breakable, before upper = {\parindent17.6pt}, beforeafter skip = \baselineskip, colframe = #3, colback = #4, boxrule = 2pt, arc = 4mm, fonttitle = \bfseries, title = {#2}, coltitle = black, #1} % before upper = alinéa dans boîte

\newtcolorbox{boitecointype}[7][]{%
cornerrulewidth/.store in = {\tcbcornerrulewidth},
cornerrulewidth = #7,
topcornercolor/.store in = {\tcbtopcornercolor},
topcornercolor = #3,
bottomcornercolor/.store in = {\tcbbottomcornercolor},
bottomcornercolor = #4,
enhanced, breakable, before upper = {\parindent17.6pt}, beforeafter skip = \baselineskip, sharp corners, boxrule = 0pt, colback = #5, title = {#2}, fonttitle = \bfseries, coltitle = black, colbacktitle = #6, underlay unbroken = {
	\draw[\tcbtopcornercolor, line width = \tcbcornerrulewidth] ([xshift = -\tcbcornerrulewidth/2]frame.west) -- ([shift = {(-\tcbcornerrulewidth/2,\tcbcornerrulewidth/2)}]frame.north west) -- ([yshift = \tcbcornerrulewidth/2]frame.north);
	\draw[\tcbtopcornercolor, line width = \tcbcornerrulewidth] ([xshift = \tcbcornerrulewidth/2]frame.east) -- ([shift = {(\tcbcornerrulewidth/2,-\tcbcornerrulewidth/2)}]frame.south east) -- ([yshift = -\tcbcornerrulewidth/2]frame.south);
}, underlay first = {
	\draw[\tcbtopcornercolor, line width = \tcbcornerrulewidth] ([xshift = -\tcbcornerrulewidth/2]frame.west) -- ([shift = {(-\tcbcornerrulewidth/2,\tcbcornerrulewidth/2)}]frame.north west) -- ([yshift = \tcbcornerrulewidth/2]frame.north);
}, underlay last = {
	\draw[\tcbtopcornercolor, line width = \tcbcornerrulewidth] ([xshift = \tcbcornerrulewidth/2]frame.east) -- ([shift = {(\tcbcornerrulewidth/2,-\tcbcornerrulewidth/2)}]frame.south east) -- ([yshift = -\tcbcornerrulewidth/2]frame.south);
}, #1}


% Construction des autres boîtes en fonction d'une boîte type
\newenvironment{boite}[3][]{\begin{boitetype}[#1]{#2}{#3}{white}}{\end{boitetype}}
\newenvironment{boitecoin}[3][]{\begin{boitecointype}[#1]{#2}{#3}{#3}{#3!5!white}{#3!50}{2pt}}{\end{boitecointype}}

\newenvironment{regles}[2][]{\begin{boitetype}[sharp corners, boxrule = 3pt, coltitle = white, #1]{#2}{BrickRed}{Goldenrod}}{\end{boitetype}}
\newenvironment{definition}[2][]{\begin{boitecoin}[#1]{#2}{Green}}{\end{boitecoin}}
\newenvironment{conseil}[2][]{\begin{boitetype}[#1]{#2}{cyan}{cyan!40}}{\end{boitetype}}
\newenvironment{attention}[2][]{\begin{boitetype}[left = 6mm, coltitle = white, sharp corners = west, underlay = {%
	\path[fill = yellow!50!black] (frame.south west) rectangle node[white] {\huge\bfseries{}!} ([xshift = 4mm]frame.north west);
}, drop fuzzy shadow, #1]{#2}{yellow!20!black}{yellow!50}}{\end{boitetype}} % Nouvelle boîte "attention" -- Inspiration : boîte "marker" (code source guide tcolorbox)


%%% --- Explications --- %%%

% Ne fonctionne pas : \newenvironment{code}[2][]{\begin{boitecodetype}[#1]{#2}{LimeGreen}{LimeGreen!5!white}{LimeGreen!50}{2pt}{TeX}}{\end{boitecodetype}}

% Boite type avec listings impossible --> problème lors de l'appel du nouvel environnement 
% (en gros, avec une couche supplémentaire \newenvironment, listings n'arrive pas à bien détecter le début et la fin de l'environnement donc erreur)

% Solution :
% Utilisation de styles (commandes propres à tcolorbox & listings) pour recenser les options à utiliser
% Création ensuite de 3 environnements (distincts et non imbriqués) mais avec appel de ces commandes 
% ==> gain de lignes et généralisation possible

%%% --- FIN Explications --- %%%

% Stockage de 2 variables principales (plus propre)
% Autre solution : utiliser le code source tcolorbox (tcbcol@frame : couleur définie par colback)
% Attention : breakable non appliqué si "listing side text" (pas de coupure)
% ==> faire des "petits" bouts de code
\tcbset{
codemainoptions/.style = {
	maincolor/.store in = {\tcbmaincol},
	maincolor = LimeGreen,
	rulewidth/.store in = {\tcbrulewidth},
	rulewidth = 2pt,
	enhanced, breakable, beforeafter skip = \baselineskip, sharp corners, boxrule = \tcbrulewidth, colframe = \tcbmaincol, colback = \tcbmaincol!15, drop fuzzy shadow, colbacktitle = \tcbmaincol!50, coltitle = black, fonttitle = \bfseries, title = {#1},
	attach boxed title to top center = {yshift = -\tcbrulewidth/2-\tcboxedtitleheight/2, yshifttext = -\tcboxedtitleheight/2}, boxed title style = {boxrule = \tcbrulewidth, frame code = {
		\path[tcb fill frame] ([xshift = -3mm]frame.west) -- (frame.north west) -- (frame.north east) -- ([xshift = 3mm]frame.east) -- (frame.south east) -- (frame.south west) -- cycle;}, interior code = {
		\path[tcb fill interior] ([xshift = -2mm]interior.west) -- (interior.north west) -- (interior.north east) -- ([xshift = 2mm]interior.east) -- (interior.south east) -- (interior.south west) -- cycle;}}
}
}

\lstdefinestyle{mainlststyle}{
language = {[LaTeX]TeX},
style = tcblatex,
texcsstyle = *\color{cyan!65!black},
commentstyle = \color{gray},
tabsize = 4,
keepspaces = true,
breaklines = true,
breakatwhitespace = false,
inputencoding = utf8,
numbers = none,
showspaces = false,
showtabs = false,
showstringspaces = false
}

% N.B. : #2 = titre de la boite
\newtcblisting{code}[2][]{codemainoptions = {#2}, listing options = {style = mainlststyle}, listing only, #1}

\newtcblisting{codedisplay}[2][]{codemainoptions = {#2}, listing options = {style = mainlststyle}, listing side text, righthand ratio = 0.4, sidebyside gap = 13mm, bicolor, colbacklower = white, #1}

% compilable listing ==> compiler "main.tex" avec "-shell-escape"
\newtcblisting{coderesult}[2][]{codemainoptions = {#2}, listing options = {style = mainlststyle}, listing and comment, bicolor, colbacklower = white, compilable listing, run pdflatex, pdf comment, freeze pdf, comment style = {raster columns = 2, drop lifted shadow}, #1}

% Boîte spéciale code TikZ
% 1ère idée : nouvelle boîte brute avec listing and comment (comment = {\resizebox{\linewidth}{!}{\tcbuselistingtext}} -- \tcbuse... = contenu de la boîte soit code TikZ)
% 2nde idée : se contenter d'un "listing and text" avec structure boîte "codedisplay"
\newtcblisting{codetikz}[2][]{codemainoptions = {#2}, listing options = {style = mainlststyle}, listing and text, bicolor, colbacklower = white, #1}