1%
2% Définitions l2h pour LaTeX
3%
4
5% l2h substitution th þ
6% l2h argblock paragraph h4
7% l2h argblock subparagraph h5
8
9\makeatletter
10\usepackage[cmyk,dvipsnames]{xcolor}
11\definecolor{emphasize}{cmyk}{0,0,0,0.05}
12\colorlet{example}{Bittersweet}
13
14\usepackage{fancyvrb}
15
16%
17% Underscore mieux mieux
18%
19%\def\_{\/\vrule height 0.4bp depth 0pt width .333em\relax}
20
21%
22% Marquage des éléments du texte
23%
24
25\newcommand\fn[1]{\textsl{#1}}		% Function name
26\newcommand\va[1]{\textit{#1}}		% Variable name
27\newcommand\fa[1]{\textit{#1}}		% Formal argument
28\newcommand\pa[1]{\textsl{#1}}		% Path
29
30% l2h argblock fn em
31% l2h argblock va var
32% l2h argblock fa car
33% l2h argblock pa em
34
35\newcommand\fn@prototype[1]{\texttt{\textbackslash#1}}
36\newcommand\fa@prototype[1]{\LA{}\textit{#1}\RA{}}
37
38%
39% Ajouter un point à la fin d'une suite de tokens, peut-être
40%
41
42\def\maybeaddadot#1{\maybeaddadot@A#1\relax.\relax\st@p}
43\def\maybeaddadot@A#1.\relax#2\st@p{#1.}
44
45
46%
47% Structure
48%
49
50\newenvironment{formalparagraph}[1]%
51  {%
52    \par
53    \bigbreak
54    \noindent
55    \begingroup
56    \def\rmA{#1}%
57    \ifx\rmA\empty\else
58    \textit{#1.~---}\enspace
59    \fi
60    \endgroup
61    \ignorespaces
62  }%
63  {\par\smallbreak}%
64
65\newenvironment{remark}%
66  {\begin{formalparagraph}{Remarque}}%
67  {\end{formalparagraph}}%
68
69\newenvironment{remarks}%
70  {\begin{formalparagraph}{Remarques}\par\nobreak
71  \ignorespaces
72  \parindent\z@
73  \parskip\smallskipamount}%
74  {\end{formalparagraph}}%
75
76\newenvironment{seealso}%
77  {\let\maybeaddadot\relax
78   \begin{formalparagraph}{Voir aussi:}\let\item\seealso@iA}%
79  {\end{formalparagraph}}%
80
81\def\seealso@A{\let\item\seealso@B}
82\def\seealso@B{, }
83
84%
85% Exemples
86%
87
88% l2h envblock example pre
89\DefineVerbatimEnvironment{example}%
90  {Verbatim}%
91  {%
92    xleftmargin=\parindent,
93    formatcom=\let\FancyVerbFormatLine\FancyExampleFormatLine
94  }%
95
96
97\def\FancyExampleFormatLine#1{\llap{\smash{$\vdots$}\enspace}\texttt{#1}}
98
99\let\begin@example@O\example
100
101\def\example{\begingroup\catcode`\^^M\active\example@M}
102
103\newcommand\example@M[1][]{%
104  \def\rmA{#1}%
105  \ifx\rmA\empty
106    \def\next{\begin@example@O}%
107  \else
108    \def\next{\begin@example@T{#1}}%
109  \fi
110  \expandafter\endgroup\next
111}
112
113\def\begin@example@T#1{%
114  \par\bigbreak
115  \noindent\textit{\maybeaddadot{#1}}\par\vskip-\medskipamount\nobreak%
116  \begin@example@O
117}%
118
119
120%
121% Alinéas spéciaux
122%
123
124\newcommand\paracommand[1]{%
125  \par
126  \vskip 4em plus 1em minus 1em
127  \penalty -20
128  \relax
129  \begingroup
130  \markslongfalse
131  \marksouterfalse
132  \marksprimitivefalse
133  \toks0{}%
134  \let\TeX@orig\TeX
135  \def\long{\toksrappend\marks@l\to\toks0}%
136  \def\outer{\toksrappend\marks@o\to\toks0}%
137  \def\TeX{\toksrappend\marks@t\to\toks0}%
138  \let\cs@orig\cs
139  \def\cs##1{\gdef\currentcs{##1}\let\cs\cs@orig\cs{##1}}%
140  \def\fa##1{\LA{}\textit{##1}\RA}%
141  \dimen0=\hsize \advance\dimen0-6pt\relax
142  \noindent\colorbox{emphasize}{\makebox[\dimen0]{#1\hfill\commandmarks}}\par
143  \endgroup
144  \nobreak
145  \smallskip
146  \noindent
147  \ignorespaces
148}
149
150\def\commandmarks{%
151  \the\toks0
152  \let\next\relax
153  \ifmarkslong\let\next\commandmarks@A\fi
154  \ifmarksouter\let\next\commandmarks@A\fi
155  \ifmarksprimitive\let\next\commandmarks@A\fi
156  \next
157}
158
159\def\commandmarks@A{\footnotesize This is %
160\ifmarksouter
161  an outer \ifmarkslong long \fi
162\else
163  \ifmarkslong a long \fi
164\fi
165\ifmarksprimitive \TeX@orig\ primitive\else command\fi
166.}
167
168\def\marks@l{\markslongtrue}
169\def\marks@o{\marksoutertrue}
170\def\marks@t{\marksprimitivetrue}
171
172\newif\ifmarkslong
173\newif\ifmarksouter
174\newif\ifmarksprimitive
175
176\newcommand\paranamespace[1]{%
177  \begin{formalparagraph}{}\em
178  La bibliothèque réserve l'espace de noms privé~\texttt{#1}.%
179  \end{formalparagraph}%
180}
181
182\def\parafakepredicate{%
183  \begin{formalparagraph}{}\em
184  Cette procédure est un faux prédicat. Les faux prédicats sont
185  discutés dans la section~XXX.
186  \end{formalparagraph}%
187}
188
189\def\paraoutercatcode{%
190  \begin{formalparagraph}{}\em
191  Cette procédure manipule la table des %
192  codes de catégorie des caractères~\emph{(catcode table)}, il est %
193  donc recommandé que les procédures l'appelant soient %
194  marquées~\texttt{\string\outer}.%
195  \end{formalparagraph}%
196}
197