summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/show2e/show2e.dtx
blob: 0b2c2c43519ca49d8947e4bae82946f1d978e2ed (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
%
% \iffalse  /!\  this file contains non-ascii --  encoding is utf-8 /!\
%
%     show2e package by Manuel P\'egouri\'e-Gonnard <mpg@elzevir.fr>
%     --------------------------------------------------------------
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3c of this license
% or (at your option) any later version.  The latest version of this
% license is in:
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
% version 2006/05/20 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The current maintainer of this work is Manuel P\'egouri\'e-Gonnard.
%
% This work consists of the file show2e.dtx and the derived files
% show2e.sty, show2e.pdf and show2e-fr.pdf.
%
%
%<*gobble>
\ProvidesFile{show2e.dtx}
%</gobble>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{show2e}
%<*package>
% \fi
% \ProvidesFile{show2e.dtx}
  [2008/03/13 v1.0 \space \show variants for latex2e \space (mpg)]
% \iffalse
%</package>
% \fi
% \CheckSum{85}
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
% \iffalse
%<*gobble>
\begingroup
%</gobble>
%<*batchfile>
\input docstrip
\keepsilent
\preamble

show2e package by Manuel P\string\'egouri\string\'e-Gonnard %
<mpg@elzevir.fr>
This is a generated file. See show2e.dtx for license information.

\endpreamble
\askforoverwritefalse
%\generate{\file{show2e.ins}{\from{show2e.dtx}{batchfile}}}
%\generate{\file{show2e.drv}{\from{show2e.dtx}{driver}}}
\generate{\file{show2e.sty}{\from{show2e.dtx}{package}}}
\generate{\file{show2e-fr.drv}{\from{show2e.dtx}{pilote}}}
%</batchfile>
%<*gobble>
\endgroup
%</gobble>
%<*driver|pilote>
\documentclass[oneside, a4paper]{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[babel=true, expansion=false]{microtype}
\usepackage{fixltx2e}
\expandafter\newif\csname iffrenchdoc\endcsname % cachez ce if...
%<pilote>\frenchdoctrue
%</driver|pilote>
%<*gobble>
\iffrenchdoc
%</gobble>
%<*pilote>
\usepackage[lmargin=4.5cm, rmargin=3cm]{geometry}
\OnlyDescription
\usepackage[english, french]{babel}
\FrenchFootnotes \AddThinSpaceBeforeFootnotes
\newcommand*\eng[1]{\emph{\foreignlanguage{english}{#1}}}
\usepackage[bookmarks=false]{hyperref}
\hypersetup{%
  pdftitle=L'extension show2e
  pdfsubject=Une DESCRIPTION}
%</pilote>
%<*gobble>
\else
%</gobble>
%<*driver>
\AlsoImplementation
\usepackage[english]{babel}
\usepackage[bookmarks=false]{hyperref}
\hypersetup{%
  pdftitle=The show2e package,
  pdfsubject=A DESCRIPTION}
\settowidth\MacroIndent{\rmfamily\scriptsize 000\ }
\setlength\MacroTopsep{0pt}
\setcounter{tocdepth}{1}
%</driver>
%<*gobble>
\fi
%</gobble>
%<*driver|pilote>
\hypersetup{%
  colorlinks=true, linkcolor=black, urlcolor=black,
  pdfauthor=Manuel Pégourié-Gonnard}
\newcommand\file{\nolinkurl}
\newcommand\pf{\textsf}
\newcommand\optstar{\meta{$*$}}
\newcommand\topcs[1]{\texorpdfstring{\cs{#1}}{#1}}
\begin{document}
  \DocInput{show2e.dtx}
\end{document}
%</driver|pilote>
%<*package>
% \fi
%
% \GetFileInfo{show2e.dtx}
%
% \title{\iffrenchdoc L'extension \pf{show2e}\else The \pf{show2e} package\fi}
% \author{Manuel Pégourié-Gonnard\\ 
%   \href{mailto:mpg@elzevir.fr}{mpg@elzevir.fr}}
% \date{\fileversion\ (\filedate)}
% 
% \maketitle
%
% \iffrenchdoc\else
% \bigbreak\noindent
% \emph{Important note for French readers}: the file
% \file{show2e-fr.pdf} contains the same documenation in French.
% \fi
%
% \section{Introduction}
%
% \iffrenchdoc
%
% Cette toute petite extension a pour but de simplifier légèrement le
% déboguage, notamment interactif, en fournissant quelques variantes de
% |\show| adaptées aux objets introduits par \LaTeXe{} : commandes à
% arguments optionnels, commandes robustes, environnements.
%
% \else
%
% This small package aims at making debugging (esp.\@ in an interactive
% way) easier, by providing |\show| variants suited to \LaTeXe's
% commands (with optional arguments or robust) and environments.
%
% \fi
%
% \section{Usage}
% 
% \iffrenchdoc
%
% \DescribeMacro{\showcmd}
% La commande |\showcmd| sert à afficher une commande comme le ferait la
% primitive |\show| de \TeX, mais en effectuant en plus quelques tests
% pour savoir si la commande est une macro qui prend un argument
% optionnel (comme on peut en définir avec |\newcommand|), ou qui a été
% définie comme robuste avec |\DeclareRobustCommand|, ou ultérieurement
% rendue robuste par |\MakeRobust| (fourni par \pf{fixltx2e}). Dans ce
% cas, la commande utilise aussi une ou plusieurs macros interne, que
% |\showcmd| affichera automatiquement pour vous.
%
% \DescribeMacro{\showcs}
% \DescribeMacro{\showenv}
% La variante |\showcs| fonctionne de la même manière, mais prend comme
% argument le \emph{nom} de la commande entre accolades : les deux
% formes |\showcmd\truc| et |\showcs{truc}| sont donc équivalentes.
% Enfin, |\showenv| montre les definitions de début et de fin d'un
% environnement.
%
% \medbreak
%
% C'est tout pour la description des commandes. Il faut bien remarquer
% qu'elles ne sont pas infaillibles, et ne fonctionnent qu'avec les
% commandes crées par les macros standard de \LaTeXe{} (et celles de
% \pf{xargs}, d'ailleurs) : elles n'essayent pas de prendre en compte
% des usages directs de |\@ifnextchar|, ni même de |\@ifstar| (pour le
% moment).
% 
% Pour les curieux, le code commenté apparaît à la fin de la version
% anglaise de cette documentation
%
% \begin{center}\large
% C'est tout pour cette fois ! \\
% Amusez-vous bien avec \LaTeX{} !
% \end{center}
%
% \else
% 
% \DescribeMacro{\showcmd}
% The |\showcmd| command displays a command like \TeX's |\show|, but
% with a little bonus: it also checks if the macros takes an optional
% argument (like some commands defined with |\newcommand| do), or was
% made robust by using |\DeclareRobustCommand| or \pf{fixltx2e}'s
% |\MakeRobust|. Such commands use other(s) internal command(s), which
% |\showcmd| will also display for you.
%
% \DescribeMacro{\showcs}
% \DescribeMacro{\showenv}
% The |\showcs| command does the same thing as |\showcmd|, but takes the
% command's \emph{name} as its argument: |\showcmd\truc| is equivalent
% to |\showcs{truc}|. Finally, the |\showenv| command does the same for
% environments.
%
% \medbreak
%
% The previous commands will only work on simple commands defined with
% standard \LaTeXe{} commands (or, by the way, with \pf{xargs}): they
% do not try to guess such things as a direct use of |\@ifnextchar|, or
% even |\@ifstar| (at the moment).
%
% \fi
%
% \StopEventually{}
%
% \section{Implementation}
%
% \begin{macro}{\showcmd}
% The |\showcmd| macro just checks to beginning of the meaning of is
% argument, in order to decide if there are any internal macro to
% show too. It also sets a default value for |\escapechar| for sake of
% readability.
%    \begin{macrocode}
\newcommand* \showcmd [1] {%
  \begingroup \escapechar92
  \show#1%
  \showe@if@meaning@prefix@NnT #1 {\x@protect} 
    {\showe@show@space@macro@N #1}%
  \showe@if@meaning@prefix@NnT #1 {\protect}
    {\showe@show@space@macro@N #1}%
  \showe@if@meaning@prefix@NoT #1 {\string\@protected@testopt}
    {\showe@show@backslash@macro@N #1}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\showcs}
% \begin{macro}{\showenv}
% The two variants are only wrappers for |\showcmd|.
%    \begin{macrocode}
\newcommand* \showcs [1] {%
  \expandafter \showcmd \csname#1\endcsname}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand* \showenv [1] {%
  \showcs{#1}%
  \expandafter \show\csname end#1\endcsname}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\showe@show@backslash@macro@N}
% \begin{macro}{\showe@show@space@macro@N}
% Macros for showing the internal macros found, either with |\show| or
% with |\showcmd|.
%    \begin{macrocode}
\newcommand* \showe@show@backslash@macro@N [1] {%
  \expandafter \show \csname\string#1\endcsname}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand* \showe@show@space@macro@N [1] {%
  \begingroup \escapechar\m@ne \expandafter\endgroup
  \expandafter \showcmd \csname\string#1 \endcsname}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\showe@if@meaning@prefix@NnT}
% \begin{macro}{\showe@if@meaning@prefix@NoT}
% Check if the second argument is a prefix for the meaning of the first.
% Variant expanding the second argument once before (named in l3 style).
%    \begin{macrocode}
\newcommand* \showe@if@meaning@prefix@NnT [2] {%
  \def \@tempa {#2}%
  \showe@if@prefix@ooT {\meaning #1} {\meaning \@tempa}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand* \showe@if@meaning@prefix@NoT [2] {%
  \expandafter \showe@if@meaning@prefix@NnT
  \expandafter #1%
  \expandafter {#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\showe@if@prefix@nnT}
% \begin{macro}{\showe@if@prefix@ooT}
% Check if string 2 is a prefix of string 1. Variant expanding the two
% arguments once before checking.
%    \begin{macrocode}
\newcommand* \showe@if@prefix@nnT [2] {%
  \def \@tempa ##1#2##2\@nil {%
    \ifx\empty##2\empty
      \expandafter\@gobble
    \else
      \expandafter\@firstofone
    \fi}%
  \@tempa#1#2\@nil}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand* \showe@if@prefix@ooT [2] {%
  \edef \@tempa {{#1}{#2}}%
  \expandafter \showe@if@prefix@nnT\@tempa}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \bigskip
% \begin{center}\Large
% That's all folks!\\
% Happy \TeX ing!
% \end{center}
%
% \Finale
%
% \iffalse
%</package>
%<*batchfile>
% \fi
% \begingroup\obeyspaces
% \typeout{*****************************************************}
% \typeout{*                                                   *}
% \typeout{* To finish the installation you have to move the   *}
% \typeout{* following file into a directory searched by TeX:  *}
% \typeout{*                                                   *}
% \typeout{*      show2e.sty                                   *}
% \typeout{*                                                   *}
% \typeout{* Documentation is in show2e.dvi or show2e.pdf      *}
% \typeout{*                                                   *}
% \typeout{* To produce the french documentation, run          *}
% \typeout{*      (pdf)latex show2e-fr.drv                     *}
% \typeout{*                                                   *}
% \typeout{* Happy TeXing!                                     *}
% \typeout{*                                                   *}
% \typeout{*****************************************************}
% \endgroup
% \iffalse
%</batchfile>
% \fi
\endinput