Debian Codegraph @

texmf-dist/source/latex/newverbs/newverbs.dtx

raw
1 % \iffalse meta-comment
2 %<=*COPYRIGHT>
3 %% Copyright (c) 2012-2022 by Martin Scharrer <[email protected]>
4 %% --------------------------------------------------------------------
5 %% This work may be distributed and/or modified under the
6 %% conditions of the LaTeX Project Public License, either version 1.3
7 %% of this license or (at your option) any later version.
8 %% The latest version of this license is in
9 %% http://www.latex-project.org/lppl.txt
10 %% and version 1.3 or later is part of all distributions of LaTeX
11 %% version 2005/12/01 or later.
12 %%
13 %% This work has the LPPL maintenance status `maintained'.
14 %%
15 %% The Current Maintainer of this work is Martin Scharrer.
16 %%
17 %% This work consists of the files newverbs.dtx and newverbs.ins
18 %% and the derived file newverbs.sty.
19 %<=/COPYRIGHT>
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{newverbs.dtx}[%
25 %<=*DATE>
26 2022/10/25
27 %<=/DATE>
28 %<=*VERSION>
29 v1.6a
30 %<=/VERSION>
31 newverbs DTX file]
32 \documentclass{ydoc}
33 \GetFileInfo{newverbs.dtx}
34 \usepackage{newverbs}[\filedate]
35
36 %\EnableCrossrefs
37 %\CodelineIndex
38 %\RecordChanges
39 \begin{document}
40 \DocInput{newverbs.dtx}
41 %\PrintChanges
42 %\PrintIndex
43 \end{document}
44 %</driver>
45 % \fi
46 %
47 % \CheckSum{465}
48 %
49 % \CharacterTable
50 % {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
51 % 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
52 % Digits \0\1\2\3\4\5\6\7\8\9
53 % Exclamation \! Double quote \" Hash (number) \#
54 % Dollar \$ Percent \% Ampersand \&
55 % Acute accent \' Left paren \( Right paren \)
56 % Asterisk \* Plus \+ Comma \,
57 % Minus \- Point \. Solidus \/
58 % Colon \: Semicolon \; Less than \<
59 % Equals \= Greater than \> Question mark \?
60 % Commercial at \@ Left bracket \[ Backslash \\
61 % Right bracket \] Circumflex \^ Underscore \_
62 % Grave accent \` Left brace \{ Vertical bar \|
63 % Right brace \} Tilde \~}
64 %
65 %
66 % \changes{v1.0}{2010/04/05}{Initial version}
67 % \changes{v1.1}{2010/04/13}{Added usage of 'csquotes' macros if loaded.}
68 % \changes{v1.2}{2011/02/16}{Added support for 'tabularx' environments.}
69 % \changes{v1.2a}{2011/03/19}{Removed spurious spaces.}
70 % \changes{v1.3}{2011/07/24}{Added macros to collect verbatim arguments.}
71 % \changes{v1.4}{2019/09/09}{Added several suggested changes.}
72 % \changes{v1.5}{2020/09/02}{Added support for mathmode.}
73 % \changes{v1.6}{2021/01/06}{Changed \cs{Verbdef} to define robust commands.}
74 % \changes{v1.6a}{2022/10/25}{Updated repository URL. Added DEPENDS.txt file.}
75 %
76 % \DoNotIndex{\newcommand,\newenvironment,\providecommand}
77 %
78 % \GetFileInfo{newverbs.dtx}
79 % \author{Martin Scharrer}
80 % \email{[email protected]}
81 % \github{MartinScharrer/newverbs}
82 % \maketitle
83 %
84 % \begin{abstract}
85 % This package allows the definition of \cs{verb} variants which add \TeX\ code before and after the verbatim text.
86 % When used together with the \pkg{shortvrb} package it allows the definition of short verbatim characters which use this variants
87 % instead of the normal \cs{verb}.
88 % \end{abstract}
89 %
90 % \section{Usage}
91 %
92 % \subsection{Defining new variants of \cs{verb}}
93 %
94 % \DescribeMacro\newverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
95 % \DescribeMacro\renewverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
96 % \DescribeMacro\provideverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
97 % This macros allow the definition of \cs{verb} variants.
98 % The verbatim content is first processed using \meta{\textbackslash verbmacro} which defaults to \cs{verb}, then the
99 % given \TeX\ code is added before and afterwards.
100 % The three definition macros use |\newcommand*|, |\renewcommand*| and |\providecommand*| internally to define \meta{\textbackslash macro}, respectively.
101 % Afterwards \meta{\textbackslash macro} can be used like \cs{verb}.
102 % The star version of \meta{\textbackslash macro} will use \meta{\textbackslash verbmacro}|*| (default: \cs{verb}|*|).
103 %
104 % See the implementation of \cs{qverb} in section~\ref{sec:impl} for an example.
105 %
106 %
107 % \subsection{Provided \cs{verb} variants}
108 %
109 % Two \cs{verb} variants are provided (i.e. with \cs{provideverbcommand}) by default.
110 %
111 % \DescribeMacro\qverb<char><verbatim material><char>
112 % This macro adds quote characters around the verbatim material.
113 % Two macros are used to insert the quotes: \cs{qverbbeginquote} (``) and \cs{qverbendquote} ('').
114 % They can be redefined by the user if required. If the \pkg{csquotes} package was loaded beforehand
115 % the above macros use its macros \cs{openautoquote} and \cs{closeautoquote} to take advantage of the language
116 % dependent quotation marks. See the manual of \pkg{csquotes} for more details.
117 %
118 % Using \Macro\qverb<char><verbatim material><char> is equal to \\
119 % \Macro\qverbbeginquote\AlsoMacro\verb<char><verbatim material><char>\AlsoMacro\qverbendquote, or\\
120 % \MacroArgs'`'\AlsoMacro\verb<char><verbatim material><char>''
121 % when the default definition of the quote macros is used.
122 %
123 % \DescribeMacro\fverb<char><verbatim material><char>
124 % This macro adds a frame (|\fbox{}|) around the verbatim text (|\fverb+$&^_%$+| $\to$ \fverb+$&^_$+).
125 % A \TeX\ box is used to store the content first, then the box is framed.
126 % The user can define similar command using the following code:\\
127 % {\ttfamily
128 % \hspace*{2.5em}|\newverbcommand{\myverb}{\begin{lrbox}{\verbbox}}|\\
129 % \hspace*{10em}|{\end{lrbox}\mycommand{\usebox{\verbbox}}}|}\\
130 % The temporary box \cs{verbbox} is only provided inside a |\...verbcommand|.
131 %
132 % \subsection{Using \cs{verb} variants with short verbatim character}
133 %
134 % \DescribeMacro\MakeSpecialShortVerb {<\textbackslash macro>}{\textbackslash\meta{char}}
135 % \DescribeMacro\MakeSpecialShortVerb*{<\textbackslash macro>}{\textbackslash\meta{char}}
136 % This package also defines a special version of the \cs{MakeShortVerb} macro from the \pkg{shortvrb} package.
137 % The orignal command \Macro\MakeShortVerb*{\textbackslash\meta{char}} changes the meaning of \meta{char} so that
138 % \MacroArgs<char><verbatim material><char>\ is a shorter alternative to
139 % \Macro\verb*<char><verbatim material><char>.
140 %
141 % The new macro \Macro\MakeSpecialShortVerb*{\textbackslash\meta{verb variant}}{\textbackslash\meta{char}} does the same, but
142 % instead of \Macro\verb*\relax\relax\ it uses a \MacroArgs'\'<verb variant>*\relax which needs to be defined using \cs{newverbcommand}.
143 % The package \pkg{shortvrb} must be installed in order to make this macro work. It is loaded automatically by \pkg{newverbs}.
144 %
145 % The special meaning of \meta{char} can be removed using \pkg{shortvrb}'s \cs{DeleteShortVerb}, i.e.\ the same way as for
146 % characters defined with the normal \cs{MakeShortVerb}.
147 % If a character was already made a short verbatim character it must be ``deleted'' before it can be redefined by \cs{MakeShortVerb} or
148 % \cs{MakeSpecialShortVerb}.
149 %
150 % \bigskip\noindent\textbf{Examples:}\\
151 % |\MakeSpecialShortVerb{\qverb}{\"}| will make `|"|' a short, quoting verbatim character: |"$^&$"| $\to$ "$^&$".\\
152 % |\DeleteShortVerb{\"}\MakeSpecialShortVerb{\fverb}{\"}| will change it definition to use \cs{fverb}: \fverb+$^&$+.
153 %
154 %
155 % \DescribeMacro\collectverb{<code>}<char><verbatim material><char>
156 % \DescribeMacro\collectverb*{<code>}<char><verbatim material><char>
157 % \DescribeMacro\collectverb{<code>}{<verbatim material>}
158 % \DescribeMacro\collectverb*{<code>}{<verbatim material>}
159 % This macro is supposed to be used with its \marg{code} argument at the end of user or package macro which want to typeset verbatim material.
160 % It will collect everything between the following \meta{char} and its next occurrence as verbatim material.
161 % An exception is if the following \meta{char} is `|{|', then `|}|' is taken as the end \meta{char} to simulate a normal argument to increase user friendliness.
162 % Afterwards \meta{code} is expanded with \marg{verbatim material} direct behind it. The macro ensures proper font settings to typeset the verbatim material.
163 % For this, a group is opened before the material is collected and closed directly after the given code is processed. ^^A \MacroArgs<code>{<verbatim material>}\AlsoMacro\endgroup.
164 % Therefore all changes done by the \meta{code} are local and the material should be typeset directly.
165 % (In special cases when the group is disruptive, \meta{code} can be a macro which reads both the verbatim material and the \Macro\endgroup as two arguments.
166 % However, then special care must be taken to use the correct font and some of the special characters may be active but have lost their definition.)
167 % The starred version will make spaces appear as `\collectverb*{}: :' instead of displaying them as normal spaces.
168 %
169 %
170 % \DescribeMacro\Collectverb{<code>}<char><verbatim material><char>
171 % \DescribeMacro\Collectverb*{<code>}<char><verbatim material><char>
172 % \DescribeMacro\Collectverb{<code>}{<verbatim material>}
173 % \DescribeMacro\Collectverb*{<code>}{<verbatim material>}
174 % This macro is supposed to be used with its \marg{code} argument at the end of user or package macro which want to collect plain verbatim material suitable to be
175 % written in auxiliary files or log messages.
176 % It will collect everything between the following \meta{char} and its next occurrence as verbatim material without adjusting the font or defining any characters in a special way (besides being verbatim).
177 % The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces.
178 % An exception is if the following \meta{char} is `|{|', then `|}|' is taken as the end \meta{char} to simulate a normal argument to increase user friendliness.
179 % Afterwards \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code.
180 % Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually.
181 %
182 %
183 %
184 % \DescribeMacro\collectverbenv{<code>}
185 % \DescribeMacro\collectverbenv*{<code>}
186 % This macro is supposed to be used with its \marg{code} argument at the end of the begin-code of an user or package environment definition.
187 % It then collects the content of the environment as verbatim material and feeds it as an argument to the provided \meta{code} like \Macro\collectverb does
188 % (see there for further details which also apply here).
189 % This has the following limitations:
190 % When used the \Macro\begin of the environment must end with a line break, i.e.\ the source line must not include any other material afterwards.
191 % If the environment is defined with arguments, which is supported, the line break must be after the arguments.
192 % The \Macro\end of the macro must be at the beginning of an own source code line.
193 % If this conditions are not met incorrect results or an error may occur. Currently trailing material on the \Macro\begin line is simply ignored, but this
194 % behaviour might change in future versions.
195 %
196 % The starred version will make the spaces inside the environment appear as `\collectverb*{}: :'.
197 %
198 % \noindent Example usage:\\
199 % \leavevmode\noindent\bgroup\footnotesize
200 % |\newenvironment{myenv}{\maybesomeothercode\collectverbenv{\mycmd}}{\someendcode}| \\
201 %
202 %
203 % \DescribeMacro\Collectverbenv{<code>}
204 % \DescribeMacro\Collectverbenv*{<code>}
205 % This macro works like \Macro\collectverbenv but collects the environment content as plain verbatim material suitable to be
206 % written in auxiliary files or log messages.
207 % After collecting the environment the \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code.
208 % Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually.
209 %
210 % The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces.
211 %
212 %
213 % \DescribeMacro\newverbsfont
214 % Macro which activates the font used by the \pkg{newverbs} package for the verbatim text.
215 % This macro can be used manually if verbatim material collected with \Macro\Collectverb or \Macro\Collectverbenv should be typeset afterall.
216 %
217 % \DescribeMacro\verbdef<\textbackslash macro><char><verbatim material><char>
218 % \DescribeMacro\verbdef*<\textbackslash macro><char><verbatim material><char>
219 % \DescribeMacro\verbdef<\textbackslash macro>{<verbatim material>}
220 % \DescribeMacro\verbdef*<\textbackslash macro>{<verbatim material>}
221 % This macro defines the \meta{\textbackslash macro} as a robust macro which typesets the \meta{verbatim material} in the usual verbatim font.
222 % For this the material is placed in a brace group with \Macro\newverbsfont. If a different font is wanted, this macro can be redefined locally.
223 %
224 % If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use
225 % \Macro\newcommand{\textbackslash macro}{} just before the \Macro\verbdef.
226 %
227 % Note that this macro is also provided by the \pkg{verbdef} package. If that package is loaded as well it definition of this macro is used,
228 % independent on the order of loading the two packages.
229 %
230 %
231 % \DescribeMacro\Verbdef<\textbackslash macro><char><verbatim material><char>
232 % \DescribeMacro\Verbdef*<\textbackslash macro><char><verbatim material><char>
233 % \DescribeMacro\Verbdef<\textbackslash macro>{<verbatim material>}
234 % \DescribeMacro\Verbdef*<\textbackslash macro>{<verbatim material>}
235 % This macro uses \Macro\Collectverb internally to define \meta{\textbackslash macro} as the plain \meta{verbatim material}.
236 % This can be used to define macros for special characters, so these can be used in error or warning messages or be written into auxiliary files.
237 %
238 % If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use
239 % \Macro\newcommand{\textbackslash macro}{} just before the \Macro\Verbdef.
240 %
241 % Note that for maximum flexibility the such defined macros are not defined as robust macros. Therefore using them inside sectioning commands they should
242 % be protected using \Macro\protect to avoid syntax issues in the |.aux| file due to verbatim characters.
243 %
244 %
245 % \section{Compatibility with other verbatim packages}
246 % The compatibility with other verbatim packages is not tested yet. This package relies on the normal internal definition of \cs{verb}
247 % and \cs{MakeShortVerb}. Any package which changes these might break this package.
248 % Users which encounter incompatibilities should not hesitate to contact the package author (with details!).
249 %
250 % Since v1.2 from 2011/02/16 the new verbatim macros and their short versions can be used inside \env{tabularx} environments.
251 % This package patches an internal macro of \pkg{tabularx} to achieve this compatibility.
252 %
253 % \StopEventually{}
254 % \section{Implementation}
255 %
256 % \iffalse
257 %<*newverbs.sty>
258 % \fi
259 % \begin{macrocode}
260 %<!COPYRIGHT>
261 \ProvidesPackage{newverbs}[%
262 %<!DATE>
263 %<!VERSION>
264 %<*DRIVER>
265 2099/01/01 develop
266 %</DRIVER>
267 Define new 'verb' commands and short verb. characters]
268 % \end{macrocode}
269 %
270 % \subsection{Verb Definition Commands}
271 %
272 % \begin{macro}{\newverbcommand}
273 % \begin{macro}{\renewverbcommand}
274 % \begin{macro}{\provideverbcommand}
275 % This macro calls the real macro with the to be used definition macro.
276 % \begin{macrocode}
277 \newcommand*\newverbcommand{\new@verbcommand\newcommand}
278 \newcommand*\renewverbcommand{\new@verbcommand\renewcommand}
279 \newcommand*\provideverbcommand{\new@verbcommand\providecommand}
280 % \end{macrocode}
281 % \end{macro}
282 % \end{macro}
283 % \end{macro}
284 %
285 % \begin{macro}{\new@verbcommand}[2]{underlying definition macro}{macro to be defined}
286 % Checks for optional argument and calls \cs{new@@verbcommand} accordingly.
287 % \begin{macrocode}
288 \def\new@verbcommand#1#2{%
289 \@ifnextchar[%
290 {\new@@verbcommand{#1}{#2}}%
291 {\new@@verbcommand{#1}{#2}[\verb]}%
292 }
293 % \end{macrocode}
294 % \end{macro}
295 %
296 % \begin{macro}{\new@verbcommand}[5]{underlying definition macro}{macro to define}{verb macro to be used}{code before}{code after}
297 % The trailing code is inserted by patching \cs{verb@egroup} which is called by \cs{verb}
298 % after the verbatim content.
299 % \begin{macrocode}
300 \let\newverbs@end\@empty
301 \def\new@@verbcommand#1#2[#3]#4#5{%
302 #1*#2{%
303 \relax\ifmmode\hbox\else\leavevmode\null\fi
304 \bgroup
305 \newverbcommand@settings
306 \ifx\newverbs@end\@empty
307 \expandafter\def\expandafter\verb@egroup\expandafter{\verb@egroup\newverbs@end}%
308 \fi
309 \begingroup\def\@tempa{#5}%
310 \expandafter\expandafter\expandafter\endgroup
311 \expandafter\expandafter\expandafter\def
312 \expandafter\expandafter\expandafter\newverbs@end
313 \expandafter\expandafter\expandafter{\expandafter\@tempa\newverbs@end\egroup}%
314 \def\newverbs@txend{#5\egroup}%
315 \verbatim@font\let\verbatim@font\relax
316 #4#3%
317 }%
318 }
319 % \end{macrocode}
320 % \end{macro}
321 %
322 % \begin{macro}{\newverbs@tabularxsupport}
323 % Enables support for the new verbatim macros inside \env{tabularx} environments.
324 % This environment defines its own almost-verbatim form of |\verb|%^^A|
325 % which lacks the end-macro we patch above. The following code inserts such
326 % an end-macro.
327 % \begin{macrocode}
328 \def\newverbs@tabularxsupport{%
329 \begingroup
330 \def\origa@TX@vb##1{\def\@tempa####1##1{\toks@{####1}\edef\@tempa{\the\toks@}%
331 \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
332 \def\origb@TX@vb##1{\def\@tempa####1##1{\toks@{####1}\edef\@tempa{\the\toks@}%
333 \expandafter\TX@v\meaning\@tempa\\\\\ifnum0=`{\fi}}\@tempa!}%
334 \ifcase0%
335 \ifx\TX@vb\origa@TX@vb 1\else
336 \ifx\TX@vb\origb@TX@vb 1\fi\fi
337 \relax
338 \endgroup
339 \PackageWarning{newverbs}{Couldn't patch 'TX@vb' macro of the 'tabularx' package. Definition unknown.}%
340 \else
341 \endgroup
342 \PackageInfo{newverbs}{Patching 'TX@vb' macro of the 'tabularx' package.}%
343 \def\TX@vb##1{\def\@tempa####1##1{\toks@{####1}\edef\@tempa{\the\toks@}%
344 \expandafter\TX@v\meaning\@tempa\\\\\ifnum0=`{\fi}\newverbs@txend}\@tempa!}%
345 \fi
346 \let\newverbs@tabularxsupport\relax
347 }
348 % \end{macrocode}
349 % The end-macro is initially empty and is set for every call of a new verb macro.
350 % \begin{macrocode}
351 \def\newverbs@txend{}
352 % \end{macrocode}
353 % The support is activated either now or at the begin of the document if the \pkg{tabularx} is loaded.
354 % \begin{macrocode}
355 \@ifpackageloaded{tabularx}{%
356 \newverbs@tabularxsupport
357 }{%
358 \AtBeginDocument{\@ifpackageloaded{tabularx}{\newverbs@tabularxsupport}{}}%
359 }
360 % \end{macrocode}
361 % \end{macro}
362 %
363 % \begin{macro}{\newverbcommand@settings}
364 % Some settings required for all new \cs{verb}-like commands.
365 % The original end group macro from \cs{verb} is saved away.
366 % Also the `temp box a' is provided with a user friendly name.
367 % \begin{macrocode}
368 \def\newverbcommand@settings{%
369 \let\verb@orig@egroup\verb@egroup
370 \let\verbbox\@tempboxa
371 }
372 % \end{macrocode}
373 % \end{macro}
374 %
375 % \subsection{Provided New Verb Commands}\label{sec:impl}
376 %
377 % \begin{macro}{\qverb}
378 % Quoting version of \cs{verb}. Places a quote character before and after the verbatim content: "verb".
379 % \begin{macrocode}
380 \provideverbcommand{\qverb}{\qverbbeginquote}{\qverbendquote}
381 % \end{macrocode}
382 % \end{macro}
383 %
384 % \begin{macro}{\qverbbeginquote}
385 % \begin{macro}{\qverbendquote}
386 % This macros insert the actual quotes. They can be redefined by the user to contain the required quotes.
387 % If available the quoting macros of \pkg{csquotes} are used.
388 % \changes{v1.1}{2010/04/13}{Added usage of 'csquotes' macros if loaded.}
389 % \begin{macrocode}
390 \@ifundefined{openinnerquote}{%
391 \def\qverbbeginquote{``}%
392 \def\qverbendquote{''}%
393 }{%
394 \def\qverbbeginquote{\openautoquote}%
395 \def\qverbendquote{\closeautoquote}%
396 }
397 % \end{macrocode}
398 % \end{macro}
399 % \end{macro}
400 %
401 % \begin{macro}{\fverb}
402 % A framed version of \cs{verb}. Stores the verbatim content first into a box. Then the box content is framed.
403 % \begin{macrocode}
404 \newverbcommand{\fverb}
405 {\setbox\verbbox\hbox\bgroup\color@setgroup}
406 {\color@endgroup\egroup\fbox{\box\verbbox}}
407 % \end{macrocode}
408 % \end{macro}
409 %
410 %
411 % \subsection{Make Special Short Verbatim Characters}
412 %
413 % \begin{macrocode}
414 \RequirePackage{shortvrb}
415 % \end{macrocode}
416 %
417 % \begin{macro}{\MakeShortVerb}
418 % \begin{macrocode}
419 \def\MakeShortVerb{%
420 \@ifstar
421 {\newverbs@MakeShortVerb*}%
422 {\newverbs@MakeShortVerb{}}%
423 }
424 % \end{macrocode}
425 % \end{macro}
426 %
427 % \begin{macro}{\newverbs@MakeShortVerb}[1]{star or empty}
428 % \begin{macrocode}
429 \def\newverbs@MakeShortVerb#1{%
430 \@ifnextchar[%
431 {\newverbs@@MakeShortVerb{#1}}%
432 {\@MakeSpecialShortVerb{#1}{\verb}}%
433 }
434 % \end{macrocode}
435 % \end{macro}
436 %
437 % \begin{macro}{\newverbs@@MakeShortVerb}[2]{star or empty}{verbatim macro}
438 % \begin{macrocode}
439 \def\newverbs@@MakeShortVerb#1[#2]{%
440 \@MakeSpecialShortVerb{#1}{#2}%
441 }
442 % \end{macrocode}
443 % \end{macro}
444 %
445 % \begin{macro}{\@MakeSpecialShortVerb}[3]{star or empty}{verbatim macro}{escaped short verbatim character}
446 % Uses the definition of \cs{MakeShortVerb} from \pkg{shortvrb} except with \cs{verb} replaced with the first argument.
447 % The last argument is then read by \cs{@MakeShortVerb}.
448 % \begin{macrocode}
449 \def\@MakeSpecialShortVerb#1#2#3{%
450 %\expandafter\ifx\csname cc\string#3\endcsname\relax
451 %\else
452 % \DeleteShortVerb{#3}%
453 %\fi
454 \def\@shortvrbdef{#2#1}%
455 \@MakeShortVerb{#3}%
456 }
457 % \end{macrocode}
458 % \end{macro}
459 %
460 % \begin{macro}{\MakeSpecialShortVerb}
461 % Checks for the starred version and calls \cs{@MakeSpecialShortVerb} appropriately. The star needs to be added again
462 % as \cs{@ifstar} removes it.
463 % \begin{macrocode}
464 \newcommand*\MakeSpecialShortVerb{%
465 \@ifstar
466 {\@MakeSpecialShortVerb{*}}%
467 {\@MakeSpecialShortVerb{}}%
468 }
469 % \end{macrocode}
470 % \end{macro}
471 %
472 %% \subsection{Collect verbatim argument}
473 %
474 % \begin{macro}{\collectverb}
475 % Collects verbatim text which can be typeset.
476 % Checks for an existing star.
477 % \begin{macrocode}
478 \newcommand*\collectverb{%
479 \begingroup
480 \verbatim@font
481 \@ifstar
482 \@scollectverb
483 \@collectverb
484 }
485 % \end{macrocode}
486 % \end{macro}
487 %
488 %
489 % \begin{macro}{\@collectverb}[1]{<code>}
490 % Changes catcodes and ensures that spaces are displayed normally.
491 % \begin{macrocode}
492 \def\@collectverb#1{%
493 \verb@eol@error
494 \let\do\@makeother
495 \dospecials
496 \@vobeyspaces
497 \frenchspacing
498 \@noligs
499 \@@collectverb{#1}%
500 }
501 % \end{macrocode}
502 % \end{macro}
503 %
504 %
505 % \begin{macro}{\@scollectverb}[1]{<code>}
506 % Changes catcodes.
507 % \begin{macrocode}
508 \def\@scollectverb#1{%
509 \verb@eol@error
510 \let\do\@makeother
511 \dospecials
512 \@noligs
513 \@@collectverb{#1}%
514 }
515 % \end{macrocode}
516 % \end{macro}
517 %
518 %
519 % \begin{macro}{\@@collectverb}[2]{<code>}{<char>}
520 % Defines \Macro\@@@collectverb to read everything to the next occurrence of \meta{char}
521 % and feed it to the given \meta{code}.
522 % \begin{macrocode}
523 \def\@@collectverb#1#2{%
524 \ifnum`#2=`\{%
525 \catcode`\}\active
526 \else
527 \catcode`#2\active
528 \fi
529 \begingroup
530 \ifnum`#2=`\{%
531 \lccode`\~`\}%
532 \else
533 \lccode`\~`#2%
534 \fi
535 \lowercase{\endgroup
536 \def\@@@collectverb##1~}{#1{##1}\endgroup}%
537 \@@@collectverb
538 }
539 % \end{macrocode}
540 % \end{macro}
541 %
542 %
543 % \begin{macro}{\collectverbenv}
544 % Collects verbatim text which can be typeset.
545 % Checks for an existing star.
546 % \begin{macrocode}
547 \newcommand*\collectverbenv{%
548 \begingroup
549 \verbatim@font
550 \@ifstar
551 \@scollectverbenv
552 \@collectverbenv
553 }
554 % \end{macrocode}
555 % \end{macro}
556 %
557 %
558 % \begin{macro}{\@collectverbenv}[1]{<code>}
559 % Changes catcodes and ensures that spaces are displayed normally.
560 % \begin{macrocode}
561 \def\@collectverbenv#1{%
562 \newverb@catcodes
563 \@vobeyspaces
564 \frenchspacing
565 \@noligs
566 \expandafter\@@collectverbenv\expandafter{\@currenvir}{#1}%
567 }
568 % \end{macrocode}
569 % \end{macro}
570 %
571 %
572 % \begin{macro}{\@scollectverbenv}[1]{<code>}
573 % Changes catcodes.
574 % \begin{macrocode}
575 \def\@scollectverbenv#1{%
576 \newverb@catcodes
577 \@noligs
578 \expandafter\@@collectverbenv\expandafter{\@currenvir}{#1}%
579 }
580 % \end{macrocode}
581 % \end{macro}
582 %
583 %
584 % \begin{macro}{\@@collectverbenv}[2]{<envname>}{<code>}
585 % \begin{macrocode}
586 \begingroup
587 \catcode`\|=0
588 \catcode`\(=1
589 \catcode`\)=2
590 \@makeother\{
591 \@makeother\}
592 \@makeother\\
593 |catcode`|^^M=|active%
594 |gdef|@@collectverbenv#1#2(%
595 |long|def|@@@collectverb##1^^M##2^^M\end{#1}(#2(##2)|endgroup|end(#1))%
596 |@@@collectverb%
597 )%
598 |endgroup%
599 % \end{macrocode}
600 % \end{macro}
601 %
602 % \begin{macro}{\Collectverb}
603 % Collects argument as plain verbatim and feeds it to the given code.
604 % The text is suitable to be printed to auxiliary files.
605 % \begin{macrocode}
606 \newcommand*\Collectverb{%
607 \begingroup
608 \@ifstar
609 \@sCollectverb
610 \@Collectverb
611 }
612 % \end{macrocode}
613 % \end{macro}
614 %
615 %
616 % \begin{macro}{\@Collectverb}[1]{<code to be executed afterwards>}
617 % \begin{macrocode}
618 \def\@Collectverb#1{%
619 \verb@eol@error
620 \let\do\@makeother
621 \dospecials
622 \obeyspaces
623 \@@Collectverb{#1}%
624 }
625 % \end{macrocode}
626 % \end{macro}
627 %
628 %
629 % \begin{macro}{\@sCollectverb}[1]{<code to be executed afterwards>}
630 % \begin{macrocode}
631 \def\@sCollectverb#1{%
632 \verb@eol@error
633 \let\do\@makeother
634 \dospecials
635 \@@Collectverb{#1}%
636 }
637 % \end{macrocode}
638 % \end{macro}
639 %
640 %
641 % \begin{macro}{\@@Collectverb}[2]{<code to be executed afterwards>}{<delimiter character>}
642 % \begin{macrocode}
643 \def\@@Collectverb#1#2{%
644 \ifnum`#2=`\{%
645 \catcode`\}\active
646 \else
647 \catcode`#2\active
648 \fi
649 \begingroup
650 \ifnum`#2=`\{%
651 \lccode`\~`\}%
652 \else
653 \lccode`\~`#2%
654 \fi
655 \lowercase{\endgroup
656 \def\@@@Collectverb##1~}{\endgroup#1{##1}}%
657 \@@@Collectverb
658 }
659 % \end{macrocode}
660 % \end{macro}
661 %
662 %
663 % \begin{macro}{\Collectverbenv}
664 % Collects environment content as plain verbatim and feeds it to the given code.
665 % The text is suitable to be printed to auxiliary files.
666 % \begin{macrocode}
667 \newcommand*\Collectverbenv{%
668 \begingroup
669 \@ifstar
670 \@sCollectverbenv
671 \@Collectverbenv
672 }
673 % \end{macrocode}
674 % \end{macro}
675 %
676 %
677 % \begin{macro}{\@Collectverbenv}[1]{<code to be executed afterwards>}
678 % \begin{macrocode}
679 \def\@Collectverbenv#1{%
680 \newverb@catcodes
681 \obeyspaces
682 \expandafter\@@Collectverbenv\expandafter{\@currenvir}{#1}%
683 }
684 % \end{macrocode}
685 % \end{macro}
686 %
687 %
688 % \begin{macro}{\newverb@catcodes}
689 % \begin{macrocode}
690 \begingroup
691 \catcode`\^^I=\active
692 \gdef\newverb@catcodes{%
693 \let\do\@makeother
694 \dospecials
695 \obeylines
696 \endlinechar=13
697 \catcode`\^^I=\active
698 \def^^I{\newverb@tab}%
699 }
700 \gdef^^I{\newverb@tab}%
701 \endgroup
702 % \end{macrocode}
703 % \end{macro}
704 %
705 %
706 % \begin{macro}{\newverb@tab}
707 % \begin{macrocode}
708 \edef\newverb@tab{\space}%\space\space\space}
709 % \end{macrocode}
710 % \end{macro}
711 %
712 %
713 % \begin{macro}{\@sCollectverbenv}[1]{<code to be executed afterwards>}
714 % \begin{macrocode}
715 \def\@sCollectverbenv#1{%
716 \newverb@catcodes
717 \expandafter\@@Collectverbenv\expandafter{\@currenvir}{#1}%
718 }
719 % \end{macrocode}
720 % \end{macro}
721 %
722 %
723 % \begin{macro}{\@@Collectverbenv}
724 % \begin{macrocode}
725 \begingroup
726 \catcode`\|=0
727 \catcode`\(=1
728 \catcode`\)=2
729 \@makeother\{
730 \@makeother\}
731 \@makeother\\
732 |catcode`|^^M=|active%
733 |gdef|@@Collectverbenv#1#2(%
734 |long|def|@@@Collectverb##1^^M##2^^M\end{#1}(|endgroup#2(##2)|end(#1))%
735 |@@@Collectverb%
736 )%
737 |gdef|misj(|def^^M(^^J))%
738 %|gdef|misj(|def^^M##1(|ifx##1|endmarker|else|noexpand^^M|expandafter##1|fi))%
739 |endgroup%
740 % \end{macrocode}
741 % \end{macro}
742 %
743 %
744 % \begin{macro}{\newverbsfont}
745 % \begin{macrocode}
746 \newcommand\newverbsfont{%
747 \verbatim@font
748 \frenchspacing
749 }
750 % \end{macrocode}
751 % \end{macro}
752 %
753 %
754 % \begin{macro}{\Verbdef}
755 % \begin{macrocode}
756 \newcommand*\Verbdef{%
757 \@ifstar
758 {\@Verbdef*}%
759 {\@Verbdef{}}%
760 }
761 % \end{macrocode}
762 % \end{macro}
763 %
764 %
765 % \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
766 % \begin{macrocode}
767 \def\@Verbdef#1#2{%
768 \Collectverb#1{\DeclareRobustCommand#2}%
769 }
770 % \end{macrocode}
771 % \end{macro}
772 %
773 % \begin{macro}{\verbdef}
774 % Provides an own definition of \Macro\verbdef which is also defined by the \pkg{verbdef} package.
775 % \begin{macrocode}
776 \providecommand*\verbdef{%
777 \@ifstar
778 {\newverbs@verbdef*}%
779 {\newverbs@verbdef{}}%
780 }
781 % \end{macrocode}
782 % \end{macro}
783 %
784 %
785 % \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
786 % \begin{macrocode}
787 \def\newverbs@verbdef#1#2{%
788 \Collectverb#1{\newverbs@@verbdef{#2}}%
789 }
790 % \end{macrocode}
791 % \end{macro}
792 %
793 %
794 % \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
795 % \begin{macrocode}
796 \def\newverbs@@verbdef#1#2{%
797 \DeclareRobustCommand{#1}{{\newverbsfont#2}}%
798 }
799 % \end{macrocode}
800 % \end{macro}
801 %
802 % \iffalse
803 %</newverbs.sty>
804 % \fi
805 %
806 % \Finale
807 \endinput