1% \iffalse meta-comment, etc.
2%%
3%% Package `fancyvrb'
4%%
5%% COPYING:
6%%   The files of this package "fancyvrb" are released under the Artistic
7%%   License Version 2. A copy of that license is included in the file
8%%   artistic2.txt. The package consists of the following files:
9%%     README artistic2.txt fancyvrb.cb fancyvrb.dtx fancyvrb.ins
10%%
11%% Timothy Van Zandt <tvz@zandtwerk.kellogg.nwu.edu>
12%% July 17, 1998
13%%
14% \fi
15%
16% \changes{v2.6}{1998/07/17}{. Three bug corrected, options numberblanklines,
17%                            label, labelposition and leftline added and few
18%                            precisions.}
19% \changes{v2.5}{1998/01/28}{First public release.}
20% \changes{v2.0 Beta}{1994/03/30}{First version personally shown by Timothy
21%                                 \textsc{van Zandt}.}
22%
23% \CheckSum{3107}
24%
25% \newif\ifPostScriptFonts
26% \IfFileExists{times.sty}{\PostScriptFontstrue}{}
27%
28% \DoNotIndex{\\,\^}
29% \DoNotIndex{\@@nil,\@M,\@MM,\@auxout,\@beginparpenalty,\@bsphack}
30% \DoNotIndex{\@currentlabel,\@currenvir,\@currenvline,\@currsize}
31% \DoNotIndex{\@defpar,\@doendpe,\@eha,\@empty,\@endparenv,\@endpefalse}
32% \DoNotIndex{\@endpetrue,\@esphack,\@fooA,\@fooB,\@footnotetext,\@gobble}
33% \DoNotIndex{\@height,\@ifnextchar,\@ifstar,\@ifundefined,\@ignorefalse}
34% \DoNotIndex{\@inlabelfalse}
35% \DoNotIndex{\@input,\@labels,\@listdepth,\@makefntext,\@makeother,}
36% \DoNotIndex{\@minipagefalse,\@namedef,\@nameuse,\@ne,\@newlistfalse,}
37% \DoNotIndex{\@nil,\@nobreakfalse,\@noparlistfalse,\@noparlisttrue}
38% \DoNotIndex{\@parboxrestore,\@sanitize,\@spaces,\@tempa,\@tempb,\@tempboxa}
39% \DoNotIndex{\@tempc,\@tempcnta,\@tempcntb,\@tempdima,\@tempdimb,\@tempdimc}
40% \DoNotIndex{\@tempg,\@temph,\@temptokena,\@thefnmark,\@toodeep}
41% \DoNotIndex{\@topsep,\@topsepadd,\@totalleftmargin,\@warning,\@width}
42% \DoNotIndex{\active,\addpenalty,\addvspace,\advance}
43% \DoNotIndex{\afterassignment,\aftergroup,\arabic}
44% \DoNotIndex{\baselineskip,\baselinestretch,\begin,\begingroup,\bf,\bgroup}
45% \DoNotIndex{\box,\c@FancyVerbLine,\catcode,\ChangeBartrue,\closein}
46% \DoNotIndex{\closeout,\clubpenalty,\CodelineIndex,\columnwidth,\cr,\csname}
47% \DoNotIndex{\date,\DeclareOption,\def,\define@booleankey,\define@key}
48% \DoNotIndex{\divide,\do,\do@noligs,\DocInput,\documentclass,\dp,\dospecials}
49% \DoNotIndex{\edef,\egroup,\else,\EnableCrossrefs,\end,\endcenter}
50% \DoNotIndex{\endcsname,\endgroup,\endinput,\endlrbox,\endpspicture}
51% \DoNotIndex{\enspace,\errhelp,\errmessage,\expandafter}
52% \DoNotIndex{\fancyvrb@loaded,\fboxrule,\fboxsep,\fi,\filedate,\fileversion}
53% \DoNotIndex{\floatingpenalty,\font,\fontdimen,\fontfamily,\fontseries}
54% \DoNotIndex{\fontshape,\footins,\footnote,\footnotesep,\footnotesize}
55% \DoNotIndex{\frenchspacing,\fvset}
56% \DoNotIndex{\gdef,\GetFileInfo,\global,\hbadness,\hbox,\hfil,\hfuzz}
57% \DoNotIndex{\hrule,\hsize,\hss,\ht,\iden,\if,\if@FV@ResetMargins,\if@filesw}
58% \DoNotIndex{\if@inlabel,\if@nobreak,\if@noparlist,\if@noskipsec,\ifcase}
59% \DoNotIndex{\ifChangeBar,\ifeof,\IfFileExists,\ifmmode,\iffalse,\ifnum}
60% \DoNotIndex{\iftrue,\ifvmode,\ifvoid,\ifx,\ignorespaces,\immediate,\input}
61% \DoNotIndex{\insert,\interfootnotelinepenalty,\interlinepenalty,\jobname}
62% \DoNotIndex{\kern,\large,\lccode,\leaders,\leavevmode,\leftmargin,\let}
63% \DoNotIndex{\lineskip,\linewidth,\long,\loop,\lowercase,\lrbox}
64% \DoNotIndex{\m@ne,\m@th,\maketitle,\mathbf,\mathit,\mathnormal}
65% \DoNotIndex{\mathsl,\mathtt,\mbox,\meaning,\message,\mid,\mskip}
66% \DoNotIndex{\multiply,\NeedsTeXFormat,\newbox,\newcommand,\newcount}
67% \DoNotIndex{\newcounter,\newenvironment,\newif,\newpsobject,\newread}
68% \DoNotIndex{\newwrite,\next,\noexpand,\normalsize,\number}
69% \DoNotIndex{\Oldmakeindex,\on@line,\OnlyDescription,\openin,\openout,\or}
70% \DoNotIndex{\outer,\pUseMVerb,\par,\parindent,\parskip,\partopsep}
71% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions,\protect}
72% \DoNotIndex{\protected@edef,\ProvidesPackage,\raise,\rangle,\read}
73% \DoNotIndex{\RecordChanges,\refstepcounter,\relax,\renewcommand}
74% \DoNotIndex{\renewenvironment,\repeat,\RequirePackage,\rightmargin,\rm}
75% \DoNotIndex{\rmfamily,\romannumeral,\rule}
76% \DoNotIndex{\scriptscriptstyle,\scriptstyle,\section,\selectfont,\setbox}
77% \DoNotIndex{\setcounter,\setkeys,\setlength,\small,\smallskip,\space}
78% \DoNotIndex{\splitmaxdepth,\splittopskip,\stepcounter,\string,\strip,\strut}
79% \DoNotIndex{\strutbox,\textbf,\textcolor,\textit,\textsc,\textsf,\textsl}
80% \DoNotIndex{\texttt,\textwidth,\the,\theFancyVerbLine,\tiny,\title,\topsep}
81% \DoNotIndex{\tt,\ttfamily,\ttyin,\tw@,\underline,\unhbox,\unitlength}
82% \DoNotIndex{\unskip,\usepackage,\valign,\vbox,\vcenter}
83% \DoNotIndex{\verbatim@nolig@list,\vfil,\voidb@x,\vrule,\vspace,\vskip}
84% \DoNotIndex{\vtop,\wd,\widowpenalty,\write,\xdef,\z@,\z@skip}
85%
86% \setcounter{IndexColumns}{2}
87%
88% \newcommand{\FBoxPackage}{`\textsf{fancybox}'}
89% \newcommand{\FVrbPackage}{`\textsf{fancyvrb}'}
90%
91% ^^A From ltugboat.cls
92%
93% ^^A Typeset the name of an environment
94% \providecommand\env[1]{\textsf{#1}}
95% \providecommand\clsname[1]{\textsf{#1}}
96% \providecommand\pkgname[1]{\textsf{#1}}
97% \providecommand\optname[1]{\textsf{#1}}
98% \providecommand\progname[1]{\textsf{#1}}
99%
100% ^^A A list of options for a package/class
101% \newenvironment{optlist}{\begin{description}%
102%   \renewcommand\makelabel[1]{%
103%     \descriptionlabel{\mdseries\optname{##1}}}%
104%   \itemsep0.25\itemsep}%
105%  {\end{description}}
106%
107% ^^A Utility macros
108%
109% ^^A Special dashes
110% \def\thinskip{\hskip 0.16667em\relax}
111% \def\endash{--}
112% \def\emdash{\endash-}
113% \def\d@sh#1#2{\unskip#1\thinskip#2\thinskip\ignorespaces}
114% \def\dash{\d@sh\nobreak\endash}
115% \def\Dash{\d@sh\nobreak\emdash}
116%
117% ^^A Example macros - adapted from the `fvrb-ex' package
118% ^^A ---------------------------------------------------
119%
120% ^^A Take care that we use here the "Z" character as comment character,
121% ^^A to avoid to use an 8 bit one which can cause portability problems.
122% ^^A But we can't use any more the "Z" into the example environments
123% ^^A of this documentation.
124%
125% \makeatletter
126% \newcommand{\BeginExample}[1][0]{%
127% \parindent=0pt
128% \multiply\topsep by 2
129% \VerbatimEnvironment
130% \begin{VerbatimOut}[gobble=#1]{\jobname.tmp}}
131%
132% \newcommand{\BelowExample}[1]{%
133% \VerbatimInput[gobble=4,commentchar=Z,numbersep=3pt,frame=single,
134%                numbers=left]{\jobname.tmp}
135% \catcode`\Z=9\relax%
136% #1\par}
137%
138% \newcommand{\SideBySide@Example}[1]{%
139% \@tempdimb=\FV@XRightMargin
140% \advance\@tempdimb -5mm
141% \vspace{2mm}
142% \begin{minipage}[c]{\@tempdimb}
143%   \fvset{xrightmargin=0pt}
144%   \catcode`\Z=9\relax%
145%   #1
146% \end{minipage}%
147% \@tempdimb=\textwidth
148% \advance\@tempdimb -\FV@XRightMargin
149% \advance\@tempdimb 5mm
150% \begin{minipage}[c]{\@tempdimb}
151%   \VerbatimInput[commentchar=Z,numbersep=3pt,frame=single,
152%                  numbers=left,xleftmargin=5mm,xrightmargin=0pt]{\jobname.tmp}
153% \end{minipage}
154% \vspace{2mm}}
155%
156% \def\Example{%
157% \catcode`\^^M=\active
158% \@ifnextchar[{\catcode`\^^M=5\Example@}{\catcode`\^^M=5\Example@@}}
159% \def\Example@[#1]{\fvset{#1}\Example@@}
160% \def\Example@@{\BeginExample}
161% \def\endExample{%
162% \end{VerbatimOut}%
163% \BelowExample{\input{\jobname.tmp}}}
164%
165% \def\CenterExample{%
166% \catcode`\^^M=\active
167% \@ifnextchar[{\catcode`\^^M=5\CenterExample@}
168%              {\catcode`\^^M=5\CenterExample@@}}
169% \def\CenterExample@[#1]{\fvset{#1}\CenterExample@@}
170% \def\CenterExample@@{\BeginExample}
171% \def\endCenterExample{%
172% \end{VerbatimOut}%
173% \center
174% \BelowExample{\input{\jobname.tmp}}
175% \endcenter}
176%
177% \def\SideBySideExample{%
178% \catcode`\^^M=\active
179% \@ifnextchar[{\catcode`\^^M=5\SideBySideExample@}%
180%              {\catcode`\^^M=5\SideBySideExample@@}}
181% \def\SideBySideExample@[#1]{\fvset{#1}\SideBySideExample@@}
182% \def\SideBySideExample@@{\BeginExample[4]}
183% \def\endSideBySideExample{%
184% \end{VerbatimOut}%
185% \SideBySide@Example{\input{\jobname.tmp}}}
186% \makeatother
187%
188% ^^A End of example macros from `fvrb-ex'
189%
190% ^^A For the possible index and changes log
191% \setlength{\columnseprule}{0.6pt}
192%
193% ^^A Beginning of the documentation itself
194%
195% \title{The `\textsf{fancyvrb}' package\\Fancy Verbatims in \LaTeX}
196% \author{Timothy Van Zandt\\Princeton University\\Princeton -- USA\\
197%         {\footnotesize email: tvz@Princeton.EDU}\\[5mm]
198%         {Packaging, documentation and support}\\
199%         {\footnotesize Denis Girou (CNRS/IDRIS -- France) -- %
200%                        Denis.Girou@idris.fr}\\[-2mm]
201%         {\footnotesize and}\\[-2mm]
202%         {\footnotesize Sebastian Rahtz (Elsevier -- GB) -- %
203%                        s.rahtz@elsevier.co.uk}}
204% \date{Version 2.6\\July 17, 1998\\
205%       {\small Documentation revised July 17, 1998}}
206%
207% \maketitle
208%
209% \begin{abstract}
210%     This package provides very sophisticated facilities for reading and
211%   writing verbatim \TeX{} code. Users can perform common tasks like changing
212%   font family and size, numbering lines, framing code examples, colouring
213%   text and conditionally processing text.
214% \end{abstract}
215%
216% \tableofcontents
217%
218% \section{Introduction}
219%
220%   \FVrbPackage{} is the development of the \emph{verbatim} macros of the
221% \FBoxPackage{} package,  Section 11 of \cite{FancyBox}. It offers six kinds
222% of extended functionality, compared to the standard \LaTeX{}
223% \textsf{verbatim} environment:
224%
225% \begin{enumerate}
226%   \item verbatim commands can be used in footnotes,
227%   \item several verbatim commands are enhanced,
228%   \item a variety of verbatim environments are provided, with many
229%   parameters to change the way the contents are printed; it is also possible
230%   to define new customized verbatim environments,
231%   \item a way is provided to save and restore verbatim text and environments,
232%   \item there are macros to write and read files in verbatim mode, with the
233%   usual versatility,
234%   \item you can build \emph{example} environments (showing both result and
235%   verbatim text), with the same versatility as normal verbatim.
236% \end{enumerate}
237%
238%   The package works by scanning a line at a time from an environment or a
239% file. This allows it to pre-process each line, rejecting it, removing
240% spaces, numbering it, etc, before going on to execute the body of the line
241% with the appropriate catcodes set.
242%
243% \section{Verbatim material in footnotes}
244%
245% \ifChangeBar\begin{changebar}\fi
246%   After a \cs{VerbatimFootnotes} macro declaration (to use after the
247% preamble), it is possible to put verbatim commands and environments
248% (the \LaTeX{} or \FVrbPackage{} ones) in footnotes, unlike in standard
249% \LaTeX:
250% \ifChangeBar\end{changebar}\fi
251%
252% \begin{Example}
253%   \VerbatimFootnotes
254%   We can put verbatim\footnote{\verb+_Yes!_+} text in footnotes.
255% \end{Example}
256%
257% \section{Improved verbatim commands}
258%
259%   The \cs{DefineShortVerb} macro allows us to define a special character as
260% an abbreviation to enclose verbatim text and the \cs{UndefineShortVerb}
261% macro suppresses the special meaning of the specified character (the same
262% \ifChangeBar\begin{changebar}\fi
263% functionalities are provided in the \LaTeX{} `\textsf{shortvrb}' package):
264% \ifChangeBar\end{changebar}\fi
265%
266% \fvset{xrightmargin=4.8cm}
267%
268% \begin{SideBySideExample}
269%   \DefineShortVerb{\|}
270%   We can simply write \Verb+_verbatim_+
271%   material using a single |_delimiter_|
272%   \UndefineShortVerb{\|}
273%   \DefineShortVerb{\+}
274%   And we can +_change_+ the character.
275% \end{SideBySideExample}
276%
277%   To make matters more versatile, we can nominate \emph{escape} characters
278% in verbatim text (using the \cs{Verb} macro or with a `shortverb' character
279% defined), to perform formatting or similar tasks, using the
280% \texttt{commandchars} parameter as shown for environments in paragraph
281% \ref{sec:commandchars}.
282%
283% \section{Verbatim environments}
284%
285% Several verbatim environments are available, each with a lot of
286% parameters to customize them. In the following examples we use the
287% \texttt{Verbatim} environment, which is the equivalent of the standard
288% \texttt{verbatim}. The parameters can be set globally using the \cs{fvset}
289% macro or in an optional argument after the start of the
290% environment\footnote{For clarification in this paper, note that we
291% generally indent each verbatim line with two
292% spaces.}$^,$\footnote{This mechanism uses the
293% `\textbf{keyval}' package from the standard \LaTeX{} graphics
294% distribution, written by David \textsc{Carlisle}.}.
295%
296% \begin{SideBySideExample}
297%   \begin{Verbatim}
298%     First verbatim line.
299%     Second verbatim line.
300%   \end{Verbatim}
301% \end{SideBySideExample}
302%
303% \subsection{Customization of verbatim environments}
304%
305% \ifChangeBar\begin{changebar}\fi
306%   The appearance of verbatim environments can be changed in many and
307% varied ways; here we list the keys that can be set.
308% \ifChangeBar\end{changebar}\fi
309%
310% \subsubsection{Comments}
311%
312% \begin{optlist}
313%   \item[commentchar (character)]: character to define comments in the
314%   verbatim code, so that lines starting with this character will not be
315%   printed (\emph{Default: empty}).
316% \end{optlist}
317%
318% \begin{SideBySideExample}
319%   \begin{Verbatim}[commentchar=!]
320%     % A comment
321%     Verbatim line.
322%     ! A comment that you will not see
323%   \end{Verbatim}
324% \end{SideBySideExample}
325%
326% \ifChangeBar\begin{changebar}\fi
327%   Take care to a special effect if the comment character is not the first
328% non blank one: it is because this character is in fact managed as the \TeX{}
329% comment one, that is to say that it gobble the newline character too. So, in
330% this case, the current line will be joined with the next one and, more, the
331% last one will be lost if it contain a comment, as \FVrbPackage{} print a
332% line only after finding it end character, which will never occured in this
333% case...
334%
335% \begin{SideBySideExample}
336%   \begin{Verbatim}[commentchar=\%]
337%     First line. % First line
338%     Second.
339%     Third line. % Third line lost...
340%   \end{Verbatim}
341% \end{SideBySideExample}
342% \ifChangeBar\end{changebar}\fi
343%
344% \subsubsection{Initial characters to suppress}
345%
346% \begin{optlist}
347%   \item[gobble (integer)]: number of characters to suppress at the beginning
348%   of each line (up to a maximum of 9), mainly useful when environments are
349%   indented
350%   (\emph{Default: empty} \Dash no character suppressed).
351% \end{optlist}
352%
353% \begin{SideBySideExample}
354%   \begin{Verbatim}
355%     Verbatim line.
356%   \end{Verbatim}
357%
358%   \begin{Verbatim}[gobble=2]
359%     Verbatim line.
360%   \end{Verbatim}
361%
362%   \begin{Verbatim}[gobble=8]
363%     Verbatim line.
364%   \end{Verbatim}
365% \end{SideBySideExample}
366%
367% \subsubsection{Customization of formatting}
368%
369% \begin{optlist}
370%   \item[formatcom (command)]: command to execute before printing verbatim
371%   text
372%   (\emph{Default: empty}).
373% \end{optlist}
374%
375% \begin{SideBySideExample}
376%   \begin{Verbatim}[formatcom=\color{red}]
377%     First verbatim line.
378%     Second verbatim line.
379%   \end{Verbatim}
380% \end{SideBySideExample}
381%
382% \subsubsection{Changing individual line formatting}
383%
384% \ifChangeBar\begin{changebar}\fi
385%   The macro \cs{FancyVerbFormatLine} defines the way each line is formatted.
386% Its default value is \verb+\def\FancyVerbFormatLine#1{#1}+, but we can
387% redefine it at our convenience (\texttt{FancyVerbLine} is the name of the
388% line counter):
389% \ifChangeBar\end{changebar}\fi
390%
391% {\fvset{fontsize=\small}
392% \begin{SideBySideExample}
393%   Z\fvset{fontsize=\normalsize}
394%   \renewcommand{\FancyVerbFormatLine}[1]{%
395%     \makebox[0cm][l]{$\Rightarrow$}#1}
396%   \begin{Verbatim}
397%     First verbatim line.
398%     Second verbatim line.
399%     Third verbatim line.
400%   \end{Verbatim}
401% \end{SideBySideExample}
402%
403% \begin{SideBySideExample}
404%   \renewcommand{\FancyVerbFormatLine}[1]{%
405%     \ifodd\value{FancyVerbLine}%
406%       \MakeUppercase{#1}\else#1\fi}
407%   \begin{Verbatim}
408%     First verbatim line.
409%     Second verbatim line.
410%     Third verbatim line.
411%   \end{Verbatim}
412% \end{SideBySideExample}
413% }
414%
415% \subsubsection{Fonts}
416%
417% \begin{optlist}
418%   \item[fontfamily (family name)]: font family to use.
419%   \texttt{tt}, \texttt{courier} and \texttt{helvetica} are pre-defined
420%   (\emph{Default:~tt}).
421% \end{optlist}
422%
423% \ifPostScriptFonts ^^A We can guess that PostScript fonts are available
424% \begin{SideBySideExample}
425%   \begin{Verbatim}[fontfamily=helvetica]
426%     Verbatim line.
427%   \end{Verbatim}
428% \end{SideBySideExample}
429% \else
430% \begin{quote}
431%     \textbf{\large Warning!} PostScript fonts seems not available on your
432%   platform (we are looking for the file \texttt{times.sty}, so we will
433%   not show the examplaes using such PostScript fonts.
434% \end{quote}
435% \fi
436%
437% \ifChangeBar\begin{changebar}\fi
438% \begin{optlist}
439%   \item[fontsize (font size)]: size of the font to use
440%   (\emph{Default: auto} \Dash the same as the current font). If you use the
441%   `\textsf{relsize}' package too, you can require a change of the size
442%   proportional to the current one (for instance:
443%   \verb+fontsize=\relsize{-2}+).
444% \end{optlist}
445% \ifChangeBar\end{changebar}\fi
446%
447% \ifPostScriptFonts ^^A We can guess that PostScript fonts are available
448% \begin{SideBySideExample}
449%   \begin{Verbatim}[fontsize=\small]
450%     Verbatim line.
451%   \end{Verbatim}
452%
453%   \begin{Verbatim}[fontfamily=courier,
454%                    fontsize=\large]
455%     Verbatim line.
456%   \end{Verbatim}
457% \end{SideBySideExample}
458% \else
459% \begin{SideBySideExample}
460%   \begin{Verbatim}[fontsize=\small]
461%     Verbatim line.
462%   \end{Verbatim}
463% \end{SideBySideExample}
464% \fi
465%
466% \begin{optlist}
467%   \item[fontshape (font shape)]: font shape to use
468%   (\emph{Default: auto} \Dash the same as the current font).
469% \end{optlist}
470%
471% \ifPostScriptFonts ^^A We can guess that PostScript fonts are available
472% \begin{SideBySideExample}
473%   \begin{Verbatim}[fontfamily=courier,
474%                    fontshape=it]
475%     Verbatim line.
476%   \end{Verbatim}
477% \end{SideBySideExample}
478% \else
479% \begin{SideBySideExample}
480%   \begin{Verbatim}[fontshape=it]
481%     Verbatim line.
482%   \end{Verbatim}
483% \end{SideBySideExample}
484% \fi
485%
486% \begin{optlist}
487%   \item[fontseries (series name)]: \LaTeX{} font `series' to use
488%   (\emph{Default: auto} \Dash the same as the current font).
489% \end{optlist}
490%
491% \ifPostScriptFonts ^^A We can guess that PostScript fonts are available
492% \begin{SideBySideExample}
493%   \begin{Verbatim}[fontfamily=courier,
494%                    fontseries=b]
495%     Verbatim line.
496%   \end{Verbatim}
497% \end{SideBySideExample}
498% \else
499% \begin{SideBySideExample}
500%   \begin{Verbatim}[fontseries=b]
501%     Verbatim line.
502%   \end{Verbatim}
503% \end{SideBySideExample}
504% \fi
505%
506% \subsubsection{Types and characteristics of frames}
507%
508% \ifChangeBar\begin{changebar}\fi
509% \begin{optlist}
510%   \item[frame
511%   (none$\mid$leftline$\mid$topline$\mid$bottomline$\mid$lines$\mid$single)]:
512%   type of frame around the verbatim environment
513%   (\emph{Default: none} \Dash no frame). With \textsf{leftline} and
514%   \textsf{single} modes, a space of a length  given by the \LaTeX{}
515%   \cs{fboxsep} macro is added between the left vertical line and the text.
516% \end{optlist}
517% \ifChangeBar\end{changebar}\fi
518%
519% ^^A Problem at the top of a page...
520% \ifChangeBar\leavevmode\mbox{}\begin{changebar}\fi
521% \begin{SideBySideExample}
522%   \begin{Verbatim}[frame=leftline]
523%     Verbatim line.
524%   \end{Verbatim}
525%
526%   \begin{Verbatim}[frame=topline]
527%     Verbatim line.
528%   \end{Verbatim}
529%
530%   \begin{Verbatim}[frame=bottomline]
531%     Verbatim line.
532%   \end{Verbatim}
533%
534%   \begin{Verbatim}[frame=lines]
535%     Verbatim line.
536%   \end{Verbatim}
537%
538%   \begin{Verbatim}[frame=single]
539%     Verbatim line.
540%   \end{Verbatim}
541% \end{SideBySideExample}
542% \ifChangeBar\end{changebar}\fi
543%
544% \begin{optlist}
545%   \item[framerule (dimension)]: width of the rule of the frame
546%   (\emph{Default: 0.4pt if framing specified}).
547% \end{optlist}
548%
549% \begin{SideBySideExample}
550%   \begin{Verbatim}[frame=single,
551%                    framerule=1mm]
552%     Verbatim line.
553%   \end{Verbatim}
554% \end{SideBySideExample}
555%
556% \begin{optlist}
557%   \item[framesep (dimension)]: width of the gap between the frame and
558%   the text (\emph{Default: \cs{fboxsep}}).
559% \end{optlist}
560%
561% \begin{SideBySideExample}
562%   \begin{Verbatim}[frame=single,
563%                    framesep=5mm]
564%     Verbatim line.
565%   \end{Verbatim}
566% \end{SideBySideExample}
567%
568% \begin{optlist}
569%   \item[rulecolor (color command)]: color of the frame rule, expressed
570%   in the standard \LaTeX{} way
571%   (\emph{Default: black}).
572% \end{optlist}
573%
574% \begin{SideBySideExample}
575%   \begin{Verbatim}[frame=single,
576%                    rulecolor=\color{red}]
577%     Verbatim line.
578%   \end{Verbatim}
579% \end{SideBySideExample}
580%
581% \begin{optlist}
582%   \item[fillcolor (color command)]: color used to fill the space
583%   between the frame and the text (its thickness is given by
584%   \texttt{framesep})
585%   (\emph{Default: none} \Dash no color).
586% \end{optlist}
587%
588% \begin{SideBySideExample}
589%   \begin{Verbatim}[frame=single,
590%          framerule=1mm,framesep=3mm,
591%          rulecolor=\color{red},
592%          fillcolor=\color{yellow}]
593%     Verbatim line.
594%   \end{Verbatim}
595% \end{SideBySideExample}
596%
597% \ifChangeBar\leavevmode\mbox{}\begin{changebar}\fi
598% \subsubsection{Label for the environment}
599%
600% \begingroup
601% \newcommand{\Vitem}{\SaveVerb[aftersave={\item[\UseVerb{Vitem}]}]{Vitem}}
602% \DefineShortVerb{\|}
603% \begin{optlist}
604%   \Vitem|label ({[string]string})|: label(s) to print on top, bottom or
605%   both frame lines of the environment to describe it content
606%   (\emph{Default: empty} \Dash no label).
607%   If the label(s) contains special characters, as a comma or an equal sign,
608%   it must be put inside a group. If only one string is given, it will be
609%   used for both top and bottom lines (if the two are printed), but if an
610%   optional first label is given too, this one will be used for the top line
611%   and the second  one for the bottom line. Note also that, if another value
612%   than \textsf{topline}, \textsf{bottomline}, \textsf{lines} or
613%   \textsf{single} is used for the \textsf{frame} parameter, the label(s)
614%   will not be printed.
615% \end{optlist}
616% \endgroup
617% \ifChangeBar\end{changebar}\fi
618%
619% ^^A Problem at the top of a page...
620% \ifChangeBar\leavevmode\mbox{}\begin{changebar}\fi
621% \begin{SideBySideExample}
622%   \fvset{gobble=2}
623%   \begin{Verbatim}[frame=single,
624%                    label=My text]
625%     First verbatim line.
626%     Second verbatim line.
627%   \end{Verbatim}
628%
629%   \begin{Verbatim}[frame=topline,
630%       framesep=4mm,
631%       label=\fbox{\Large\emph{The code}}]
632%     First verbatim line.
633%     Second verbatim line.
634%   \end{Verbatim}
635% \end{SideBySideExample}
636%
637% \begin{optlist}
638%   \item[labelposition (none$\mid$topline$\mid$bottomline$\mid$all)]:
639%   position where to print the label if one is defined, which must be
640%   coherent with the kind of frame chosen
641%   (\emph{Default: none if the label is empty, topline if one label is
642%   defined and all if two are defined}).
643%   Of course, some incompatible options (like
644%   \textsf{frame=topline,labelposition=bottomline}) will not print the
645%   label.
646% \end{optlist}
647% \ifChangeBar\end{changebar}\fi
648%
649% ^^A Problem at the top of a page...
650% \ifChangeBar\leavevmode\mbox{}\begin{changebar}\fi
651% \begin{SideBySideExample}
652%   \fvset{gobble=2}
653%   \begin{Verbatim}[frame=single,
654%          framesep=2mm,
655%          label=Text,labelposition=all]
656%     First verbatim line.
657%     Second verbatim line.
658%   \end{Verbatim}
659%
660%   \begin{Verbatim}[frame=lines,
661%          label=Text,labelposition=topline]
662%     First verbatim line.
663%     Second verbatim line.
664%   \end{Verbatim}
665% \end{SideBySideExample}
666%
667% \begin{SideBySideExample}
668%   \begin{Verbatim}[frame=bottomline,
669%          framesep=3mm,
670%          label=\textit{Code included},
671%          labelposition=bottomline]
672%     First verbatim line.
673%     Second verbatim line.
674%   \end{Verbatim}
675%
676%   \begin{Verbatim}[frame=lines,
677%                    framesep=3mm,
678%    label={[Beginning of code]End of code}]
679%     First verbatim line.
680%     Second verbatim line.
681%   \end{Verbatim}
682% \end{SideBySideExample}
683% \ifChangeBar\end{changebar}\fi
684%
685% \subsubsection{Line numbering}
686%
687% \begin{optlist}
688%   \item[numbers (none$\mid$left$\mid$right)]: numbering of the verbatim lines
689%   (\emph{Default: none} \Dash no numbering). If requested, this numbering is
690%   done \emph{outside} the verbatim environment.
691% \end{optlist}
692%
693% \begin{SideBySideExample}
694%   \begin{Verbatim}[gobble=2,numbers=left]
695%     First verbatim line.
696%     Second verbatim line.
697%   \end{Verbatim}
698%
699%   \begin{Verbatim}[gobble=2,
700%          numbers=right,numbersep=0pt]
701%     First verbatim line.
702%     Second verbatim line.
703%   \end{Verbatim}
704% \end{SideBySideExample}
705%
706% \begin{optlist}
707%   \item[numbersep (dimension)]: gap between numbers and verbatim lines
708%   (\emph{Default: 12pt}).
709% \end{optlist}
710%
711% \begin{SideBySideExample}
712%   \begin{Verbatim}[gobble=2,
713%          numbers=left,numbersep=2pt]
714%     First verbatim line.
715%     Second verbatim line.
716%   \end{Verbatim}
717% \end{SideBySideExample}
718%
719% \begin{optlist}
720%   \item[firstnumber (auto$\mid$last$\mid$integer)]: number of the first line
721%   (\emph{Default: auto} \Dash numbering starts from 1). \textsf{last} means
722%   that the numbering is continued from the previous verbatim environment. If
723%   an integer is given, its value will be used to start the numbering.
724% \end{optlist}
725%
726% \begin{SideBySideExample}
727%   \fvset{gobble=2,
728%          numbers=left,numbersep=3pt}
729%   \begin{Verbatim}
730%     Verbatim line.
731%   \end{Verbatim}
732%
733%   \begin{Verbatim}[firstnumber=last]
734%     Verbatim line.
735%   \end{Verbatim}
736%
737%   \begin{Verbatim}[firstnumber=100]
738%     Verbatim line.
739%   \end{Verbatim}
740% \end{SideBySideExample}
741%
742% \begin{optlist}
743%   \item[stepnumber (integer)]: interval at which line numbers are printed
744%   (\emph{Default:~1} \Dash all lines are numbered).
745% \end{optlist}
746%
747% \begin{SideBySideExample}
748%   \begin{Verbatim}[gobble=2,numbers=left,
749%          numbersep=3pt,stepnumber=2]
750%     First verbatim line.
751%     Second verbatim line.
752%     Third verbatim line.
753%   \end{Verbatim}
754% \end{SideBySideExample}
755%
756%   The macro \cs{theFancyVerbLine} defines the typesetting style of the
757% numbering, and the counter used is \texttt{FancyVerbLine}:
758%
759% \begin{SideBySideExample}
760%   \renewcommand{\theFancyVerbLine}{%
761%     \textcolor{red}{\small
762%       8.\alph{FancyVerbLine}}}
763%   \begin{Verbatim}[gobble=2,
764%          numbers=left,numbersep=2pt]
765%     First verbatim line.
766%     Second verbatim line.
767%     Third verbatim line.
768%   \end{Verbatim}
769% \end{SideBySideExample}
770%
771% \ifChangeBar\begin{changebar}\fi
772% \begin{optlist}
773%   \item[numberblanklines (boolean)]: to number or not the empty lines
774%   (really empty or containing blank characters only)
775%   (\emph{Default: true} \Dash all lines are numbered).
776% \end{optlist}
777%
778% \begin{SideBySideExample}
779%   \begin{Verbatim}[gobble=2,numbers=left,
780%          numbersep=3pt,
781%          numberblanklines=false]
782%     First verbatim line.
783%
784%
785%     Second verbatim line.
786%   \end{Verbatim}
787% \end{SideBySideExample}
788% \ifChangeBar\end{changebar}\fi
789%
790% \subsubsection{Selection of lines to print}
791%
792% \begin{optlist}
793%   \item[firstline (integer)]: first line to print
794%   (\emph{Default: empty} \Dash all lines from the first are printed).
795% \end{optlist}
796%
797% \begin{SideBySideExample}
798%   \begin{Verbatim}[gobble=2,firstline=2,
799%          numbers=left,numbersep=2pt]
800%     First verbatim line.
801%     Second verbatim line.
802%     Third verbatim line.
803%   \end{Verbatim}
804% \end{SideBySideExample}
805%
806% \begin{optlist}
807%   \item[lastline (integer)]: last line to print
808%   (\emph{Default: empty} \Dash all lines until the last one are printed).
809% \end{optlist}
810%
811% \begin{SideBySideExample}
812%   \begin{Verbatim}[gobble=2,lastline=1,
813%          numbers=left,numbersep=2pt]
814%     First verbatim line.
815%     Second verbatim line.
816%     Third verbatim line.
817%   \end{Verbatim}
818% \end{SideBySideExample}
819%
820% \subsubsection{Spaces and tab characters}
821%
822% \begin{optlist}
823%   \item[showspaces (boolean)]: print a special character representing each
824%   space
825%   (\emph{Default: false} \Dash spaces not shown).
826% \end{optlist}
827%
828% \begin{SideBySideExample}
829%   \begin{Verbatim}[showspaces=true]
830%     Verbatim line.
831%   \end{Verbatim}
832% \end{SideBySideExample}
833%
834%   In practice, all verbatim environments have a~\texttt{*} variant, which
835% sets \texttt{showspaces=true}:
836%
837% \begin{SideBySideExample}
838%   \begin{Verbatim*}
839%     Verbatim line.
840%   \end{Verbatim*}
841% \end{SideBySideExample}
842%
843%   There are also some parameters to determine the way tab characters are
844% interpreted (using tabs is in fact a rather old-fashioned style of coding):
845%
846% \begin{optlist}
847%   \item[showtabs (boolean)]: explicitly show tab characters
848%   (\emph{Default: false} \Dash tab characters not shown).
849% \end{optlist}
850%
851% \begin{optlist}
852%   \item[obeytabs (boolean)]: position characters according to the tabs
853%   (\emph{Default: false} \Dash tab characters are added to the current
854%   position).
855% \end{optlist}
856%
857% \begin{optlist}
858%   \item[tabsize (integer)]: number of spaces given by a tab character
859%   (\emph{Default:~8}).
860% \end{optlist}
861%
862% \subsubsection{Space between lines}
863%
864% \begin{optlist}
865%   \item[baselinestretch (auto$\mid$dimension)]: value to give to the usual
866%   `baselinestretch' \LaTeX{} parameter
867%   (\emph{Default: auto} \Dash its current value just before the verbatim
868%   command).
869% \end{optlist}
870%
871% \begin{SideBySideExample}
872%   \begin{Verbatim}[baselinestretch=2]
873%     First verbatim line.
874%     Second verbatim line.
875%   \end{Verbatim}
876% \end{SideBySideExample}
877%
878% \subsubsection{Escape characters for inserting commands}
879%
880% \begin{optlist}
881%   \item[commandchars (three characters)]: characters which define the
882%   character which starts a macro and marks the beginning and end of a group;
883%   thus lets us introduce \emph{escape} sequences in verbatim code. Of
884%   course, it is better to choose special characters which are not used in
885%   the verbatim text! (\emph{Default: empty}).
886%   \label{sec:commandchars}
887% \end{optlist}
888%
889% \begin{SideBySideExample}
890%   \begin{Verbatim}[commandchars=\\\{\}]
891%     \textit{% This is a comment}
892%     First verbatim line.
893%     \fbox{Second} verbatim line.
894%     \textcolor{red}{Third} verbatim line.
895%   \end{Verbatim}
896%
897%   \begin{Verbatim}[commandchars=+\[\]]
898%     +textit[\textbf{Verbatim} line].
899%   \end{Verbatim}
900% \end{SideBySideExample}
901%
902% \ifChangeBar\begin{changebar}\fi
903%   Using this way, it is also possible to put labels to be able, later, to
904% make reference to some lines of the verbatim environments:
905%
906% \begin{SideBySideExample}
907%   \begin{Verbatim}[commandchars=\\\{\},
908%          numbers=left,numbersep=2pt]
909%     First verbatim line.
910%     Second line.\label{vrb:Important}
911%     Third verbatim line.
912%   \end{Verbatim}
913%
914%     As I previously shown
915%   line~\ref{vrb:Important}, it is...
916% \end{SideBySideExample}
917% \ifChangeBar\end{changebar}\fi
918%
919% \subsubsection{Margins}
920%
921% \begin{optlist}
922%   \item[xleftmargin (dimension)]: indentation to add at the start of each
923%   line
924%   (\emph{Default:~0pt} \Dash no left margin).
925% \end{optlist}
926%
927% \begin{SideBySideExample}
928%   \begin{Verbatim}[frame=single,
929%                    xleftmargin=5mm]
930%     Verbatim line.
931%   \end{Verbatim}
932% \end{SideBySideExample}
933%
934% \begin{optlist}
935%   \item[xrightmargin (dimension)]: right margin to add after each line
936%   (\emph{Default:~0pt} \Dash no right margin).
937% \end{optlist}
938%
939% \begin{SideBySideExample}
940%   \begin{Verbatim}[frame=single,
941%                    xrightmargin=1cm]
942%     Verbatim line.
943%   \end{Verbatim}
944% \end{SideBySideExample}
945%
946% \begin{optlist}
947%   \item[resetmargins (boolean)]: reset the left margin, which is useful if
948%   we are inside other indented environments (\emph{Default: false} \Dash no
949%   reset of the margin).
950% \end{optlist}
951%
952% {%
953% \DefineVerbatimEnvironment{Verbatim}{Verbatim}{gobble=0,numbers=none}
954% \begin{SideBySideExample}
955%   \begin{itemize}
956%     \item First item
957%     \begin{Verbatim}[frame=single]
958%   Verbatim line.
959%     \end{Verbatim}
960%     \item Second item
961%     \begin{Verbatim}[frame=single,
962%                      resetmargins=true]
963%   Verbatim line.
964%     \end{Verbatim}
965%   \end{itemize}
966% \end{SideBySideExample}
967% }
968%
969% \subsubsection{Overfull box messages}
970%
971% \begin{optlist}
972%   \item[hfuzz (dimension)]: value to give to the \TeX{} \cs{hfuzz} dimension
973%   for text to format. This can be used to avoid seeing some unimportant
974%   \emph{Overfull box} messages (\emph{Default:~2pt}).
975% \end{optlist}
976%
977% \subsubsection{Page breaks}
978%
979% \begin{optlist}
980%   \item[samepage (boolean)]: in very special circumstances, we may want to
981%   make sure that a verbatim environment is not broken, even if it does not
982%   fit on the current page. To avoid a page break, we can set the
983%   \texttt{samepage} parameter to \emph{true} (\emph{Default: false}).
984% \end{optlist}
985%
986% \subsubsection{Catcode characters}
987%
988% \begin{optlist}
989%   \item[codes (macro)]: to specify \emph{catcode} changes (\emph{Default:
990%   empty}).
991% \end{optlist}
992%
993%   For instance, this allows us to include formatted mathematics in verbatim
994% text:
995%
996% {\fvset{fontsize=\small}
997% \begin{SideBySideExample}
998%   Z\fvset{fontsize=\normalsize}
999%   \begin{Verbatim}[commandchars=\\\{\},
1000%          codes={\catcode`$=3\catcode`^=7}]
1001%     x=1/sqrt(z**2) ! $\frac{1}{\sqrt{z^2}}$
1002%   \end{Verbatim}
1003% \end{SideBySideExample}
1004% }
1005%
1006% \subsubsection{Active characters}
1007%
1008% \begin{optlist}
1009%   \item[defineactive (macro)]: to define the effect of \emph{active}
1010%   characters
1011%   (\emph{Default: empty}).
1012% \end{optlist}
1013%
1014%   This allows us to do some devious tricks: see the example in Section
1015% \ref{sec:VerbatimInclude} on page~\pageref{sec:VerbatimInclude}.
1016%
1017% \subsection{Different kinds of verbatim environments}
1018%
1019% \subsubsection{Verbatim environment}
1020%
1021%   This is the `normal' verbatim environment which we have been using up to
1022% now.
1023%
1024% \subsubsection{BVerbatim environment}
1025%
1026%   This environment puts the verbatim material in a \TeX{} box. Some
1027% parameters do not work inside this environment (notably the framing ones),
1028% but two new ones are available:
1029%
1030% \begin{optlist}
1031%   \item[boxwidth (auto$\mid$dimension)]: size of the box used
1032%   (\emph{Default: auto} \Dash the width of the longest line is used).
1033% \end{optlist}
1034%
1035% \begin{optlist}
1036%   \item[baseline (b$\mid$c$\mid$t)]: position of the baseline (on the
1037%   \texttt{baseline}, the \texttt{center} or the \texttt{top} of the box)
1038%   (\emph{Default: b}).
1039% \end{optlist}
1040%
1041% \begin{SideBySideExample}
1042%   \fvset{gobble=2}
1043%   \begin{BVerbatim}
1044%     First
1045%     Second
1046%   \end{BVerbatim}
1047%   \begin{BVerbatim}[baseline=c]
1048%     First
1049%     Second
1050%   \end{BVerbatim}
1051% \end{SideBySideExample}
1052%
1053% \begin{SideBySideExample}
1054%   \begin{BVerbatim}[boxwidth=2cm]
1055%     First
1056%     Second
1057%   \end{BVerbatim}
1058%   \begin{BVerbatim}[boxwidth=2cm,
1059%                     baseline=t]
1060%     First
1061%     Second
1062%   \end{BVerbatim}
1063% \end{SideBySideExample}
1064%
1065% \subsubsection{LVerbatim environment}
1066%
1067%   This environment puts verbatim material into \LaTeX{} `LR' mode (the
1068% so-called \emph{left-to-right} mode, which in fact is the same thing that
1069% \TeX{} itself calls \emph{restricted horizontal mode}).
1070%
1071% \subsubsection{Personalized environments}
1072%
1073% \ifChangeBar\begin{changebar}\fi
1074% \VerbatimFootnotes%
1075%   It is easy to define personal customized environments. You can redefine
1076% the existing ones using the \cs{RecustomVerbatimEnvironment} macro or create
1077% your own ones, using the \cs{DefineVerbatimEnvironment} macro\footnote{%
1078% \ifChangeBar\begin{changebar}\fi
1079% For verbatim commands, the \cs{CustomVerbatimCommand} and
1080% \cs{RecustomVerbatimCommand} macros also exist; for instance:
1081%
1082% \noindent%
1083% \verb+\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{frame=lines}+
1084% \ifChangeBar\end{changebar}\fi}.
1085% In each case, you specify the name of the new environment, the type of
1086% environment on which it is based, and a set of initial option values. The
1087% options can be overridden with an optional argument in the normal way:
1088%
1089% \begin{SideBySideExample}
1090%   \RecustomVerbatimEnvironment
1091%     {Verbatim}{Verbatim}
1092%     {gobble=2,frame=single}
1093%   \begin{Verbatim}
1094%     First verbatim line.
1095%     Second verbatim line.
1096%   \end{Verbatim}
1097% \end{SideBySideExample}
1098% \ifChangeBar\end{changebar}\fi
1099%
1100% \begin{SideBySideExample}
1101%   \DefineVerbatimEnvironment%
1102%     {MyVerbatim}{Verbatim}
1103%     {gobble=2,numbers=left,numbersep=2mm,
1104%      frame=lines,framerule=0.8mm}
1105%   \begin{MyVerbatim}
1106%     First verbatim line.
1107%     Second verbatim line.
1108%   \end{MyVerbatim}
1109%
1110%   \begin{MyVerbatim}[numbers=none,
1111%                      framerule=1pt]
1112%     First verbatim line.
1113%     Second verbatim line.
1114%   \end{MyVerbatim}
1115% \end{SideBySideExample}
1116%
1117% \section{Saving and restoring verbatim text and environments}
1118%
1119%   The \cs{SaveVerb} and \cs{UseVerb} macros allow us to save and restore
1120% verbatim material.
1121%
1122% \begin{SideBySideExample}
1123%   \DefineShortVerb{\|}
1124%   \SaveVerb{Verb}|_verbatim_|
1125%   I have saved \UseVerb{Verb} and reuse
1126%   it later as many times as I want
1127%   \UseVerb{Verb}.
1128% \end{SideBySideExample}
1129%
1130%   This also provides a solution to putting verbatim text inside \LaTeX{}
1131% commands which do not normally permit it:
1132%
1133% {\fvset{frame=single,xrightmargin=0cm}
1134% \begin{Example}
1135%   \DefineShortVerb{\|}
1136%   \SaveVerb{Verb}|_OK^|
1137%   \marginpar{\UseVerb{Verb}}
1138% \end{Example}
1139% }
1140%
1141%   There is a useful ability to use verbatim text as the item text in a
1142% description list (something not normally permitted in \LaTeX), using the
1143% \texttt{aftersave} parameter:
1144%
1145% \begin{optlist}
1146%   \item[aftersave (macro)]: macro to dynamically save some verbatim material
1147%   (\emph{Default: empty}).
1148% \end{optlist}
1149%
1150% \begin{SideBySideExample}
1151%   \newcommand{\Vitem}{%
1152%     \SaveVerb[aftersave={%
1153%       \item[\UseVerb{Vitem}]}]{Vitem}}
1154%   \DefineShortVerb{\|}
1155%   \begin{description}
1156%     \Vitem|\MyCommand|: my command
1157%   \end{description}
1158% \end{SideBySideExample}
1159%
1160%   In the same way, we can use and restore (in normal, boxed and LR mode,
1161% using \cs{UseVerbatim}, \cs{BUseVerbatim} and \cs{LUseVerbatim} respectively)
1162% entire verbatim environments:
1163%
1164% \begin{SideBySideExample}
1165%   Z\fvset{gobble=0,numbers=none}
1166%   \begin{SaveVerbatim}{VerbEnv}
1167%     Verbatim line.
1168%   \end{SaveVerbatim}
1169%   \UseVerbatim{VerbEnv}
1170%   and \UseVerbatim{VerbEnv}
1171% \end{SideBySideExample}
1172%
1173% \begin{SideBySideExample}
1174%   Z\fvset{gobble=0,numbers=none}
1175%   \begin{SaveVerbatim}[gobble=5]{VerbEnv}
1176%     First
1177%     Second
1178%   \end{SaveVerbatim}
1179%
1180%   \fbox{\BUseVerbatim{VerbEnv}}
1181%   and \BUseVerbatim{VerbEnv}.
1182%
1183%   \LUseVerbatim{VerbEnv} and
1184%   \LUseVerbatim{VerbEnv}
1185% \end{SideBySideExample}
1186%
1187% \section{Writing and reading verbatim files}
1188% \label{sec:VerbatimInclude}
1189%
1190%   The command \cs{VerbatimInput} (the variants \cs{BVerbatimInput} and
1191% \cs{LVerbatimInput} also exist) allows inclusion of the contents of a file
1192% with verbatim formatting. Of course, the various parameters which we have
1193% described for customizing can still be used:
1194%
1195% ^^A The file we will use for \VerbatimInput
1196%
1197% \typeout{*************************************}
1198% \typeout{* Created files: hello.f90, file.txt}
1199% \typeout{* See fancyhdr.dvi for an explanation}
1200% \typeout{*************************************}
1201%
1202% \begin{VerbatimOut}{hello.f90}
1203%   ! A "hello" program
1204%
1205%   program hello
1206%     print *,"Hello world"
1207%   end program hello
1208% \end{VerbatimOut}
1209%
1210% \begin{SideBySideExample}
1211%   Z\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{gobble=4}
1212%   \fvset{fontsize=\small}
1213%   \VerbatimInput{hello.f90}
1214%
1215%   \fvset{frame=single,numbers=left,
1216%          numbersep=3pt}
1217%   \VerbatimInput{hello.f90}
1218%
1219%   \VerbatimInput[firstline=3,
1220%       rulecolor=\color{green}]
1221%     {hello.f90}
1222%
1223%   \VerbatimInput[frame=lines,
1224%       fontshape=sl,fontsize=\footnotesize]
1225%     {hello.f90}
1226% \end{SideBySideExample}
1227%
1228%   We can make use of the `defineactive' parameter to set the comment lines
1229%   in the program text in a different style:
1230%
1231% \begin{SideBySideExample}
1232%   Z\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{gobble=4}
1233%   \def\ExclamationPoint{\char33}
1234%   \catcode`!=\active
1235%   \VerbatimInput%
1236%     [defineactive=%
1237%       \def!{\color{cyan}\itshape
1238%         \ExclamationPoint}]
1239%     {hello.f90}
1240% \end{SideBySideExample}
1241%
1242%   It is important to note that if the contents of the file does not fit on
1243% the page, it will be automatically broken across pages as needed (unless the
1244% \texttt{samepage} parameter has been set to \texttt{true}).
1245%
1246%   There is also a \verb+VerbatimOut+ environment to write verbatim text to an
1247% output file, in the same way:
1248%
1249% \begin{SideBySideExample}
1250%   \begin{VerbatimOut}{file.txt}
1251%     I write that.
1252%     And that too.
1253%   \end{VerbatimOut}
1254%
1255%   \VerbatimInput[frame=single,
1256%     numbers=left,numbersep=6pt]{file.txt}
1257% \end{SideBySideExample}
1258%
1259% \ifChangeBar\begin{changebar}\fi
1260% \section{Automatic pretty printing}
1261%
1262%    Obviously, automatic \emph{pretty printing} is outside the scope of this
1263% package. Nevertheless, this is specially interesting for verbatim
1264% inclusion of programming code files or fragments. In the \LaTeX{} world
1265% (not speaking of the \emph{literate programming} way), there are software
1266% for some special languages, as the `\textsf{C++2LaTeX}' package from Norbert
1267% \textsc{Kiesel}, but mainly two generic ones, which use completely different
1268% modes (an external preprocessor written in C and a \TeX{} based solution):
1269% the `\textsf{LGrind}'~\cite{LGrind} system, currently maintened by Michael
1270% \textsc{Piefel}, and the `\textsf{listings}'~\cite{Listings} package from
1271% Carsten \textsc{Heinz}.
1272%
1273%    Future versions of \FVrbPackage{} and `\textsf{listings}' packages are
1274% planned to cooperate, which will offer great advantages to both users of the
1275% two actual packages, and will allow \FVrbPackage{} users to have automatic
1276% pretty printing of programming codes.
1277%
1278% \section{Known problems}
1279%
1280% \begin{itemize}
1281%   \item Vladimir \textsc{Volovich} \verb+<vvv@vvv.vsu.ru>+ reported that the
1282%   special character \verb+\th+, available with T1 encoding, can't be
1283%   included as verbatim with \FVrbPackage. It can be true for other special
1284%   characters too.
1285% \end{itemize}
1286%
1287% \section{Thanks}
1288%
1289%   For interesting comments and suggestions, we would like to thank specially
1290% (alphabetic order): Philippe \textsc{Esperet}
1291% \texttt{<esperet@marie.polytechnique.fr>}, Michael \textsc{Friendly}
1292% \texttt{<friendly@hotspur.psych.yorku.ca>}, Rolf \textsc{Niepraschk}
1293% \texttt{<niepraschk@ptb.de>} and for bug reports Mario \textsc{Hassler}
1294% \relax\unskip\break
1295% \texttt{<HASSLER@ippnv2.ipp.kfa-juelich.de>}, Mikhail \textsc{Kolodin}
1296% \relax\unskip\break
1297% \texttt{<myke@morrigan.spb.su>} and Vladimir \textsc{Volovich}
1298% \verb+<vvv@vvv.vsu.ru>+.
1299% \ifChangeBar\end{changebar}\fi
1300%
1301% \section{Conclusion}
1302%
1303% \ifChangeBar\begin{changebar}\fi
1304%   There are a few other possibilities that we have not described here.
1305% Note specially that it is possible to define a customization file
1306% (\texttt{fancyvrb.cfg}) loaded at the end of the package, to store
1307% definitions of your customized commands and environments and to redefine
1308% the attributes of existing ones.
1309% \ifChangeBar\end{changebar}\fi
1310%
1311% \begin{thebibliography}{1}
1312%   \bibitem{FancyBox} Timothy \textsc{van Zandt},
1313%   \textit{Documentation for `fancybox': Box tips and tricks for \LaTeX}.
1314%   Available from \texttt{CTAN:}
1315%   \texttt{macros/latex/contrib/supported/fancybox}, 1993.
1316%
1317%   \bibitem{FancyVrb} Timothy \textsc{van Zandt},
1318%   \textit{`fancyvrb': Fancy Verbatims in \LaTeX}.
1319%   Available from \texttt{CTAN:}
1320%   \texttt{macros/latex/contrib/supported/fancyvrb}, 1998.
1321%
1322%   \bibitem{LGrind} Various authors (current maintainer: Michael
1323%   \textsc{Piefel}),
1324%   \textit{The `LGrind' package}.
1325%   Available from \texttt{CTAN:} \texttt{support/lgrind}, 1998.
1326%
1327%   \bibitem{Listings} Carsten \textsc{Heinz},
1328%   \textit{The `Listings' package}.
1329%   Available from \texttt{CTAN:}
1330%   \texttt{macros/latex/contrib/supported/listings}, 1996-1997.
1331%\end{thebibliography}
1332%
1333% \StopEventually{}
1334%
1335% ^^A .................... End of the documentation part ....................
1336%
1337% \section{Driver file}
1338%
1339%   The next bit of code contains the documentation driver file for \TeX{},
1340% i.e., the file that will produce the documentation you are currently
1341% reading. It will be extracted from this file by the \texttt{docstrip}
1342% program.
1343%
1344%    \begin{macrocode}
1345%<*driver>
1346\documentclass{ltxdoc}
1347\GetFileInfo{fancyvrb.dtx}
1348\usepackage{color}
1349\usepackage{fancyvrb}
1350\newif\ifChangeBar
1351\IfFileExists{changebar.sty}%
1352             {\ChangeBartrue\usepackage[dvips,rightbars]{changebar}}{}
1353\EnableCrossrefs
1354\CodelineIndex
1355\RecordChanges
1356\OnlyDescription                % Comment it for implementation details
1357%\Oldmakeindex                   % Uncomment if your MakeIndex is pre-0.9
1358\hbadness=7000                  % Over and under full box warnings
1359\hfuzz=3pt
1360\begin{document}
1361  \DocInput{fancyvrb.dtx}
1362\end{document}
1363%</driver>
1364%    \end{macrocode}
1365%
1366% \section{\FVrbPackage{} code}
1367%
1368%<*fancyvrb>
1369%
1370% \iffalse meta-comment, etc.
1371%% COPYRIGHT 1992-1999, by Timothy Van Zandt <tvz@zandtwerk.kellogg.nwu.edu>
1372%%
1373%% This package may be distributed under the terms of the LaTeX Project Public
1374%% License, as described in lppl.txt in the base LaTeX distribution.
1375%% Either version 1.0 or, at your option, any later version.
1376%%
1377%% DESCRIPTION:
1378%%   fancyvrb.sty is a LaTeX style option, containing flexible
1379%%   verbatim environments and commands and extensive documentation.
1380%%
1381%%   This is a companion to the `fancybox' package.
1382%%
1383% \fi
1384%
1385% \begin{quote}
1386%     \emph{\textbf{\large Disclaimer (D.G./S.R.)}: This is the original
1387%   comments of the code by Timothy \textsc{van Zandt}. We have not change
1388%   them.}
1389% \end{quote}
1390%
1391% \subsection{Preambule}
1392%
1393% What we need.
1394%    \begin{macrocode}
1395\NeedsTeXFormat{LaTeX2e}
1396%    \end{macrocode}
1397%
1398% Who we are.
1399%    \begin{macrocode}
1400\def\fileversion{2.6, with DG/SPQR fixes}
1401\def\filedate{1998/07/17}
1402\ProvidesPackage{fancyvrb}[\filedate]
1403\message{Style option: `fancyvrb' v\fileversion \space  <\filedate> (tvz)}
1404\csname fancyvrb@loaded\endcsname
1405\let\fancyvrb@loaded\endinput
1406%    \end{macrocode}
1407%
1408% \subsection{Errors}
1409%
1410%    \begin{macrocode}
1411\def\FV@Error#1#2{%
1412  \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
1413  \errmessage{FancyVerb Error:^^J\space\space #1^^J}}
1414
1415\def\FV@eha{Your command was ignored. Type <return> to continue.}
1416%    \end{macrocode}
1417%
1418% \subsection{Verbatim footnotes}
1419%
1420% Color has to be protected.
1421%
1422% \noindent Won't work for some definitions of \cs{@makefntext}.
1423% If it weren't for \cs{@makefntext}, I would do this properly by defining a
1424% footnote environment.
1425%
1426% \begin{macro}{\VerbatimFootnotes}
1427%    \begin{macrocode}
1428%% DG/SR modification begin - Jan. 21, 1998
1429%% Suggested by Bernard Gaulle to solve a compatibility problem with `french'
1430%% (it introduce the restriction to put \VerbatimFootnotes AFTER the preambule)
1431%%\def\VerbatimFootnotes{\let\@footnotetext\V@footnotetext}
1432\let\V@footnote\footnote
1433\def\VerbatimFootnotes{%
1434\let\@footnotetext\V@footnotetext%
1435\let\footnote\V@footnote}
1436%% DG/SR modification end
1437%    \end{macrocode}
1438% \end{macro}
1439%
1440% \begin{macro}{\V@footnotetext}
1441%    \begin{macrocode}
1442\long\def\V@footnotetext{%
1443  \afterassignment\V@@footnotetext
1444  \let\@tempa}
1445%    \end{macrocode}
1446% \end{macro}
1447%
1448% \begin{macro}{\V@@footnotetext}
1449%    \begin{macrocode}
1450\def\V@@footnotetext{%
1451  \insert\footins\bgroup
1452  \csname reset@font\endcsname
1453  \footnotesize
1454  \interlinepenalty\interfootnotelinepenalty
1455  \splittopskip\footnotesep
1456  \splitmaxdepth\dp\strutbox
1457  \floatingpenalty \@MM
1458  \hsize\columnwidth
1459  \@parboxrestore
1460  \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
1461  \@makefntext{}%
1462  \rule{\z@}{\footnotesep}%
1463  \bgroup
1464  \aftergroup\V@@@footnotetext
1465  \ignorespaces}
1466%    \end{macrocode}
1467% \end{macro}
1468%
1469% \begin{macro}{\V@@@footnotetext}
1470%    \begin{macrocode}
1471\def\V@@@footnotetext{\strut\egroup}
1472%    \end{macrocode}
1473% \end{macro}
1474%
1475% \subsection{key=value}
1476%
1477%    \begin{macrocode}
1478\RequirePackage{keyval}
1479%    \end{macrocode}
1480%
1481% Extensions to keyval.sty:
1482%
1483% \verb+\define@booleankey{<family>}{<key>}{<iftrue>}{<iffalse>}+
1484%
1485% Defines a \verb+<key>+ for \verb+<family>+ that executes:
1486%
1487%   \verb+<iftrue>+ clause when value begins with `t' or `T', or is omitted.
1488%
1489%   \verb+<iffalse>+ clause otherwise.
1490%
1491% \begin{macro}{\define@booleankey}
1492%    \begin{macrocode}
1493\def\define@booleankey#1#2#3#4{%
1494  \@namedef{KV@#1@#2@default}{#3}%
1495  \@namedef{KV@#1@#2@false}{#4}%
1496  \@namedef{KV@#1@#2}##1{\KV@booleankey{##1}{#1}{#2}}}
1497%    \end{macrocode}
1498% \end{macro}
1499%
1500% \begin{macro}{\KV@booleankey}
1501%    \begin{macrocode}
1502\def\KV@booleankey#1#2#3{%
1503  \edef\@tempa{#1}\expandafter\KV@@booleankey\@tempa\relax\@nil{#2}{#3}}
1504%    \end{macrocode}
1505% \end{macro}
1506%
1507% \begin{macro}{\KV@@booleankey}
1508%    \begin{macrocode}
1509\def\KV@@booleankey#1#2\@nil#3#4{%
1510  \@nameuse{KV@#3@#4@\if t#1default\else\if T#1default\else false\fi\fi}}
1511%    \end{macrocode}
1512% \end{macro}
1513%
1514% \begin{macro}{\FV@None}
1515%    \begin{macrocode}
1516\def\FV@None{none}
1517%    \end{macrocode}
1518% \end{macro}
1519%
1520% \begin{macro}{\FV@Auto}
1521%    \begin{macrocode}
1522\def\FV@Auto{auto}
1523%    \end{macrocode}
1524% \end{macro}
1525%
1526% \begin{macro}{\fvset}
1527%    \begin{macrocode}
1528\def\fvset#1{\setkeys{FV}{#1}}
1529%    \end{macrocode}
1530% \end{macro}
1531%
1532% \cs{FV@Command} is for verbatim commands. Example:
1533%
1534%   \verb+\def\VerbatimInput{\FV@Command{}{VerbatimInput}}+
1535%
1536% \verb+\FV@Command{<key=value>}{<name>}+:
1537%
1538% \begin{enumerate}
1539%   \item Defines \cs{FV@KeyValues} to be \verb+<key=value>+.
1540%   \item Looks for $*$, and adds `showspaces' to \cs{FV@KeyValues} if found.
1541%   \item Looks for \verb+[<key=value>]+ argument, and adds it to
1542%         \cs{FV@KeyValues} if found.
1543%   \item Executes \verb+\FVC@<name>+.
1544% \end{enumerate}
1545%
1546% \begin{macro}{\FV@Command}
1547%    \begin{macrocode}
1548\def\FV@Command#1#2{%
1549  \@ifstar
1550    {\def\FV@KeyValues{#1,showspaces}\FV@@Command{#2}}%
1551    {\def\FV@KeyValues{#1}\FV@@Command{#2}}}
1552%    \end{macrocode}
1553% \end{macro}
1554%
1555% \begin{macro}{\FV@@Command}
1556%    \begin{macrocode}
1557\def\FV@@Command#1{%
1558  \@ifnextchar[%
1559    {\FV@GetKeyValues{\@nameuse{FVC@#1}}}%
1560    {\@nameuse{FVC@#1}}}
1561%    \end{macrocode}
1562% \end{macro}
1563%
1564% \begin{macro}{\FV@GetKeyValues}
1565%    \begin{macrocode}
1566\def\FV@GetKeyValues#1[#2]{%
1567  \expandafter\def\expandafter\FV@KeyValues\expandafter{\FV@KeyValues,#2}#1}
1568%    \end{macrocode}
1569% \end{macro}
1570%
1571% \begin{macro}{\@CustomVerbatimCommand}
1572%    \begin{macrocode}
1573\def\@CustomVerbatimCommand#1#2#3#4{%
1574  \begingroup\fvset{#4}\endgroup  % If there are errors, it easier to locate.
1575%% DG/SR modification begin - Jan. 13, 1998
1576%%  \def\@tempa##1##2\@nil{\def\@tempa{##2}}%
1577%%  \expandafter\@tempa\string#3\@empty\@nil
1578%%  \@ifundefined{FVC@\@tempa}%
1579  \@ifundefined{FVC@#3}%
1580%% DG/SR modification end
1581    {\FV@Error{Command `\string#3' is not a FancyVerb command.}\@eha}%
1582    {#1{#2}{\FV@Command{#4}{#3}}}}
1583%    \end{macrocode}
1584% \end{macro}
1585%
1586% \begin{macro}{\CustomVerbatimCommand}
1587%    \begin{macrocode}
1588\def\CustomVerbatimCommand{\@CustomVerbatimCommand\newcommand}
1589%    \end{macrocode}
1590% \end{macro}
1591%
1592% \begin{macro}{\RecustomVerbatimCommand}
1593%    \begin{macrocode}
1594\def\RecustomVerbatimCommand{\@CustomVerbatimCommand\renewcommand}
1595%    \end{macrocode}
1596% \end{macro}
1597%
1598% \cs{FV@Environment} is for verbatim environments. Example:
1599%
1600%          \verb+\def\Verbatim{\FV@Environment{}{Verbatim}}+
1601%
1602%          \verb+\@namedef{Verbatim*}{\FV@Environment{showspaces}{Verbatim}}+
1603%
1604% \verb+\FV@Environment{<key=value>}{<name>}+:
1605%
1606% \begin{enumerate}
1607%   \item Defines \cs{FV@KeyValues} to be \verb+<key=value>+.
1608%   \item Sets \verb+\catcode`\^^M=13+, checks for `[', and resets
1609%         \verb+\catcode``^^M=5+.
1610%   \item Reads \verb+[<key=value>]+ and adds it to \cs{FV@KeyValues} if `['
1611%         was found.
1612%   \item Executes \verb+\FVB@<name>+.
1613% \end{enumerate}
1614%
1615% \cs{FV@Environment} is like \cs{FV@Command}, except:
1616%
1617% \begin{itemize}
1618%   \item It omits step 2 (looking for $*$), and
1619%   \item It sets \verb+\catcode`\^^M=13+ when checking for the `[' of the
1620%         optional argument, so that it does not skip over \verb+^^M+ if there
1621%         is no `['.
1622% \end{itemize}
1623%
1624% \begin{macro}{\FV@Environment}
1625%    \begin{macrocode}
1626\def\FV@Environment#1#2{%
1627  \def\FV@KeyValues{#1}%
1628  \catcode`\^^M=\active
1629  \@ifnextchar[%
1630    {\catcode`\^^M=5 \FV@GetKeyValues{\@nameuse{FVB@#2}}}%
1631    {\catcode`\^^M=5 \@nameuse{FVB@#2}}}
1632%    \end{macrocode}
1633% \end{macro}
1634%
1635% \begin{macro}{\CustomVerbatimEnvironment}
1636%    \begin{macrocode}
1637\def\CustomVerbatimEnvironment{\@CustomVerbatimEnvironment\newenvironment}
1638%    \end{macrocode}
1639% \end{macro}
1640%
1641% \begin{macro}{\RecustomVerbatimEnvironment}
1642%    \begin{macrocode}
1643\def\RecustomVerbatimEnvironment{\@CustomVerbatimEnvironment\renewenvironment}
1644%    \end{macrocode}
1645% \end{macro}
1646%
1647% \begin{macro}{\@CustomVerbatimEnvironment}
1648%    \begin{macrocode}
1649\def\@CustomVerbatimEnvironment#1#2#3#4{%
1650  \begingroup\fvset{#4}\endgroup  % If there are errors, it easier to locate.
1651  \@ifundefined{FVB@#3}%
1652    {\FV@Error{`#3' is not a FancyVerb environment.}\@eha}%
1653    {#1{#2}{\FV@Environment{#4}{#3}}{\@nameuse{FVE@#3}}%
1654     #1{#2*}{\FV@Environment{#4,showspaces}{#3}}{\@nameuse{FVE@#3}}}}
1655%    \end{macrocode}
1656% \end{macro}
1657%
1658% \begin{macro}{\DefineVerbatimEnvironment}
1659%    \begin{macrocode}
1660\def\DefineVerbatimEnvironment#1#2#3{%
1661  \@namedef{#1}{\FV@Environment{#3}{#2}}%
1662  \@namedef{end#1}{\@nameuse{FVE@#2}}%
1663  \@namedef{#1*}{\FV@Environment{#3,showspaces}{#2}}%
1664  \@namedef{end#1*}{\@nameuse{FVE@#2}}}
1665%    \end{macrocode}
1666% \end{macro}
1667%
1668% Then commands or environments set key values with \cs{FV@UseKeyValues},
1669% within a group.
1670%
1671% \begin{macro}{\FV@UseKeyValues}
1672%    \begin{macrocode}
1673\def\FV@UseKeyValues{%
1674  \ifx\FV@KeyValues\@empty\else
1675    \def\KV@prefix{KV@FV@}%
1676    \expandafter\KV@do\FV@KeyValues,\relax,%
1677    \def\FV@KeyValues{}%
1678  \fi}
1679%    \end{macrocode}
1680% \end{macro}
1681%
1682% \subsection{Scanning}
1683%
1684% Scanning macros:
1685%
1686% \begin{itemize}
1687%   \item read a line at a time from an environment or a file,
1688%   \item save the line in \cs{FV@Line}, and
1689%   \item execute \cs{FV@PreProcessLine}.
1690% \end{itemize}
1691%
1692% \noindent\cs{FV@PreProcessLine}:
1693%
1694% \begin{itemize}
1695%   \item Determines whether line is in a user-specified ranges, and if so,
1696%   \item Strips the line of a user-specified no. of tokens, and
1697%   \item Executes \verb+\FV@ProcessLine{<line>}+.
1698% \end{itemize}
1699%
1700% Two things are common to scanning an environment or reading a file:
1701%
1702% \begin{itemize}
1703%   \item \cs{FV@CatCodes} $\Longrightarrow$ Change \verb+\catcode+'s.
1704%   \item \cs{FV@PreProcessLine} $\Longrightarrow$ See above.
1705% \end{itemize}
1706%
1707% \subsection{Codes}
1708%
1709% \begin{macro}{\FV@CatCodes}
1710%    \begin{macrocode}
1711\def\FV@CatCodes{%
1712  \let\do\@makeother\dospecials  % The usual stuff.
1713  \FV@ActiveWhiteSpace           % See below.
1714  \FV@FontScanPrep               % See below.
1715  \FV@CatCodesHook               % A style hook.
1716  \FancyVerbCodes}               % A user-defined hook.
1717%    \end{macrocode}
1718% \end{macro}
1719%
1720% \begin{macro}{\FV@ActiveWhiteSpace}
1721%    \begin{macrocode}
1722\def\FV@ActiveWhiteSpace{%
1723  \catcode`\^^M=\active          % End of line
1724  \catcode`\ =\active            % Space
1725  \catcode`\^^I=\active}         % Tab
1726%    \end{macrocode}
1727% \end{macro}
1728%
1729% CM Ligatures:
1730%
1731% \begin{tabbing}
1732%   Left-quote: \= \verb+--+ \= \verb+---+ \= fl \= ffi \= ffl \kill
1733%   Left-quote: \> `` \> !` \> ?` \\
1734%   Letter f:   \> ff \> fi \> fl \> ffi \> ffl \\
1735%   Hyphen:     \> \verb+--+ \> \verb+---+
1736% \end{tabbing}
1737%
1738% \begin{macro}{\FV@CatCodesHook}
1739%    \begin{macrocode}
1740\def\FV@CatCodesHook{}
1741%    \end{macrocode}
1742% \end{macro}
1743%
1744% \begin{macro}{\FV@AddToHook}
1745%    \begin{macrocode}
1746\def\FV@AddToHook#1#2{%
1747  \expandafter\def\expandafter#1\expandafter{#1#2\relax}}
1748%    \end{macrocode}
1749% \end{macro}
1750%
1751% \begin{macro}{\FancyVerbCodes}
1752%    \begin{macrocode}
1753\define@key{FV}{codes}[]{\def\FancyVerbCodes{#1\relax}}
1754\define@key{FV}{codes*}{%
1755  \expandafter\def\expandafter\FancyVerbCodes\expandafter{%
1756    \FancyVerbCodes#1\relax}}
1757\fvset{codes}
1758%    \end{macrocode}
1759% \end{macro}
1760%
1761%    \begin{macrocode}
1762\define@key{FV}{commandchars}[\\\{\}]%
1763  {\def\@tempa{#1}%
1764    \ifx\@tempa\FV@None
1765      \let\FV@CommandChars\relax
1766    \else
1767      \FV@DefineCommandChars#1\relax\relax\relax
1768    \fi}
1769%    \end{macrocode}
1770%
1771% \begin{macro}{\FV@DefineCommandChars}
1772%    \begin{macrocode}
1773\def\FV@DefineCommandChars#1#2#3{%
1774  \def\FV@CommandChars{%
1775    \catcode`#1=0\relax\catcode`#2=1\relax\catcode`#3=2\relax}}
1776%    \end{macrocode}
1777% \end{macro}
1778%
1779%    \begin{macrocode}
1780\FV@AddToHook\FV@CatCodesHook\FV@CommandChars
1781%    \end{macrocode}
1782%
1783% \begin{macro}{\FV@CommentChar}
1784%    \begin{macrocode}
1785\define@key{FV}{commentchar}[\%]{%
1786  \def\@tempa{#1}%
1787  \ifx\@tempa\FV@None
1788    \let\FV@CommentChar\relax
1789  \else
1790    \def\FV@CommentChar{\catcode`#1=14}%
1791  \fi}
1792%    \end{macrocode}
1793% \end{macro}
1794%
1795%    \begin{macrocode}
1796\FV@AddToHook\FV@CatCodesHook\FV@CommentChar
1797%    \end{macrocode}
1798%
1799%    \begin{macrocode}
1800\fvset{commandchars=none,commentchar=none}
1801%    \end{macrocode}
1802%
1803% \subsection{Preprocess line}
1804%
1805% These is tedious and takes up macro space, but it doesn't slow things
1806% down much when the parameters are not used.
1807%
1808% \noindent\texttt{start}, \texttt{stop} and \texttt{gobble} parameters:
1809%
1810% \noindent if value is a number, then after the assignment the next token is
1811% \cs{relax}.
1812%
1813%    \begin{macrocode}
1814\define@key{FV}{firstline}{%
1815  \afterassignment\FV@ParseStart\@tempcnta=0#1\relax\@nil{#1}}
1816%    \end{macrocode}
1817%
1818% \begin{macro}{\FV@ParseStart}
1819%    \begin{macrocode}
1820\def\FV@ParseStart#1\relax\@nil#2{%
1821  \ifx\@nil#1\@nil
1822    \edef\FancyVerbStartNum{\the\@tempcnta}%
1823    \let\FancyVerbStartString\relax
1824  \else
1825    \edef\FancyVerbStartString{#2}%
1826  \fi}
1827%    \end{macrocode}
1828% \end{macro}
1829%
1830% \begin{macro}{\KV@FV@firstline@default}
1831%    \begin{macrocode}
1832\def\KV@FV@firstline@default{%
1833  \let\FancyVerbStartNum\z@
1834  \let\FancyVerbStartString\relax}
1835%    \end{macrocode}
1836% \end{macro}
1837%
1838%    \begin{macrocode}
1839\define@key{FV}{lastline}{%
1840  \afterassignment\FV@ParseStop\@tempcnta=0#1\relax\@nil{#1}}
1841%    \end{macrocode}
1842%
1843% \begin{macro}{\FV@ParseStop}
1844%    \begin{macrocode}
1845\def\FV@ParseStop#1\relax\@nil#2{%
1846  \ifx\@nil#1\@nil
1847    \edef\FancyVerbStopNum{\the\@tempcnta}%
1848    \let\FancyVerbStopString\relax
1849  \else
1850    \edef\FancyVerbStopString{#2}%
1851  \fi}
1852%    \end{macrocode}
1853% \end{macro}
1854%
1855% \begin{macro}{\KV@FV@lastline@default}
1856%    \begin{macrocode}
1857\def\KV@FV@lastline@default{%
1858  \let\FancyVerbStopNum\z@
1859  \let\FancyVerbStopString\relax}
1860%    \end{macrocode}
1861% \end{macro}
1862%
1863%    \begin{macrocode}
1864\fvset{firstline,lastline}
1865%    \end{macrocode}
1866%
1867%    \begin{macrocode}
1868\newcount\FV@CodeLineNo
1869%    \end{macrocode}
1870%
1871% If \cs{FV@FindStartStop} determines the line should be printed, it
1872% executes \cs{FV@@PreProcessLine}
1873%
1874% \begin{macro}{\FV@PreProcessLine}
1875%    \begin{macrocode}
1876\def\FV@PreProcessLine{%
1877  \global\advance\FV@CodeLineNo\@ne
1878  \FV@FindStartStop}
1879%    \end{macrocode}
1880% \end{macro}
1881%
1882% \begin{macro}{\FV@@PreProcessLine}
1883%    \begin{macrocode}
1884\def\FV@@PreProcessLine{%
1885  \FV@StepLineNo
1886  \FV@Gobble
1887  \expandafter\FV@ProcessLine\expandafter{\FV@Line}}
1888%    \end{macrocode}
1889% \end{macro}
1890%
1891% The definition of \cs{FV@FindStartStop} changes, so that we don't
1892% have to check irrelevant conditions with each line.
1893%
1894% \begin{macro}{\FV@FindStartStop}
1895%    \begin{macrocode}
1896\def\FV@FindStartStop{\FV@DefineFindStart\FV@FindStartStop}
1897%    \end{macrocode}
1898% \end{macro}
1899%
1900%    \begin{macrocode}
1901%% \def\FV@DefinePreProcessLine{%
1902%%   \setcounter{FancyVerbLine}{0}%
1903%%   \FV@DefineFindStart}
1904%    \end{macrocode}
1905%
1906% \begin{macro}{\FV@DefineFindStart}
1907%    \begin{macrocode}
1908\def\FV@DefineFindStart{%
1909  \ifx\FancyVerbStartString\relax
1910    \ifnum\FancyVerbStartNum<\tw@
1911      \FV@DefineFindStop
1912    \else
1913      \let\FV@FindStartStop\FV@FindStartNum
1914    \fi
1915  \else
1916    \let\FV@FindStartStop\FV@FindStartString
1917  \fi}
1918%    \end{macrocode}
1919% \end{macro}
1920%
1921% \begin{macro}{\FV@FindStartNum}
1922%    \begin{macrocode}
1923\def\FV@FindStartNum{%
1924  \ifnum\FancyVerbStartNum>\FV@CodeLineNo\else
1925    \FV@DefineFindStop
1926    \expandafter\FV@@PreProcessLine
1927  \fi}
1928%    \end{macrocode}
1929% \end{macro}
1930%
1931% \begin{macro}{\FV@FindStartString}
1932%    \begin{macrocode}
1933%% SR modification begin - 1996
1934\def\FV@FindStartString{%
1935 \expandafter\FV@@FindStartString
1936{\meaning\FV@Line}%
1937{\meaning\FancyVerbStartString}%
1938}
1939%    \end{macrocode}
1940% \end{macro}
1941%
1942% \begin{macro}{\FV@@FindStartString}
1943%    \begin{macrocode}
1944\def\FV@@FindStartString#1#2{%
1945\edef\@fooA{#1}\edef\@fooB{#2}%
1946  \ifx\@fooA\@fooB
1947    \FV@DefineFindStop
1948  \fi
1949}
1950%% SR modification end
1951%    \end{macrocode}
1952% \end{macro}
1953%
1954% \begin{macro}{\FV@DefineFindStop}
1955%    \begin{macrocode}
1956\def\FV@DefineFindStop{%
1957  \ifx\FancyVerbStopString\relax
1958    \ifnum\FancyVerbStopNum<\@ne
1959      \let\FV@FindStartStop\FV@@PreProcessLine
1960    \else
1961      \let\FV@FindStartStop\FV@FindStopNum
1962    \fi
1963  \else
1964    \let\FV@FindStartStop\FV@FindStopString
1965  \fi}
1966%    \end{macrocode}
1967% \end{macro}
1968%
1969% \begin{macro}{\FV@FindStopNum}
1970%    \begin{macrocode}
1971\def\FV@FindStopNum{%
1972  \ifnum\FancyVerbStopNum=\FV@CodeLineNo
1973    \let\FV@FindStartStop\relax
1974    \ifeof\FV@InFile\else
1975      \immediate\closein\FV@InFile
1976    \fi
1977  \fi
1978  \FV@@PreProcessLine}
1979%    \end{macrocode}
1980% \end{macro}
1981%
1982% \begin{macro}{\FV@FindStopString}
1983%    \begin{macrocode}
1984%% SR modification begin - 1996
1985\def\FV@FindStopString{%
1986 \expandafter\FV@@FindStopString
1987{\meaning\FV@Line}%
1988{\meaning\FancyVerbStopString}%
1989}
1990%    \end{macrocode}
1991% \end{macro}
1992%
1993% \begin{macro}{\FV@@FindStopString}
1994%    \begin{macrocode}
1995\def\FV@@FindStopString#1#2{%
1996\edef\@fooA{#1}\edef\@fooB{#2}%
1997  \ifx\@fooA\@fooB
1998    \let\FV@FindStartStop\relax
1999    \ifeof\FV@InFile\else
2000      \immediate\closein\FV@InFile
2001    \fi
2002  \else
2003    \expandafter\FV@@PreProcessLine
2004  \fi}
2005%% SR modification end
2006%    \end{macrocode}
2007% \end{macro}
2008%
2009% Gobblings. \cs{FV@Gobble} does nothing, or strips some tokens from
2010% the line and stores the result in \cs{FV@Line} again. We use
2011% \LaTeX's \verb+\renewcommand+ to define a command for gobbling up to
2012% 9 arguments. This is not the same as removing 9 tokens, but is easier.
2013%
2014% \begin{macro}{\FV@@Gobble}
2015%    \begin{macrocode}
2016\def\FV@@Gobble{%
2017  \expandafter\expandafter\expandafter\FV@@@Gobble
2018  \expandafter\FV@@@@Gobble\FV@Line
2019    \@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@@nil}
2020%    \end{macrocode}
2021% \end{macro}
2022%
2023% \begin{macro}{\FV@@@Gobble}
2024%    \begin{macrocode}
2025\def\FV@@@Gobble#1\@nil#2\@@nil{\def\FV@Line{#1}}
2026%    \end{macrocode}
2027% \end{macro}
2028%
2029% \begin{macro}{\FV@Gobble}
2030%    \begin{macrocode}
2031\define@key{FV}{gobble}{%
2032  \@tempcnta=#1\relax
2033  \ifnum\@tempcnta<\@ne
2034    \let\FV@Gobble\relax
2035  \else
2036    \ifnum\@tempcnta>9
2037      \FV@Error{gobble parameter must be less than 10}\FV@eha
2038    \else
2039      \renewcommand{\FV@@@@Gobble}[\@tempcnta]{}%
2040      \let\FV@Gobble\FV@@Gobble
2041    \fi
2042  \fi}
2043%    \end{macrocode}
2044% \end{macro}
2045%
2046% \begin{macro}{\FV@@@@Gobble}
2047%    \begin{macrocode}
2048\def\FV@@@@Gobble{}
2049%    \end{macrocode}
2050% \end{macro}
2051%
2052% \begin{macro}{\KV@FV@gobble@default}
2053%    \begin{macrocode}
2054\def\KV@FV@gobble@default{\let\FV@Gobble\relax}
2055%    \end{macrocode}
2056% \end{macro}
2057%
2058%    \begin{macrocode}
2059\fvset{gobble}
2060%    \end{macrocode}
2061%
2062% \subsection{Scanning environments}
2063%
2064% \begin{macro}{\FV@Scan}
2065%    \begin{macrocode}
2066\def\FV@Scan{%
2067    \FV@CatCodes
2068    \VerbatimEnvironment
2069    \FV@DefineCheckEnd
2070    \FV@BeginScanning}
2071%    \end{macrocode}
2072% \end{macro}
2073%
2074% \cs{VerbatimEnvironment}:
2075%
2076% This saves the name of the current environment as
2077% \cs{FV@EnvironName}, if the latter is not already defined.
2078% Then \cs{FV@CheckEnd} knows how to find the end as long as either:
2079% \begin{itemize}
2080%   \item \verb+\begin+ and \verb+\end+ are not used within the definition of
2081%         the environment, OR
2082%   \item \cs{VerbatimEnvironment} is used in the definition before the first
2083%         \verb+\begin+.
2084%  \end{itemize}
2085%
2086% \begin{macro}{\VerbatimEnvironment}
2087%    \begin{macrocode}
2088\def\VerbatimEnvironment{%
2089  \ifx\FV@EnvironName\relax\xdef\FV@EnvironName{\@currenvir}\fi}
2090%    \end{macrocode}
2091% \end{macro}
2092%
2093%    \begin{macrocode}
2094\let\FV@EnvironName\relax
2095%    \end{macrocode}
2096%
2097%\subsection{Check end}
2098%
2099% We have to check the argument of the first \verb+\end{}+ in each line,
2100% compare it with \cs{FV@EnvironName}, and return \verb+\iftrue+ if it matches
2101% and \verb+\iffalse+ otherwise.
2102%
2103% There are four cases (R=regular):
2104%
2105% \begin{tabbing}
2106%   catcode of \verb+{}+  \= : \= R \= 12 \= 12  \= 12 \kill
2107%                   case  \> : \> i \> ii \> iii \> iv \\
2108%    catcode of \verb+\+  \> : \> R \> 12 \> 12  \> R  \\
2109%    catcode of \verb+{}+ \> : \> R \> R  \> 12  \> 12
2110% \end{tabbing}
2111%
2112% For uniformity, we use \verb+![]+ instead of \verb+\{}+ in all the
2113% definitions.
2114%
2115% We first set the catcodes of \verb+\{}+ to those in effect in the
2116% verbatim environment. Then we define:
2117%
2118%   \verb+!def!FV@CheckEnd#1[!FV@@CheckEnd#1\end{}!@nil]+
2119%
2120% \noindent If {} have their usual catcodes, we define:
2121%
2122%   \verb+!def!FV@@CheckEnd#1\end#2#3!@nil[!def!@tempa[#2]]+
2123%
2124% \noindent If {} have catcode 12, we define:
2125%
2126%   \verb+!def!FV@@CheckEnd#1\end{#2}#3!@nil[!def!@tempa[#2]]+
2127%
2128%    \begin{macrocode}
2129\begingroup
2130\catcode`\!=0
2131\catcode`\[=1
2132\catcode`\]=2
2133%    \end{macrocode}
2134%
2135% Case i:
2136%
2137%    \begin{macrocode}
2138!gdef!FV@CheckEnd@i#1[!FV@@CheckEnd#1\end{}!@nil]
2139!gdef!FV@@CheckEnd@i#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
2140!gdef!FV@@@CheckEnd@i[\end{}]
2141%    \end{macrocode}
2142%
2143% Case ii:
2144%
2145%    \begin{macrocode}
2146\catcode`!\=12
2147
2148!gdef!FV@CheckEnd@ii#1[!FV@@CheckEnd#1\end{}!@nil]
2149!gdef!FV@@CheckEnd@ii#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
2150!gdef!FV@@@CheckEnd@ii[\end{}]
2151%    \end{macrocode}
2152%
2153% Case iii:
2154%
2155%    \begin{macrocode}
2156!catcode`!{=12
2157!catcode`!}=12
2158
2159!gdef!FV@CheckEnd@iii#1[!FV@@CheckEnd#1\end{}!@nil]
2160!gdef!FV@@CheckEnd@iii#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
2161!gdef!FV@@@CheckEnd@iii[\end{}]
2162%    \end{macrocode}
2163%
2164% Case iv:
2165%
2166%    \begin{macrocode}
2167!catcode`!\=0
2168
2169!gdef!FV@CheckEnd@iv#1[!FV@@CheckEnd#1\end{}!@nil]
2170!gdef!FV@@CheckEnd@iv#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
2171!gdef!FV@@@CheckEnd@iv[\end{}]
2172%    \end{macrocode}
2173%
2174%    \begin{macrocode}
2175\endgroup
2176%    \end{macrocode}
2177%
2178% \begin{macro}{\FV@BadCodes}
2179%    \begin{macrocode}
2180\def\FV@BadCodes#1{%
2181  \FV@Error
2182    {\string\catcode\space of \expandafter\@gobble\string#1 is wrong:
2183    \the\catcode`#1}%
2184    {Only the following catcode values are allowed:
2185    ^^J\@spaces \expandafter\@gobble\string\\ \space\space --> 0 or 12.
2186    ^^J\@spaces \string{ \string} --> 1 and 2, resp., or both 12.
2187    ^^JTo get this error, either you are a hacker or you got bad advice.}%
2188  \def\FV@CheckEnd##1{\iftrue}}
2189%    \end{macrocode}
2190% \end{macro}
2191%
2192% \begin{macro}{\FV@DefineCheckEnd}
2193%    \begin{macrocode}
2194\def\FV@DefineCheckEnd{%
2195  \ifnum\catcode`\\=\z@
2196    \ifnum\catcode`\{=\@ne
2197      \let\FV@CheckEnd\FV@CheckEnd@i
2198      \let\FV@@CheckEnd\FV@@CheckEnd@i
2199      \let\FV@@@CheckEnd\FV@@@CheckEnd@i
2200    \else
2201      \ifnum\catcode`\{=12
2202        \let\FV@CheckEnd\FV@CheckEnd@iv
2203        \let\FV@@CheckEnd\FV@@CheckEnd@iv
2204        \let\FV@@@CheckEnd\FV@@@CheckEnd@iv
2205      \else
2206        \FV@BadCodes\{%
2207      \fi
2208    \fi
2209  \else
2210    \ifnum\catcode`\\=12
2211      \ifnum\catcode`\{=\@ne
2212        \let\FV@CheckEnd\FV@CheckEnd@ii
2213        \let\FV@@CheckEnd\FV@@CheckEnd@ii
2214        \let\FV@@@CheckEnd\FV@@@CheckEnd@ii
2215      \else
2216        \ifnum\catcode`\{=12
2217          \let\FV@CheckEnd\FV@CheckEnd@iii
2218          \let\FV@@CheckEnd\FV@@CheckEnd@iii
2219          \let\FV@@@CheckEnd\FV@@@CheckEnd@iii
2220        \else
2221          \FV@BadCodes\{%
2222        \fi
2223      \fi
2224    \else
2225      \FV@BadCodes\\%
2226    \fi
2227  \fi}
2228%    \end{macrocode}
2229% \end{macro}
2230%
2231% \subsection{Line-by-line scanning}
2232%
2233% We first skip everything after the beginning of the environment.
2234%
2235% \begin{macro}{\FV@BeginScanning}
2236%    \begin{macrocode}
2237\begingroup
2238\catcode`\^^M=\active
2239  \gdef\FV@BeginScanning#1^^M{%
2240    \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi%
2241    \FV@GetLine}%
2242\endgroup
2243%    \end{macrocode}
2244% \end{macro}
2245%
2246% \begin{macro}{\FV@BadBeginError}
2247%    \begin{macrocode}
2248\def\FV@BadBeginError#1{%
2249  \expandafter\@temptokena\expandafter{\@tempa}%
2250  \FV@Error
2251    {Extraneous input `\the\@temptokena' between
2252      \string\begin{\FV@EnvironName}[<key=value>] and line end}%
2253   {This input will be discarded. Hit <return> to continue.}}
2254%    \end{macrocode}
2255% \end{macro}
2256%
2257% If \cs{FancyVerbGetLine} does not find a \verb+^^M+, then we are at
2258% the end of the file, and \cs{FV@EOF} attempts to terminate the document.
2259% Otherwise, \cs{FV@EOF} is gobbled by \cs{FancyVerbGetLine}.
2260%
2261% \ifChangeBar\begin{changebar}\fi
2262% \begin{macro}{\FV@GetLine}
2263%    \begin{macrocode}
2264%% DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures)
2265%% \def\FV@GetLine{\expandafter\FV@CheckScan\FancyVerbGetLine}
2266\def\FV@GetLine{\@noligs\expandafter\FV@CheckScan\FancyVerbGetLine}
2267%% DG/SR modification end
2268%    \end{macrocode}
2269% \end{macro}
2270% \ifChangeBar\end{changebar}\fi
2271%
2272% \begin{macro}{\FancyVerbGetLine}
2273%    \begin{macrocode}
2274\begingroup
2275\catcode`\^^M=\active
2276\gdef\FancyVerbGetLine#1^^M{%
2277  \@nil
2278  \FV@CheckEnd{#1}%
2279  \ifx\@tempa\FV@EnvironName%            % True if end is found
2280    \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi%
2281    \let\next\FV@EndScanning%
2282  \else%
2283    \def\FV@Line{#1}%
2284    \def\next{\FV@PreProcessLine\FV@GetLine}%
2285  \fi%
2286  \next}%
2287\endgroup
2288%    \end{macrocode}
2289% \end{macro}
2290%
2291% \begin{macro}{\FV@BadEndError}
2292%    \begin{macrocode}
2293\def\FV@BadEndError{%
2294  \expandafter\@temptokena\expandafter{\@tempb}%
2295  \FV@Error
2296      {Extraneous input `\the\@temptokena' between
2297        \string\end{\FV@EnvironName} and line end}%
2298      {This input will be discarded. Type <return> to continue.}}
2299%    \end{macrocode}
2300% \end{macro}
2301%
2302% \begin{macro}{\FV@EndScanning}
2303%    \begin{macrocode}
2304\def\FV@EndScanning{%
2305  \edef\next{\noexpand\end{\FV@EnvironName}}%
2306  \global\let\FV@EnvironName\relax
2307  \next}
2308%    \end{macrocode}
2309% \end{macro}
2310%
2311%    \begin{macrocode}
2312\@ifundefined{@currenvline}{\let\@currenvline\@empty}{}
2313%    \end{macrocode}
2314%
2315% \begin{macro}{\FV@CheckScan}
2316%    \begin{macrocode}
2317\def\FV@CheckScan#1{\@ifnextchar\@nil{\@gobble}{\FV@EOF}}
2318\def\FV@CheckScan#1{\ifx\@nil#1\@empty\else\expandafter\FV@EOF\fi}
2319%    \end{macrocode}
2320% \end{macro}
2321%
2322% \begin{macro}{\FV@EOF}
2323%    \begin{macrocode}
2324\def\FV@EOF{%
2325  \FV@Error{Couldn't find `\string\end{\FV@EnvironName}' to end
2326    a verbatim environment\@currenvline.}%
2327    {Probably you mistyped the environment name or included an extraneous
2328    ^^Jspace, or are using an improperly defined verbatim environment.
2329    ^^JHit return and I will try to terminate this job.}%
2330  \FV@EndScanning
2331  \end{document}}
2332%    \end{macrocode}
2333% \end{macro}
2334%
2335                                % \subsection{Input}
2336%
2337%    \begin{macrocode}
2338\newread\FV@InFile
2339%    \end{macrocode}
2340%
2341% \begin{macro}{\FV@Input}
2342%    \begin{macrocode}
2343\def\FV@Input#1{%
2344  \immediate\openin\FV@InFile #1\relax
2345  \ifeof\FV@InFile
2346    \FV@Error{No verbatim file #1}\FV@eha
2347    \immediate\closein\FV@InFile
2348  \else
2349    \FV@CatCodes
2350    \expandafter\FV@@Input
2351  \fi}
2352%    \end{macrocode}
2353% \end{macro}
2354%
2355% \noindent\TeX{} reports EOF when reading after the last newline character.
2356%
2357% \noindent Thus, we read to InLine, and if \TeX{} reports EOF:
2358% \begin{itemize}
2359%   \item If InLine=Empty, previous line was last line in file (file ends nl).
2360%   \item Otherwise, InLine holds last line in file (file doesn't end in nl).
2361% \end{itemize}
2362% \cs{FV@@Input} handles both cases correctly.
2363%
2364% \begin{macro}{\FV@@Input}
2365%    \begin{macrocode}
2366\def\FV@@Input{%
2367  \def\FV@Line{}%
2368  \FV@ReadLine
2369  \ifeof\FV@InFile
2370    \ifx\FV@Line\@empty\else
2371      \FV@PreProcessLine
2372    \fi
2373    \immediate\closein\FV@InFile
2374  \else
2375    \FV@PreProcessLine
2376    \expandafter\FV@@Input
2377  \fi}
2378%    \end{macrocode}
2379% \end{macro}
2380%
2381% We also want to handle true comment characters correctly. This means that
2382% we keep accumulating text in InLine until we find a \verb+^^M+ (indicating
2383% that the line did not contain a comment character).
2384%
2385% \begin{macro}{\FV@ReadLine}
2386%    \begin{macrocode}
2387\begingroup
2388\catcode`\^^M=\active
2389\gdef\FV@ReadLine{%
2390  \ifeof\FV@InFile\else
2391    \immediate\read\FV@InFile to\@tempa%
2392    \expandafter\FV@@ReadLine\@tempa^^M\relax^^M\@nil%
2393  \fi}
2394%    \end{macrocode}
2395% \end{macro}
2396%
2397% \verb+#2+ is empty if line ends in \verb+^^M+, \verb+#2=\relax+ otherwise
2398%
2399% \begin{macro}{\FV@@ReadLine}
2400%    \begin{macrocode}
2401\gdef\FV@@ReadLine#1^^M#2^^M#3\@nil{%
2402  \expandafter\def\expandafter\FV@Line\expandafter{%
2403    \FV@Line#1}%
2404  \ifx\relax#2\@empty\expandafter\FV@ReadLine\fi}%
2405\endgroup
2406%    \end{macrocode}
2407% \end{macro}
2408%
2409% \subsection{Formatting -- Common components}
2410%
2411% Some things that are common to all verbatim formatting:
2412%
2413% \begin{macro}{\FV@FormattingPrep}
2414%    \begin{macrocode}
2415\def\FV@FormattingPrep{%
2416  \global\FV@CodeLineNo\z@
2417  \frenchspacing             % Cancels special punctuation spacing.
2418  \FV@SetupFont              % See below.
2419  \FV@DefineWhiteSpace       % See below.
2420  \FancyVerbDefineActive
2421  \FancyVerbFormatCom}       % A user-defined hook (formatcom parameter).
2422%    \end{macrocode}
2423% \end{macro}
2424%
2425% Fonts
2426%
2427% \changes{v2.6}{1998/07/17}{Correct a bug for the -- ligature in T1 encoding
2428%                            (reported by Mario Hassler on May 12, 1998).}
2429%
2430%    \begin{macrocode}
2431\expandafter\ifx\csname selectfont\endcsname\relax
2432%    \end{macrocode}
2433%
2434% \begin{macro}{\FV@SetupFont}
2435%    \begin{macrocode}
2436\def\FV@SetupFont{%
2437  \FV@BaseLineStretch
2438  \ifx\@currsize\small\normalsize\else\small\fi\@currsize
2439  \FV@FontSize
2440  \FV@FontFamily}
2441
2442\else
2443
2444\def\FV@SetupFont{%
2445  \FV@BaseLineStretch
2446  \FV@FontSize
2447  \FV@FontFamily
2448  \FV@FontSeries
2449  \FV@FontShape
2450  \selectfont
2451%% DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures)
2452  \@noligs}
2453%% DG/SR modification end
2454%    \end{macrocode}
2455% \end{macro}
2456%
2457%    \begin{macrocode}
2458\fi
2459%    \end{macrocode}
2460%
2461% \begin{macro}{\FV@FontSize}
2462%    \begin{macrocode}
2463\define@key{FV}{fontsize}{%
2464  \def\@tempa{#1}%
2465  \ifx\@tempa\FV@Auto
2466    \let\FV@FontSize\relax
2467  \else
2468    \def\FV@FontSize{#1}%
2469  \fi}
2470%    \end{macrocode}
2471% \end{macro}
2472%
2473% \begin{macro}{\KV@FV@fontsize@default}
2474%    \begin{macrocode}
2475\def\KV@FV@fontsize@default{\let\FV@FontSize\relax}
2476%    \end{macrocode}
2477% \end{macro}
2478%
2479% \begin{macro}{\FV@BaseLineStretch}
2480%    \begin{macrocode}
2481\define@key{FV}{baselinestretch}[auto]{%
2482  \def\@tempa{#1}%
2483  \ifx\@tempa\FV@Auto
2484    \let\FV@BaseLineStretch\relax
2485  \else
2486    \def\FV@BaseLineStretch{\def\baselinestretch{#1}}%
2487  \fi}
2488%    \end{macrocode}
2489% \end{macro}
2490%
2491% \begin{macro}{\KV@FV@baselinestretch@default}
2492%    \begin{macrocode}
2493\def\KV@FV@baselinestretch@default{\let\FV@BaseLineStretch\relax}
2494%    \end{macrocode}
2495% \end{macro}
2496%
2497%    \begin{macrocode}
2498\define@key{FV}{fontfamily}{%
2499  \@ifundefined{FV@fontfamily@#1}%
2500    {\def\FV@FontScanPrep{}\def\FV@FontFamily{\fontfamily{#1}}}
2501    {\csname FV@fontfamily@#1\endcsname}}
2502%    \end{macrocode}
2503%
2504% \begin{macro}{\FV@FontSeries}
2505%    \begin{macrocode}
2506\define@key{FV}{fontseries}{%
2507  \def\@tempa{#1}%
2508  \ifx\@tempa\FV@Auto
2509    \let\FV@FontSeries\relax
2510  \else
2511    \def\FV@FontSeries{\fontseries{#1}}%
2512  \fi}
2513%    \end{macrocode}
2514% \end{macro}
2515%
2516% \begin{macro}{\FV@FontShape}
2517%    \begin{macrocode}
2518\define@key{FV}{fontshape}{%
2519  \def\@tempa{#1}%
2520  \ifx\@tempa\FV@Auto
2521    \let\FV@FontShape\relax
2522  \else
2523    \def\FV@FontShape{\fontshape{#1}}%
2524  \fi}
2525%    \end{macrocode}
2526% \end{macro}
2527%
2528% Font family styles have to define \cs{FV@FontScanPrep} and
2529% \cs{FV@FontFamily}.
2530%
2531% \begin{macro}{\FV@MakeActive}
2532%    \begin{macrocode}
2533\def\FV@MakeActive#1{%
2534  \catcode`#1=\active
2535  \def\next##1{\expandafter\def\expandafter\FV@MakeUnActive\expandafter{%
2536    \FV@MakeUnActive\def##1{\string##1}}}%
2537  \begingroup\lccode`~=`#1\relax\expandafter\next\expandafter~\endgroup}
2538%    \end{macrocode}
2539% \end{macro}
2540%
2541% \begin{macro}{\FV@MakeUnActive}
2542%    \begin{macrocode}
2543\def\FV@MakeUnActive{}
2544%    \end{macrocode}
2545% \end{macro}
2546%
2547%    \begin{macrocode}
2548\begingroup
2549\catcode`\`=\active
2550%    \end{macrocode}
2551%
2552% \begin{macro}{\FV@fontfamily@tt}
2553%    \begin{macrocode}
2554\gdef\FV@fontfamily@tt{%
2555  \def\FV@FontScanPrep{\FV@MakeActive\`}%
2556%% SR modification begin - 1995
2557%%  \def\FV@FontFamily{\tt`{{\string`}}}}
2558  \def\FV@FontFamily{\ttfamily\edef`{{\string`}}}}
2559%% SR modification end
2560%    \end{macrocode}
2561% \end{macro}
2562%
2563% \begin{macro}{\FV@fontfamily@cmtt}
2564%    \begin{macrocode}
2565\gdef\FV@fontfamily@cmtt{%
2566  \def\FV@FontScanPrep{\FV@MakeActive\`}%
2567  \def\FV@FontFamily{\edef`{{\string`}}\fontfamily{cmtt}}}
2568%    \end{macrocode}
2569% \end{macro}
2570%
2571%    \begin{macrocode}
2572\endgroup
2573%    \end{macrocode}
2574%
2575% \begin{macro}{\FV@fontfamily@cmtt-spanish}
2576%    \begin{macrocode}
2577\@namedef{FV@fontfamily@cmtt-spanish}{%
2578  \def\FV@FontScanPrep{}%
2579  \def\FV@FontFamily{\fontfamily{cmtt}}}
2580%    \end{macrocode}
2581% \end{macro}
2582%
2583% Fix me
2584%
2585% \begin{macro}{\FV@fontfamily@courier}
2586%    \begin{macrocode}
2587\@namedef{FV@fontfamily@courier}{%
2588  \def\FV@FontScanPrep{}%
2589%% SR modification begin - 1995
2590%%  \def\FV@FontFamily{\fontfamily{rpcr}}}
2591  \def\FV@FontFamily{\fontfamily{pcr}}}
2592%% SR modification end
2593%    \end{macrocode}
2594% \end{macro}
2595%
2596% \begin{macro}{\FV@fontfamily@helvetica}
2597%    \begin{macrocode}
2598\@namedef{FV@fontfamily@helvetica}{%
2599  \def\FV@FontScanPrep{}%
2600%% SR modification begin - 1995
2601%%  \def\FV@FontFamily{\fontfamily{rphv}}}
2602  \def\FV@FontFamily{\fontfamily{phv}}}
2603%% SR modification end
2604%    \end{macrocode}
2605% \end{macro}
2606%
2607%    \begin{macrocode}
2608\fvset{fontfamily=tt,fontsize=auto,fontshape=auto,fontseries=auto,
2609  baselinestretch=auto}
2610%    \end{macrocode}
2611%
2612% \cs{FV@DefineWhiteSpace}
2613%
2614% We just define the active characters to be ordinary commands, which
2615% are easier to redefine. We do with any macros that use verbatim text.
2616%
2617%    \begin{macrocode}
2618\begingroup
2619\catcode`\ =\active
2620\catcode`\^^I=\active
2621%    \end{macrocode}
2622%
2623% \begin{macro}{\FV@DefineWhiteSpace}
2624%    \begin{macrocode}
2625\gdef\FV@DefineWhiteSpace{\def {\FV@Space}\def^^I{\FV@Tab}}%
2626%    \end{macrocode}
2627% \end{macro}
2628%
2629%    \begin{macrocode}
2630\endgroup
2631%    \end{macrocode}
2632%
2633% \begin{macro}{\FancyVerbDefineActive}
2634%    \begin{macrocode}
2635\define@key{FV}{defineactive}[]{\def\FancyVerbDefineActive{#1\relax}}
2636\define@key{FV}{defineactive*}{%
2637  \expandafter\def\expandafter\FancyVerbDefineActive\expandafter{%
2638    \FancyVerbDefineActive#1\relax}}
2639\fvset{defineactive}
2640%    \end{macrocode}
2641% \end{macro}
2642%
2643% \cs{FV@Space}:
2644%
2645% \begin{macro}{\FV@Space}
2646%    \begin{macrocode}
2647\define@booleankey{FV}{showspaces}%
2648  {\def\FV@Space{{\FancyVerbSpace}}}%
2649  {\def\FV@Space{\ }}
2650%    \end{macrocode}
2651% \end{macro}
2652%
2653%    \begin{macrocode}
2654{\catcode`\ =12 \gdef\FancyVerbSpace{\tt }}
2655%    \end{macrocode}
2656%
2657%    \begin{macrocode}
2658\fvset{showspaces=false}
2659%    \end{macrocode}
2660%
2661% \cs{FV@Tab}:
2662%
2663% \begin{macro}{\FV@Tab}
2664%    \begin{macrocode}
2665\def\FV@Tab{\hbox to\FancyVerbTabSize\fontdimen2\font{\hss\FV@TabChar}}
2666%    \end{macrocode}
2667% \end{macro}
2668%
2669% \begin{macro}{\FancyVerbTabSize}
2670%    \begin{macrocode}
2671\define@key{FV}{tabsize}{%
2672  \@tempcnta=#1\relax
2673  \ifnum\@tempcnta>100
2674    \FV@Error{Tab size too large: `\the\@tempcnta'. (Max size = 100)}\FV@eha
2675  \else
2676    \edef\FancyVerbTabSize{\the\@tempcnta}%
2677  \fi}
2678%    \end{macrocode}
2679% \end{macro}
2680%
2681% \begin{macro}{\FV@TabChar}
2682%    \begin{macrocode}
2683\define@booleankey{FV}{showtabs}%
2684  {\def\FV@TabChar{\FancyVerbTab}}%
2685  {\let\FV@TabChar\relax}
2686%    \end{macrocode}
2687% \end{macro}
2688%
2689%    \begin{macrocode}
2690\fvset{tabsize=8,showtabs=false}
2691%    \end{macrocode}
2692%
2693% Here is a weak attempt at a tab character. It may exceed the width
2694% of a space character when the verbatim font is small. The only proper way
2695% to do this is making it part of the verbatim font.
2696%
2697% \begin{macro}{\FancyVerbTab}
2698%    \begin{macrocode}
2699\def\FancyVerbTab{%
2700    \valign{%
2701      \vfil##\vfil\cr
2702      \hbox{$\scriptscriptstyle-$}\cr
2703      \hbox to 0pt{\hss$\scriptscriptstyle\rangle\mskip -.8mu$}\cr
2704      \hbox{$\scriptstyle\mskip -3mu\mid\mskip -1.4mu$}\cr}}
2705%    \end{macrocode}
2706% \end{macro}
2707%
2708% Obey Tabs:
2709%
2710%    \begin{macrocode}
2711\newbox\FV@TabBox
2712%    \end{macrocode}
2713%
2714% \begin{macro}{\FV@@ObeyTabsInit}
2715%    \begin{macrocode}
2716\def\FV@@ObeyTabsInit{%
2717  \@tempdimb=\FancyVerbTabSize\fontdimen\tw@\font
2718  \edef\FV@ObeyTabSize{\number\@tempdimb}%
2719  \advance\@tempdimb\fontdimen\tw@\font
2720  \advance\@tempdimb-\FancyVerbTabSize sp  % Allow for rounding errors.
2721  \edef\FV@@ObeyTabSize{\number\@tempdimb}%
2722  \let\FV@ObeyTabs\FV@@ObeyTabs
2723  \let\FV@Tab\FV@TrueTab}
2724%    \end{macrocode}
2725% \end{macro}
2726%
2727% \begin{macro}{\FV@@ObeyTabs}
2728%    \begin{macrocode}
2729\def\FV@@ObeyTabs#1{\setbox\FV@TabBox=\hbox{#1}\box\FV@TabBox}
2730%    \end{macrocode}
2731% \end{macro}
2732%
2733%    \begin{macrocode}
2734\let\FV@ObeyTabs\relax
2735%    \end{macrocode}
2736%
2737% \begin{macro}{\FV@TrueTab}
2738%    \begin{macrocode}
2739\def\FV@TrueTab{%
2740  \egroup
2741  \@tempdima=\FV@ObeyTabSize sp\relax
2742  \@tempcnta=\wd\FV@TabBox
2743  \advance\@tempcnta\FV@@ObeyTabSize\relax
2744  \divide\@tempcnta\@tempdima
2745  \multiply\@tempdima\@tempcnta
2746  \advance\@tempdima-\wd\FV@TabBox
2747  \setbox\FV@TabBox=\hbox\bgroup
2748    \unhbox\FV@TabBox\kern\@tempdima\hbox to\z@{\hss\FV@TabChar}}
2749%    \end{macrocode}
2750% \end{macro}
2751%
2752% \begin{macro}{\FV@ObeyTabsInit}
2753%    \begin{macrocode}
2754\define@booleankey{FV}{obeytabs}%
2755  {\let\FV@ObeyTabsInit\FV@@ObeyTabsInit}%
2756  {\let\FV@ObeyTabsInit\relax}
2757%    \end{macrocode}
2758% \end{macro}
2759%
2760%    \begin{macrocode}
2761\fvset{obeytabs=false}
2762%    \end{macrocode}
2763%
2764% \cs{FancyVerbFormatCom}
2765%
2766% \begin{macro}{\FancyVerbFormatCom}
2767%    \begin{macrocode}
2768\define@key{FV}{formatcom}[]{\def\FancyVerbFormatCom{#1\relax}}
2769\define@key{FV}{formatcom*}{%
2770  \expandafter\def\expandafter\FancyVerbFormatCom\expandafter{%
2771    \FancyVerbFormatCom#1\relax}}
2772%    \end{macrocode}
2773% \end{macro}
2774%
2775%    \begin{macrocode}
2776\fvset{formatcom}
2777%    \end{macrocode}
2778%
2779% \begin{macro}{\FancyVerbFormatLine}
2780%    \begin{macrocode}
2781\def\FancyVerbFormatLine#1{\FV@ObeyTabs{#1}}
2782%    \end{macrocode}
2783% \end{macro}
2784%
2785% \subsection{List environments}
2786%
2787% Some parameters:
2788%
2789% \begin{macro}{\FV@XLeftMargin}
2790%    \begin{macrocode}
2791\define@key{FV}{xleftmargin}{\def\FV@XLeftMargin{#1}}
2792\let\FV@XLeftMargin\z@
2793%    \end{macrocode}
2794% \end{macro}
2795%
2796% \begin{macro}{\FV@XRightMargin}
2797%    \begin{macrocode}
2798\define@key{FV}{xrightmargin}{\def\FV@XRightMargin{#1}}
2799\let\FV@XRightMargin\z@
2800%    \end{macrocode}
2801% \end{macro}
2802%
2803% \begin{macro}{\if@FV@ResetMargins}
2804%    \begin{macrocode}
2805\define@booleankey{FV}{resetmargins}%
2806  {\let\if@FV@ResetMargins\iftrue}
2807  {\let\if@FV@ResetMargins\iffalse}
2808\fvset{resetmargins=false}
2809%    \end{macrocode}
2810% \end{macro}
2811%
2812% \begin{macro}{\FV@ListParameterHook}
2813%    \begin{macrocode}
2814\define@key{FV}{listparameters}{\def\FV@ListParameterHook{#1}}
2815\def\FV@ListParameterHook{}
2816%    \end{macrocode}
2817% \end{macro}
2818%
2819% \begin{macro}{\FancyVerbHFuzz}
2820%    \begin{macrocode}
2821\define@key{FV}{hfuzz}{%
2822  \@tempdima=#1\relax
2823  \edef\FancyVerbHFuzz{\number\@tempdima sp}}
2824\fvset{hfuzz=2pt}
2825%    \end{macrocode}
2826% \end{macro}
2827%
2828% \begin{macro}{\FV@InterLinePenalty}
2829%    \begin{macrocode}
2830\define@booleankey{FV}{samepage}%
2831  {\def\FV@InterLinePenalty{\interlinepenalty\@M}}%
2832  {\let\FV@InterLinePenalty\relax}
2833\fvset{samepage=false}
2834%    \end{macrocode}
2835% \end{macro}
2836%
2837%
2838% \noindent Lists:
2839%
2840% \verb+\FV@List{}+ is a rewriting of \verb+\list{}{}\item[]+.
2841% The rewrite gives me more control.
2842% I might not get the vertical spacing exactly the same, but it
2843% is more likely that it will get better than worse.
2844%
2845% The verbatim environment consists of a series of \verb+\hbox+'s inserted in
2846% vertical mode.
2847%
2848% \noindent We need to take care of the following:
2849% \begin{itemize}
2850%   \item leftmargin
2851%   \item rightmargin
2852%   \item topskip
2853%   \item botskip
2854%   \item toppenalty
2855%   \item botpenalty
2856%   \item interlinepenalties
2857% \end{itemize}
2858%
2859% Note: A verbatim environment immediately after an \verb+\item+ starts on
2860%       the same line as the \verb+\item+'s label, unless we reset margins.
2861%       The user can instead have the environment start on a new
2862%       line by inserting \verb+`\ '+ between \verb+\item+ and the environment.
2863%
2864% \begin{macro}{\FV@List}
2865%    \begin{macrocode}
2866\def\FV@List#1{%
2867  \begingroup
2868  \FV@UseKeyValues
2869  \FV@LeaveVMode
2870  \if@inlabel\else\setbox\@labels=\box\voidb@x\fi
2871  \FV@ListNesting{#1}%
2872  \FV@ListParameterHook
2873  \FV@ListVSpace
2874  \FV@SetLineWidth
2875  \FV@InterLinePenalty
2876  \let\FV@ProcessLine\FV@ListProcessLine@i
2877  \FV@CatCodes
2878  \FV@FormattingPrep
2879  \FV@ObeyTabsInit
2880  \FV@BeginListFrame}
2881%    \end{macrocode}
2882% \end{macro}
2883%
2884%
2885% \noindent Cases where we need to leave vmode:
2886% \begin{itemize}
2887%   \item After an in-line section (\verb+\if@noskipsec=T+).
2888%   \item After an \verb+\item+ command, if we reset margins.
2889% \end{itemize}
2890%
2891% Then we end \verb+\vmode+, using \verb+@noparlist+ as a flag if in vmode.
2892% (Not the usual meaning of \verb+@noparlist+.)
2893%
2894% \begin{macro}{\FV@LeaveVMode}
2895%    \begin{macrocode}
2896\def\FV@LeaveVMode{%
2897  \if@noskipsec
2898    \leavevmode
2899  \else
2900    \if@FV@ResetMargins\if@inlabel\leavevmode\fi\fi
2901  \fi
2902  \ifvmode\@noparlisttrue\else\@noparlistfalse\unskip\par\fi}
2903%    \end{macrocode}
2904% \end{macro}
2905%
2906% \begin{macro}{\FV@ListNesting}
2907%    \begin{macrocode}
2908\def\FV@ListNesting#1{%
2909  \if@FV@ResetMargins
2910    \@listdepth=\z@
2911  \else
2912    \ifnum\@listdepth>5\relax
2913      \@toodeep
2914    \else
2915      \advance\@listdepth\@ne
2916    \fi
2917  \fi
2918  \rightmargin\z@
2919  \csname @list\romannumeral\the\@listdepth\endcsname
2920  \ifnum#1=\z@
2921    \rightmargin\z@
2922    \leftmargin\z@
2923  \fi}
2924%    \end{macrocode}
2925% \end{macro}
2926%
2927%
2928% \noindent \cs{FV@ListVSpace} contains selected parts of \cs{@trivlist} and
2929% \cs{@item}.
2930%
2931% \noindent Here are the cases:
2932%
2933% \noindent Vmode not in label or after \verb+@NOBREAK+:
2934% \begin{tabbing}
2935%   \verb+<toppenalty>+ \= = \kill
2936%   \verb+<topskip>+    \> = \verb!\topsep + \partopsep + \parskip! \\
2937%   \verb+<botskip>+    \> = \verb!\topsep + \partopsep! \\
2938%   \verb+<toppenalty>+ \> = \verb+\@beginparpenalty+ \\
2939%   \verb+<botpenalty>+ \> = \verb+\@endparpenalty+
2940% \end{tabbing}
2941%
2942% \noindent Vmode in label:
2943% \begin{tabbing}
2944%   \verb+<toppenalty>+ \= = \verb!\topsep + \partopsep! \= \% \kill
2945%   \verb+<topskip>+    \> = \verb+\parskip+             \> \% Expected
2946%                                                             anyway. \\
2947%   \verb+<botskip>+    \> = \verb!\topsep + \partopsep! \> \% Omitted
2948%                                              in \LaTeX{} -- a bug? \\
2949%   \verb+<toppenalty>+ \> = None \\
2950%   \verb+<botpenalty>+ \> = \verb+\@endparpenalty+      \> \% Ditto.
2951% \end{tabbing}
2952%
2953% \noindent Vmode after \verb+@nobreak+:
2954% \begin{tabbing}
2955%   \verb+<toppenalty>+ \= = \kill
2956%   \verb+<topskip>+    \> = \verb+\parskip+ \\
2957%   \verb+<botskip>+    \> = \verb!\topsep + \partopsep! \\
2958%   \verb+<toppenalty>+ \> = \verb+None+ \\
2959%   \verb+<botpenatly>+ \> = \verb+\@endparpenalty+
2960% \end{tabbing}
2961%
2962% \noindent Hmode:
2963% \begin{tabbing}
2964%   \verb+<toppenalty>+ \= = \kill
2965%   \verb+<topskip>+    \> = \verb!\topsep + \parskip! \\
2966%   \verb+<botskip>+    \> = \verb+\topsep+ \\
2967%   \verb+<toppenalty>+ \> = \verb+\@beginparpenalty+ \\
2968%   \verb+<botpenatly>+ \> = \verb+\@endparpenalty+
2969% \end{tabbing}
2970%
2971% \noindent Notes:
2972% \begin{itemize}
2973%   \item Except when in label or after nobreak, \verb+\parskip+ is added with
2974%         \verb+\addvspace+, so that net space is:
2975%
2976%         \verb!MAX{\topsep (+\partopsep) + \parskip , \lastskip }!
2977%
2978%         (The usual \verb+\@item+ works the same way.)
2979%   \item \verb+\parskip+ is added afterwards by a new paragraph, if any.
2980%   \item \verb+<botskip> == \@topsepadd+
2981% \end{itemize}
2982%
2983% \begin{macro}{\FV@ListVSpace}
2984%    \begin{macrocode}
2985\def\FV@ListVSpace{%
2986  \@topsepadd\topsep
2987  \if@noparlist\advance\@topsepadd\partopsep\fi
2988  \if@inlabel
2989    \vskip\parskip
2990  \else
2991    \if@nobreak
2992      \vskip\parskip
2993      \clubpenalty\@M
2994    \else
2995      \addpenalty\@beginparpenalty
2996      \@topsep\@topsepadd
2997      \advance\@topsep\parskip
2998      \addvspace\@topsep
2999    \fi
3000  \fi
3001  \global\@nobreakfalse
3002  \global\@inlabelfalse
3003  \global\@minipagefalse
3004  \global\@newlistfalse}
3005%    \end{macrocode}
3006% \end{macro}
3007%
3008% \begin{tabbing}
3009%   \verb+\@totalleftmargin+ \= := \kill
3010%   \verb+\leftmargin+       \> := totalleftmargin \\
3011%   \verb+\rightmargin+      \> := totalrightmargin \\
3012%   \verb+\@totalleftmargin+ \> := totalleftmargin of enclosing environment.
3013% \end{tabbing}
3014%
3015% \begin{macro}{\FV@SetLineWidth}
3016%    \begin{macrocode}
3017\def\FV@SetLineWidth{%
3018  \if@FV@ResetMargins\else
3019    \advance\leftmargin\@totalleftmargin
3020  \fi
3021  \advance\leftmargin\FV@XLeftMargin\relax
3022  \advance\rightmargin\FV@XRightMargin\relax
3023  \linewidth\hsize
3024  \advance\linewidth-\leftmargin
3025  \advance\linewidth-\rightmargin
3026  \hfuzz\FancyVerbHFuzz\relax}
3027%    \end{macrocode}
3028% \end{macro}
3029%
3030% We have to insert the right interline penalties (\verb+\interlinepenalty+,
3031% \verb+\clubpenalty+, \verb+\widowpenalty+). We could process the environment
3032% as one long paragraph and let \TeX{} insert the penalties, but this
3033% might cause problems for a very long environment.
3034%
3035% \begin{description}
3036%   \item[Line 1] : Insert \verb+\@labels+ (maybe) plus current\_line
3037%   \item[Line 2] : Save current line
3038%   \item[Line 3] : penalty = interline + club ; Insert last line ;
3039%                   Save current line.
3040%   \item[Line 4] : penalty = interline ; Insert last line ; Save current line.
3041% \end{description}
3042%
3043% \noindent Then at the end:
3044% \begin{description}
3045%   \item[Next line = 1] :  Add null line.
3046%   \item[Next line = 2] :  Nothing.
3047%   \item[Next line = 3] :  penalty = interline + club + widow ;
3048%                           Insert last line.
3049%   \item[Next line = 4] :  penalty = interline + widow ; Insert last line.
3050% \end{description}
3051%
3052% \begin{macro}{\FV@ListProcessLine}
3053%    \begin{macrocode}
3054\def\FV@ListProcessLine#1{%
3055  \hbox to \hsize{%
3056    \kern\leftmargin
3057    \hbox to \linewidth{%
3058      \FV@LeftListNumber
3059      \FV@LeftListFrame
3060      \FancyVerbFormatLine{#1}\hss
3061%% DG/SR modification begin - Jan. 28, 1998 (for numbers=right add-on)
3062%%      \FV@RightListFrame}%
3063      \FV@RightListFrame
3064      \FV@RightListNumber}%
3065%% DG/SR modification end
3066    \hss}}
3067%    \end{macrocode}
3068% \end{macro}
3069%
3070% \begin{macro}{\FV@ListProcessLine@i}
3071%    \begin{macrocode}
3072\def\FV@ListProcessLine@i#1{%
3073  \hbox{%
3074    \ifvoid\@labels\else
3075      \hbox to \z@{\kern\@totalleftmargin\box\@labels\hss}%
3076    \fi
3077    \FV@ListProcessLine{#1}}%
3078  \let\FV@ProcessLine\FV@ListProcessLine@ii}
3079%    \end{macrocode}
3080% \end{macro}
3081%
3082% \begin{macro}{\FV@ListProcessLine@ii}
3083%    \begin{macrocode}
3084\def\FV@ListProcessLine@ii#1{%
3085  \setbox\@tempboxa=\FV@ListProcessLine{#1}%
3086  \let\FV@ProcessLine\FV@ListProcessLine@iii}
3087%    \end{macrocode}
3088% \end{macro}
3089%
3090% \begin{macro}{\FV@ListProcessLine@iii}
3091%    \begin{macrocode}
3092\def\FV@ListProcessLine@iii#1{%
3093  {\advance\interlinepenalty\clubpenalty\penalty\interlinepenalty}%
3094  \box\@tempboxa
3095  \setbox\@tempboxa=\FV@ListProcessLine{#1}%
3096  \let\FV@ProcessLine\FV@ListProcessLine@iv}
3097%    \end{macrocode}
3098% \end{macro}
3099%
3100% \begin{macro}{\FV@ListProcessLine@iv}
3101%    \begin{macrocode}
3102\def\FV@ListProcessLine@iv#1{%
3103  \penalty\interlinepenalty
3104  \box\@tempboxa
3105  \setbox\@tempboxa=\FV@ListProcessLine{#1}}%
3106%    \end{macrocode}
3107% \end{macro}
3108%
3109% \begin{macro}{\FV@EndList}
3110%    \begin{macrocode}
3111\def\FV@EndList{%
3112  \FV@ListProcessLastLine
3113  \FV@EndListFrame
3114  \@endparenv
3115  \endgroup
3116  \@endpetrue}
3117%    \end{macrocode}
3118% \end{macro}
3119%
3120% \begin{macro}{\FV@ListProcessLastLine}
3121%    \begin{macrocode}
3122\def\FV@ListProcessLastLine{%
3123  \ifx\FV@ProcessLine\FV@ListProcessLine@iv
3124    {\advance\interlinepenalty\widowpenalty\penalty\interlinepenalty}%
3125    \box\@tempboxa
3126  \else
3127    \ifx\FV@ProcessLine\FV@ListProcessLine@iii
3128      {\advance\interlinepenalty\widowpenalty
3129        \advance\interlinepenalty\clubpenalty
3130        \penalty\interlinepenalty}%
3131      \box\@tempboxa
3132    \else
3133      \ifx\FV@ProcessLine\FV@ListProcessLine@i
3134        \FV@Error{Empty verbatim environment}{}%
3135        \FV@ProcessLine{}%
3136      \fi
3137    \fi
3138  \fi}
3139%    \end{macrocode}
3140% \end{macro}
3141%
3142% Verbatim environment:
3143%
3144% \DescribeEnv{Verbatim}
3145%    \begin{macrocode}
3146\def\FV@VerbatimBegin{\FV@List\z@}
3147\def\FV@VerbatimEnd{\FV@EndList}
3148%    \end{macrocode}
3149%
3150% \begin{macro}{\FVB@Verbatim}
3151%    \begin{macrocode}
3152\def\FVB@Verbatim{\FV@VerbatimBegin\FV@Scan}
3153%    \end{macrocode}
3154% \end{macro}
3155%
3156% \begin{macro}{\FVE@Verbatim}
3157%    \begin{macrocode}
3158\def\FVE@Verbatim{\FV@VerbatimEnd}
3159%    \end{macrocode}
3160% \end{macro}
3161%
3162%    \begin{macrocode}
3163\DefineVerbatimEnvironment{Verbatim}{Verbatim}{}
3164%    \end{macrocode}
3165%
3166% With \cs{UseVerbatim}, we have to take care of some of the things
3167% \verb+\end{}+ would do.
3168%
3169% \begin{macro}{\FV@UseVerbatim}
3170%    \begin{macrocode}
3171\def\FV@UseVerbatim#1{%
3172  \FV@VerbatimBegin#1\FV@VerbatimEnd
3173  \@doendpe\global\@ignorefalse\ignorespaces}
3174%    \end{macrocode}
3175% \end{macro}
3176%
3177% \begin{macro}{\VerbatimInput}
3178%    \begin{macrocode}
3179\def\VerbatimInput{\FV@Command{}{VerbatimInput}}
3180%    \end{macrocode}
3181% \end{macro}
3182%
3183% \begin{macro}{\FVC@VerbatimInput}
3184%    \begin{macrocode}
3185\def\FVC@VerbatimInput#1{\FV@UseVerbatim{\FV@Input{#1}}}
3186%    \end{macrocode}
3187% \end{macro}
3188%
3189% LVerbatim environment:
3190%
3191% \DescribeEnv{LVerbatim}
3192%    \begin{macrocode}
3193\def\FV@LVerbatimBegin{\FV@List\@ne}
3194\def\FV@LVerbatimEnd{\FV@EndList}
3195%    \end{macrocode}
3196%
3197% \begin{macro}{\FVB@LVerbatim}
3198%    \begin{macrocode}
3199\def\FVB@LVerbatim{\FV@LVerbatimBegin\FV@Scan}
3200%    \end{macrocode}
3201% \end{macro}
3202%
3203% \begin{macro}{\FVE@LVerbatim}
3204%    \begin{macrocode}
3205\def\FVE@LVerbatim{\FV@LVerbatimEnd}
3206%    \end{macrocode}
3207% \end{macro}
3208%
3209%    \begin{macrocode}
3210\DefineVerbatimEnvironment{LVerbatim}{LVerbatim}{}
3211%    \end{macrocode}
3212%
3213% \begin{macro}{\FV@LUseVerbatim}
3214%    \begin{macrocode}
3215\def\FV@LUseVerbatim#1{%
3216  \FV@LVerbatimBegin#1\FV@LVerbatimEnd
3217  \@doendpe\global\@ignorefalse\ignorespaces}
3218%    \end{macrocode}
3219% \end{macro}
3220%
3221% \begin{macro}{\LVerbatimInput}
3222%    \begin{macrocode}
3223\def\LVerbatimInput{\FV@Command{}{LVerbatimInput}}
3224%    \end{macrocode}
3225% \end{macro}
3226%
3227% \begin{macro}{\FVC@LVerbatimInput}
3228%    \begin{macrocode}
3229\def\FVC@LVerbatimInput#1{\FV@LUseVerbatim{\FV@Input{#1}}}
3230%    \end{macrocode}
3231% \end{macro}
3232%
3233% Frames:
3234%
3235% \begin{macro}{\FV@Frame@none}
3236%    \begin{macrocode}
3237\def\FV@Frame@none{%
3238  \let\FV@BeginListFrame\relax
3239  \let\FV@LeftListFrame\relax
3240  \let\FV@RightListFrame\relax
3241  \let\FV@EndListFrame\relax}
3242%    \end{macrocode}
3243% \end{macro}
3244%
3245% \begin{macro}{\FV@Frame@single}
3246%    \begin{macrocode}
3247\def\FV@Frame@single{%
3248  \let\FV@BeginListFrame\FV@BeginListFrame@Single
3249  \let\FV@LeftListFrame\FV@LeftListFrame@Single
3250  \let\FV@RightListFrame\FV@RightListFrame@Single
3251  \let\FV@EndListFrame\FV@EndListFrame@Single}
3252%    \end{macrocode}
3253% \end{macro}
3254%
3255% \begin{macro}{\FV@Frame@lines}
3256%    \begin{macrocode}
3257\def\FV@Frame@lines{%
3258  \let\FV@BeginListFrame\FV@BeginListFrame@Lines
3259  \let\FV@LeftListFrame\relax
3260  \let\FV@RightListFrame\relax
3261  \let\FV@EndListFrame\FV@EndListFrame@Lines}
3262%    \end{macrocode}
3263% \end{macro}
3264%
3265% \begin{macro}{\FV@Frame@topline}
3266%    \begin{macrocode}
3267\def\FV@Frame@topline{%
3268  \let\FV@BeginListFrame\FV@BeginListFrame@Lines
3269  \let\FV@LeftListFrame\relax
3270  \let\FV@RightListFrame\relax
3271  \let\FV@EndListFrame\relax}
3272%    \end{macrocode}
3273% \end{macro}
3274%
3275% \begin{macro}{\FV@Frame@bottomline}
3276%    \begin{macrocode}
3277\def\FV@Frame@bottomline{%
3278  \let\FV@BeginListFrame\relax
3279  \let\FV@LeftListFrame\relax
3280  \let\FV@RightListFrame\relax
3281  \let\FV@EndListFrame\FV@EndListFrame@Lines}
3282%    \end{macrocode}
3283% \end{macro}
3284%
3285% \changes{v2.6}{1998/07/17}{Add ``leftline'' value for the ``frame'' parameter
3286%                            (idea taken from a requirement of
3287%                            Christophe Roudet on June 9, 1998).}
3288%
3289% \ifChangeBar\begin{changebar}\fi
3290% \begin{macro}{\FV@Frame@leftline}
3291%    \begin{macrocode}
3292%% To define a frame with only a left line
3293\def\FV@Frame@leftline{%
3294  % To define the \FV@FrameFillLine macro (from \FV@BeginListFrame)
3295  \ifx\FancyVerbFillColor\relax
3296    \let\FV@FrameFillLine\relax
3297  \else
3298    \@tempdima\FV@FrameRule\relax
3299    \multiply\@tempdima-\tw@
3300    \edef\FV@FrameFillLine{%
3301      {\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}%
3302      \kern-\number\@tempdima sp}}%
3303  \fi
3304  \let\FV@BeginListFrame\relax
3305  \let\FV@LeftListFrame\FV@LeftListFrame@Single
3306  \let\FV@RightListFrame\relax
3307  \let\FV@EndListFrame\relax}
3308%    \end{macrocode}
3309% \end{macro}
3310% \ifChangeBar\end{changebar}\fi
3311%
3312% \changes{v2.6}{1998/07/17}{Add the ``label'' and ``labelposition'' parameters
3313%                            (suggested by Michael Friendly on May 15, 1998).}
3314%
3315% \ifChangeBar\begin{changebar}\fi
3316% \begin{macro}{\FV@BeginListFrame@Single}
3317%    \begin{macrocode}
3318\def\FV@BeginListFrame@Single{%
3319  \lineskip\z@
3320  \baselineskip\z@
3321  \ifx\FancyVerbFillColor\relax
3322    \let\FV@FrameFillLine\relax
3323  \else
3324    \@tempdima\FV@FrameRule\relax
3325    \multiply\@tempdima-\tw@
3326    \edef\FV@FrameFillLine{%
3327      {\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}%
3328      \kern-\number\@tempdima sp}}%
3329  \fi
3330%% DG/SR modification begin - May. 19, 1998
3331%%  \FV@SingleFrameLine
3332  \FV@SingleFrameLine{\z@}%
3333%% DG/SR modification end
3334  \penalty\@M
3335  \FV@SingleFrameSep
3336  \penalty\@M}
3337%    \end{macrocode}
3338% \end{macro}
3339%
3340% \begin{macro}{\FV@Label}
3341%    \begin{macrocode}
3342%% DG/SR modification begin - May. 19, 1998
3343\define@key{FV}{label}{%
3344  \def\@tempa{#1}%
3345  \ifx\@tempa\FV@None
3346    \let\FV@LabelBegin\relax
3347    \let\FV@LabelEnd\relax
3348  \else
3349    \FV@Label@i#1\@nil%
3350  \fi}
3351%    \end{macrocode}
3352% \end{macro}
3353%
3354% \begin{macro}{\FV@Label@i}
3355%    \begin{macrocode}
3356\def\FV@Label@i{\@ifnextchar[{\FV@Label@ii}{\FV@Label@ii[]}}
3357%    \end{macrocode}
3358% \end{macro}
3359%
3360% \begin{macro}{\FV@Label@ii}
3361%    \begin{macrocode}
3362\def\FV@Label@ii[#1]#2\@nil{%
3363  \def\@tempa{#1}%
3364  \ifx\@tempa\empty
3365    \def\FV@LabelBegin{#2}%
3366  \else
3367    \def\FV@LabelBegin{#1}%
3368    \def\FV@LabelPositionBottomLine{\@ne}%
3369  \fi
3370  \def\FV@LabelEnd{#2}}
3371%    \end{macrocode}
3372% \end{macro}
3373%
3374%    \begin{macrocode}
3375\fvset{label=none}
3376%    \end{macrocode}
3377%
3378% \begin{macro}{\FV@LabelPosition}
3379%    \begin{macrocode}
3380\define@key{FV}{labelposition}[none]{%
3381  \@ifundefined{FV@LabelPosition@#1}%
3382    {\FV@Error{Label position `#1' not defined.}\FV@eha}%
3383    {\@nameuse{FV@LabelPosition@#1}}}
3384%    \end{macrocode}
3385% \end{macro}
3386%
3387% \begin{macro}{\FV@LabelPosition@none}
3388%    \begin{macrocode}
3389\def\FV@LabelPosition@none{%
3390  \let\FV@LabelPositionTopLine\relax%
3391  \let\FV@LabelPositionBottomLine\relax}
3392%    \end{macrocode}
3393% \end{macro}
3394%
3395% \begin{macro}{\FV@LabelPosition@topline}
3396%    \begin{macrocode}
3397\def\FV@LabelPosition@topline{%
3398  \def\FV@LabelPositionTopLine{\@ne}%
3399  \let\FV@LabelPositionBottomLine\relax}
3400%    \end{macrocode}
3401% \end{macro}
3402%
3403% \begin{macro}{\FV@LabelPosition@bottomline}
3404%    \begin{macrocode}
3405\def\FV@LabelPosition@bottomline{%
3406  \let\FV@LabelPositionTopLine\relax%
3407  \def\FV@LabelPositionBottomLine{\@ne}}
3408%    \end{macrocode}
3409% \end{macro}
3410%
3411% \begin{macro}{\FV@LabelPosition@all}
3412%    \begin{macrocode}
3413\def\FV@LabelPosition@all{%
3414  \def\FV@LabelPositionTopLine{\@ne}%
3415  \def\FV@LabelPositionBottomLine{\@ne}}
3416%    \end{macrocode}
3417% \end{macro}
3418%
3419%    \begin{macrocode}
3420\fvset{labelposition=topline}
3421%% DG/SR modification end
3422%    \end{macrocode}
3423%
3424% \begin{macro}{\FV@SingleFrameLine}
3425%    \begin{macrocode}
3426%% DG/SR modification begin - May. 19, 1998
3427%% \def\FV@SingleFrameLine{%
3428\def\FV@SingleFrameLine#1{%
3429%% DG/SR modification end
3430  \hbox to\z@{%
3431    \kern\leftmargin
3432%% DG/SR modification begin - Jun. 22, 1998
3433    \ifnum#1=\z@
3434      \let\FV@Label\FV@LabelBegin
3435    \else
3436      \let\FV@Label\FV@LabelEnd
3437    \fi
3438    \ifx\FV@Label\relax
3439%% DG/SR modification end
3440      \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
3441%% DG/SR modification begin - Jun. 22, 1998
3442    \else
3443      \ifnum#1=\z@
3444        \setbox\z@\hbox{\strut\enspace\FV@LabelBegin\enspace\strut}%
3445      \else
3446        \setbox\z@\hbox{\strut\enspace\FV@LabelEnd\enspace\strut}%
3447      \fi
3448      \@tempdimb=\dp\z@
3449      \advance\@tempdimb -.5\ht\z@
3450      \@tempdimc=\linewidth
3451      \advance\@tempdimc -\wd\z@
3452      \divide\@tempdimc\tw@
3453      \ifnum#1=\z@              % Top line
3454        \ifx\FV@LabelPositionTopLine\relax
3455          \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
3456        \else
3457          \FV@FrameLineWithLabel
3458        \fi
3459      \else                     % Bottom line
3460        \ifx\FV@LabelPositionBottomLine\relax
3461          \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
3462        \else
3463          \FV@FrameLineWithLabel
3464        \fi
3465      \fi
3466    \fi
3467%% DG/SR modification end
3468    \hss}}
3469%    \end{macrocode}
3470% \end{macro}
3471%
3472% \begin{macro}{\FV@FrameLineWithLabel}
3473%    \begin{macrocode}
3474%% DG/SR modification begin - May. 19, 1998
3475\def\FV@FrameLineWithLabel{%
3476  \ht\z@\@tempdimb\dp\z@\@tempdimb%
3477  \FancyVerbRuleColor{%
3478    \vrule \@width\@tempdimc \@height\FV@FrameRule
3479    \raise\@tempdimb\box\z@
3480    \vrule \@width\@tempdimc \@height\FV@FrameRule}}
3481%% DG/SR modification end
3482%    \end{macrocode}
3483% \end{macro}
3484%
3485% \begin{macro}{\FV@BeginListFrame@Lines}
3486%    \begin{macrocode}
3487\def\FV@BeginListFrame@Lines{%
3488  \begingroup
3489    \lineskip\z@skip
3490%% DG modification begin - June 18, 1997 (effect of \baselineskip too earlier)
3491%%    \baselineskip\z@skip
3492%%    \FV@SingleFrameLine
3493%% DG/SR modification begin - May. 19, 1998
3494%%    \FV@SingleFrameLine
3495    \FV@SingleFrameLine{\z@}%
3496%% DG/SR modification end
3497    \kern-0.5\baselineskip\relax
3498    \baselineskip\z@skip
3499%% DG modification end
3500    \kern\FV@FrameSep\relax
3501  \endgroup}%
3502%    \end{macrocode}
3503% \end{macro}
3504%
3505% \begin{macro}{\FV@EndListFrame@Lines}
3506%    \begin{macrocode}
3507\def\FV@EndListFrame@Lines{%
3508  \begingroup
3509    \baselineskip\z@skip
3510    \kern\FV@FrameSep\relax
3511%% DG/SR modification begin - May. 19, 1998
3512%%    \FV@SingleFrameLine
3513    \FV@SingleFrameLine{\@ne}%
3514%% DG/SR modification end
3515  \endgroup}
3516%    \end{macrocode}
3517% \end{macro}
3518% \ifChangeBar\end{changebar}\fi
3519%
3520% \begin{macro}{\FV@SingleFrameSep}
3521%    \begin{macrocode}
3522\def\FV@SingleFrameSep{%
3523  \hbox to \z@{%
3524    \kern\leftmargin
3525    \hbox to\linewidth{%
3526      \FancyVerbRuleColor{%
3527%% DG modification begin - June 18, 1997 (\FV@FrameSep missing)
3528        \ifx\FancyVerbFillColor\relax
3529          \vrule\@width 0pt\@height\FV@FrameSep\relax
3530        \fi
3531%% DG modification end
3532        \vrule\@width\FV@FrameRule\relax
3533        \ifx\FancyVerbFillColor\relax
3534          \hfil
3535        \else
3536          {\FancyVerbFillColor\leaders\hrule\@height\FV@FrameSep\hfil}%
3537        \fi
3538%% DG modification begin - June 18, 1997 (\FV@FrameSep missing)
3539        \ifx\FancyVerbFillColor\relax
3540          \vrule\@width 0pt\@height\FV@FrameSep\relax
3541        \fi
3542%% DG modification end
3543        \vrule\@width\FV@FrameRule\relax}}%
3544    \hss}}
3545%    \end{macrocode}
3546% \end{macro}
3547%
3548% \begin{macro}{\FV@LeftListFrame@Single}
3549%    \begin{macrocode}
3550\def\FV@LeftListFrame@Single{%
3551  \strut
3552  {\FancyVerbRuleColor{\vrule \@width\FV@FrameRule}}%
3553  \FV@FrameFillLine
3554%% DG modification begin - June 18, 1997 (to fill color on left side)
3555%%  \kern\FV@FrameSep}
3556  \ifx\FancyVerbFillColor\relax
3557    \kern\FV@FrameSep
3558  \else
3559    {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}%
3560  \fi}
3561%% DG modification end
3562%    \end{macrocode}
3563% \end{macro}
3564%
3565% \begin{macro}{\FV@RightListFrame@Single}
3566%    \begin{macrocode}
3567\def\FV@RightListFrame@Single{%
3568%% DG modification begin - June 18, 1997 (to fill color on right side)
3569%%  \kern\FV@FrameSep
3570  \ifx\FancyVerbFillColor\relax
3571    \kern\FV@FrameSep
3572  \else
3573    {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}%
3574  \fi
3575  {\noexpand\leavevmode\FancyVerbRuleColor{\vrule\@width\FV@FrameRule}}}
3576%% DG modification end
3577%    \end{macrocode}
3578% \end{macro}
3579%
3580% \ifChangeBar\begin{changebar}\fi
3581% \begin{macro}{\FV@EndListFrame@Single}
3582%    \begin{macrocode}
3583\def\FV@EndListFrame@Single{%
3584  \penalty\@M
3585  \FV@SingleFrameSep
3586  \penalty\@M
3587%% DG/SR modification begin - May. 19, 1998
3588%%  \FV@SingleFrameLine}
3589  \FV@SingleFrameLine{\@ne}}
3590%% DG/SR modification end
3591%    \end{macrocode}
3592% \end{macro}
3593% \ifChangeBar\end{changebar}\fi
3594%
3595% \begin{macro}{\FV@FrameRule}
3596%    \begin{macrocode}
3597\define@key{FV}{framerule}{%
3598  \@tempdima=#1\relax
3599  \edef\FV@FrameRule{\number\@tempdima sp\relax}}
3600%    \end{macrocode}
3601% \end{macro}
3602%
3603% \begin{macro}{\KV@FV@framerule@default}
3604%    \begin{macrocode}
3605\def\KV@FV@framerule@default{\let\FV@FrameRule\fboxrule}
3606%    \end{macrocode}
3607% \end{macro}
3608%
3609% \begin{macro}{\FV@FrameSep}
3610%    \begin{macrocode}
3611\define@key{FV}{framesep}{%
3612  \@tempdima=#1\relax
3613  \edef\FV@FrameSep{\number\@tempdima sp\relax}}
3614%    \end{macrocode}
3615% \end{macro}
3616%
3617% \begin{macro}{\KV@FV@framesep@default}
3618%    \begin{macrocode}
3619\def\KV@FV@framesep@default{\let\FV@FrameSep\fboxsep}
3620%    \end{macrocode}
3621% \end{macro}
3622%
3623%    \begin{macrocode}
3624\fvset{framerule,framesep}
3625%    \end{macrocode}
3626%
3627% \begin{macro}{\FancyVerbRuleColor}
3628%    \begin{macrocode}
3629\define@key{FV}{rulecolor}{%
3630  \def\@tempa{#1}%
3631  \ifx\@tempa\FV@None
3632    \let\FancyVerbRuleColor\relax
3633  \else
3634    \let\FancyVerbRuleColor\@tempa
3635  \fi}
3636%    \end{macrocode}
3637% \end{macro}
3638%
3639% \begin{macro}{\FancyVerbFillColor}
3640%    \begin{macrocode}
3641\define@key{FV}{fillcolor}{%
3642  \def\@tempa{#1}%
3643  \ifx\@tempa\FV@None
3644    \let\FancyVerbFillColor\relax
3645  \else
3646    \let\FancyVerbFillColor\@tempa
3647  \fi}
3648%    \end{macrocode}
3649% \end{macro}
3650%
3651%    \begin{macrocode}
3652\fvset{rulecolor=none,fillcolor=none}
3653%    \end{macrocode}
3654%
3655% \begin{macro}{\FV@Frame@double}
3656%    \begin{macrocode}
3657\def\FV@Frame@double{%
3658  \let\FV@FrameBegin\FV@FrameBegin@double
3659  \let\FV@FrameLine\FV@FrameLine@double
3660  \let\FV@FrameEnd\FV@FrameEnd@double}
3661%    \end{macrocode}
3662% \end{macro}
3663%
3664%    \begin{macrocode}
3665\define@key{FV}{frame}[none]{%
3666  \@ifundefined{FV@Frame@#1}%
3667    {\FV@Error{Frame style `#1' not defined.}\FV@eha}%
3668    {\@nameuse{FV@Frame@#1}}}
3669%    \end{macrocode}
3670%
3671%    \begin{macrocode}
3672\fvset{frame=none}
3673%    \end{macrocode}
3674%
3675%
3676% Code line numbers:
3677%
3678%    \begin{macrocode}
3679\newcounter{FancyVerbLine}
3680%    \end{macrocode}
3681%
3682% \begin{macro}{\FV@SetLineNo}
3683%    \begin{macrocode}
3684\define@key{FV}{firstnumber}[auto]{%
3685  \def\@tempa{#1}\def\@tempb{auto}%
3686  \ifx\@tempa\@tempb
3687    \def\FV@SetLineNo{%
3688      \c@FancyVerbLine\FV@CodeLineNo
3689      \advance\c@FancyVerbLine\m@ne}%
3690  \else
3691    \def\@tempb{last}%
3692    \ifx\@tempa\@tempb
3693      \let\FV@SetLineNo\relax
3694    \else
3695%% DG/SR modification begin - Jan. 19, 1998
3696%%      \def\FV@SetLineNo{\c@FancyVerbLine#1}%
3697      \def\FV@SetLineNo{%
3698        \c@FancyVerbLine#1
3699        \advance\c@FancyVerbLine\m@ne}%
3700%% DG/SR modification end
3701    \fi
3702  \fi}
3703%    \end{macrocode}
3704% \end{macro}
3705%
3706% \changes{v2.6}{1998/07/17}{Add the ``numberblanklines'' parameter to allow
3707%                            to don't number empty lines (suggested by
3708%                            Philippe Esperet on April 25, 1998).}
3709%
3710% \ifChangeBar\begin{changebar}\fi
3711% \begin{macro}{\if@FV@NumberBlankLines}
3712%    \begin{macrocode}
3713\define@booleankey{FV}{numberblanklines}%
3714  {\let\if@FV@NumberBlankLines\iftrue}
3715  {\let\if@FV@NumberBlankLines\iffalse}
3716\fvset{numberblanklines=true}
3717%    \end{macrocode}
3718% \end{macro}
3719% \ifChangeBar\end{changebar}\fi
3720%
3721% \changes{v2.6}{1998/07/17}{Correct a bug which didn't allow to use the label
3722%                            macro in verbatim env.
3723%                            (reported by Philippe Esperet on May 20, 1998).}
3724%
3725% \ifChangeBar\mbox{}\begin{changebar}\fi
3726% \begin{macro}{\FV@refstepcounter}
3727%    \begin{macrocode}
3728%% DG/SR modification begin - May. 20, 1998
3729%%\def\refstepcounter#1{% Adapted from latex.ltx
3730\def\FV@refstepcounter#1{%
3731%% DG/SR modification end
3732  \stepcounter{#1}%
3733  \protected@edef\@currentlabel
3734    {\csname p@#1\endcsname\arabic{FancyVerbLine}}}
3735%    \end{macrocode}
3736% \end{macro}
3737%
3738% \begin{macro}{\FV@StepLineNo}
3739%    \begin{macrocode}
3740\def\FV@StepLineNo{%
3741  \FV@SetLineNo
3742%% DG/SR modification begin - Apr. 28, 1998 and May 20, 1998
3743%%  \def\FV@StepLineNo{\refstepcounter{FancyVerbLine}}%
3744  \def\FV@StepLineNo{%
3745    \if@FV@NumberBlankLines
3746      \FV@refstepcounter{FancyVerbLine}
3747    \else
3748      \ifx\FV@Line\empty
3749      \else
3750        \FV@refstepcounter{FancyVerbLine}
3751      \fi
3752    \fi}%
3753%% DG/SR modification end
3754  \FV@StepLineNo}
3755%    \end{macrocode}
3756% \end{macro}
3757% \ifChangeBar\end{changebar}\mbox{}\fi
3758%
3759% \begin{macro}{\theFancyVerbLine}
3760%    \begin{macrocode}
3761%% DG/SR modification begin - 1995
3762%%\def\theFancyVerbLine{\rm\tiny\arabic{FancyVerbLine}}
3763\def\theFancyVerbLine{\rmfamily\tiny\arabic{FancyVerbLine}}
3764%% DG/SR modification end
3765%    \end{macrocode}
3766% \end{macro}
3767%
3768%    \begin{macrocode}
3769\define@key{FV}{numbers}[none]{%
3770  \@ifundefined{FV@Numbers@#1}%
3771    {\FV@Error{Numbers style `#1' not defined.}\FV@eha}%
3772    {\@nameuse{FV@Numbers@#1}}}
3773%    \end{macrocode}
3774%
3775% (D.G. -- Dec. 20, 1995 and Jan. 28, 1998):
3776%
3777% Add-on to allow a step when printing the lines counter
3778% (``\texttt{stepnumber''} keyword)
3779%
3780% Add-on to allow the counter to be printed on right side
3781% (\texttt{numbers=right})
3782%
3783% \begin{macro}{\FV@Numbers@none}
3784%    \begin{macrocode}
3785%% DG modification begin - Dec. 20, 1995 and Jan. 28, 1998
3786%%\def\FV@Numbers@none{\let\FV@LeftListNumber\relax}
3787\def\FV@Numbers@none{%
3788\let\FV@LeftListNumber\relax
3789\let\FV@RightListNumber\relax}
3790%    \end{macrocode}
3791% \end{macro}
3792%
3793%    \begin{macrocode}
3794\newcount\FV@StepNumber
3795\define@key{FV}{stepnumber}{\FV@StepNumber#1}
3796%    \end{macrocode}
3797%
3798% \begin{macro}{\KV@FV@stepnumber@default}
3799%    \begin{macrocode}
3800\def\KV@FV@stepnumber@default{\FV@StepNumber\@ne}
3801%    \end{macrocode}
3802% \end{macro}
3803%
3804%    \begin{macrocode}
3805\fvset{stepnumber}
3806%    \end{macrocode}
3807%
3808% ^^A `changebar' bug... \ifChangeBar\mbox{}\begin{changebar}\fi
3809% \begin{macro}{\FV@Numbers@left}
3810%    \begin{macrocode}
3811%% DG modification begin - Dec. 20, 1995
3812%%\def\FV@Numbers@left{%
3813%%  \def\FV@LeftListNumber{\hbox to\z@{%
3814%%    \hss\theFancyVerbLine\kern\FV@NumberSep}}}
3815\def\FV@Numbers@left{%
3816%% DG/SR modification begin - Apr. 28, 1998
3817  \let\FV@RightListNumber\relax
3818%% DG/SR modification end
3819  \def\FV@LeftListNumber{%
3820  \@tempcnta=\FV@CodeLineNo
3821  \@tempcntb=\FV@CodeLineNo
3822  \divide\@tempcntb\FV@StepNumber
3823  \multiply\@tempcntb\FV@StepNumber
3824  \ifnum\@tempcnta=\@tempcntb
3825%% DG/SR modification begin - Apr. 28, 1998
3826%%    \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
3827      \if@FV@NumberBlankLines
3828        \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
3829      \else
3830        \ifx\FV@Line\empty
3831        \else
3832          \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
3833        \fi
3834      \fi
3835%% DG/SR modification end
3836  \fi}}
3837%    \end{macrocode}
3838% \end{macro}
3839% ^^A `changebar' bug... \ifChangeBar\end{changebar}\fi
3840%
3841% \ifChangeBar\begin{changebar}\fi
3842% \begin{macro}{\FV@Numbers@right}
3843%    \begin{macrocode}
3844\def\FV@Numbers@right{%
3845%% DG/SR modification begin - Apr. 28, 1998
3846  \let\FV@LeftListNumber\relax
3847%% DG/SR modification end
3848  \def\FV@RightListNumber{%
3849  \@tempcnta=\FV@CodeLineNo
3850  \@tempcntb=\FV@CodeLineNo
3851  \divide\@tempcntb\FV@StepNumber
3852  \multiply\@tempcntb\FV@StepNumber
3853  \ifnum\@tempcnta=\@tempcntb
3854%% DG/SR modification begin - Apr. 28, 1998
3855%%    \hbox to \z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
3856      \if@FV@NumberBlankLines
3857        \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
3858      \else
3859        \ifx\FV@Line\empty
3860        \else
3861          \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
3862        \fi
3863      \fi
3864%% DG/SR modification end
3865  \fi}}
3866%% DG modification end
3867%    \end{macrocode}
3868% \end{macro}
3869% \ifChangeBar\end{changebar}\fi
3870%
3871% \begin{macro}{\FV@NumberSep}
3872%    \begin{macrocode}
3873\define@key{FV}{numbersep}{%
3874  \@tempdima=#1\relax
3875  \edef\FV@NumberSep{\number\@tempdima sp\relax}}
3876%    \end{macrocode}
3877% \end{macro}
3878%
3879%    \begin{macrocode}
3880\fvset{numbers=none,numbersep=12pt,firstnumber=auto}
3881%    \end{macrocode}
3882%
3883% \subsection{BVerbatim}
3884%
3885% \DescribeEnv{BVerbatim}
3886%    \begin{macrocode}
3887\def\FV@BVerbatimBegin{%
3888  \begingroup
3889    \FV@UseKeyValues
3890    \FV@BeginVBox
3891    \let\FV@ProcessLine\FV@BProcessLine
3892    \FV@FormattingPrep
3893    \FV@ObeyTabsInit}%
3894\def\FV@BVerbatimEnd{\FV@EndVBox\endgroup}
3895%    \end{macrocode}
3896%
3897% \begin{macro}{\FV@BeginVBox}
3898%    \begin{macrocode}
3899\def\FV@BeginVBox{%
3900  \leavevmode
3901  \hbox\ifx\FV@boxwidth\relax\else to\FV@boxwidth\fi\bgroup
3902  \ifcase\FV@baseline\vbox\or\vtop\or$\vcenter\fi\bgroup}
3903%    \end{macrocode}
3904% \end{macro}
3905%
3906% \begin{macro}{\FV@EndVBox}
3907%    \begin{macrocode}
3908\def\FV@EndVBox{\egroup\ifmmode$\fi\hfil\egroup}
3909%    \end{macrocode}
3910% \end{macro}
3911%
3912% \begin{macro}{\FV@boxwidth}
3913%    \begin{macrocode}
3914\define@key{FV}{boxwidth}{%
3915  \def\@tempa{#1}\def\@tempb{auto}%
3916  \ifx\@tempa\@tempb
3917    \let\FV@boxwidth\relax
3918  \else
3919    \@tempdima=#1\relax
3920    \edef\FV@boxwidth{\number\@tempdima sp}%
3921  \fi}
3922%    \end{macrocode}
3923% \end{macro}
3924%
3925% \begin{macro}{\KV@FV@boxwidth@default}
3926%    \begin{macrocode}
3927\def\KV@FV@boxwidth@default{\let\FV@boxwidth\relax}
3928%    \end{macrocode}
3929% \end{macro}
3930%
3931% \begin{macro}{\FV@baseline}
3932%    \begin{macrocode}
3933\define@key{FV}{baseline}{%
3934  \if t#1\@empty\let\FV@baseline\@ne\else
3935    \if c#1\@empty\let\FV@baseline\tw@\else\let\FV@baseline\z@\fi
3936  \fi}
3937%    \end{macrocode}
3938% \end{macro}
3939%
3940%    \begin{macrocode}
3941\fvset{baseline=b,boxwidth}
3942%    \end{macrocode}
3943%
3944% \begin{macro}{\FV@BProcessLine}
3945%    \begin{macrocode}
3946\def\FV@BProcessLine#1{\hbox{\FancyVerbFormatLine{#1}}}
3947%    \end{macrocode}
3948% \end{macro}
3949%
3950% \begin{macro}{\FVB@BVerbatim}
3951%    \begin{macrocode}
3952\def\FVB@BVerbatim{\FV@BVerbatimBegin\FV@Scan}
3953%    \end{macrocode}
3954% \end{macro}
3955%
3956% \begin{macro}{\FVE@BVerbatim}
3957%    \begin{macrocode}
3958\def\FVE@BVerbatim{\FV@BVerbatimEnd}
3959%    \end{macrocode}
3960% \end{macro}
3961%
3962%    \begin{macrocode}
3963\DefineVerbatimEnvironment{BVerbatim}{BVerbatim}{}
3964%    \end{macrocode}
3965%
3966% \begin{macro}{\FV@BUseVerbatim}
3967%    \begin{macrocode}
3968\def\FV@BUseVerbatim#1{\FV@BVerbatimBegin#1\FV@BVerbatimEnd}
3969%    \end{macrocode}
3970% \end{macro}
3971%
3972% \begin{macro}{\BVerbatimInput}
3973%    \begin{macrocode}
3974\def\BVerbatimInput{\FV@Command{}{BVerbatimInput}}
3975%    \end{macrocode}
3976% \end{macro}
3977%
3978% \begin{macro}{\FVC@BVerbatimInput}
3979%    \begin{macrocode}
3980\def\FVC@BVerbatimInput#1{\FV@BUseVerbatim{\FV@Input{#1}}}
3981%    \end{macrocode}
3982% \end{macro}
3983%
3984% \subsection{Save verbatim}
3985%
3986% \DescribeEnv{SaveVerbatim}
3987%    \begin{macrocode}
3988\def\SaveVerbatim{\FV@Environment{}{SaveVerbatim}}
3989%    \end{macrocode}
3990%
3991% \begin{macro}{\FVB@SaveVerbatim}
3992%    \begin{macrocode}
3993\def\FVB@SaveVerbatim#1{%
3994  \@bsphack
3995  \begingroup
3996    \FV@UseKeyValues
3997%%    \FV@BeginVBox
3998%%    \let\FV@ProcessLine\FV@BProcessLine
3999%%    \FV@FormattingPrep
4000%%    \FV@ObeyTabsInit%
4001%%
4002    \def\SaveVerbatim@Name{#1}%
4003    \gdef\FV@TheVerbatim{}%
4004    \def\FV@ProcessLine##1{%
4005      \expandafter\gdef\expandafter\FV@TheVerbatim\expandafter{%
4006        \FV@TheVerbatim\FV@ProcessLine{##1}}}%
4007    \gdef\FV@TheVerbatim{}%
4008    \FV@Scan}
4009%    \end{macrocode}
4010% \end{macro}
4011%
4012% \begin{macro}{\FVE@SaveVerbatim}
4013%    \begin{macrocode}
4014\def\FVE@SaveVerbatim{%
4015  \expandafter\global\expandafter\let
4016  \csname FV@SV@\SaveVerbatim@Name\endcsname\FV@TheVerbatim
4017%%  \expandafter\gdef
4018%%    \csname FV@SV@\SaveVerbatim@Name\endcsname{\FV@TheVerbatim}
4019%%    \FV@EndVBox
4020%%  \endgroup}
4021  \endgroup\@esphack}
4022%    \end{macrocode}
4023% \end{macro}
4024%
4025% \DescribeEnv{SaveVerbatim}
4026%    \begin{macrocode}
4027\DefineVerbatimEnvironment{SaveVerbatim}{SaveVerbatim}{}
4028%    \end{macrocode}
4029%
4030% \begin{macro}{\FV@CheckIfSaved}
4031%    \begin{macrocode}
4032\def\FV@CheckIfSaved#1#2{%
4033  \@ifundefined{FV@SV@#1}%
4034  {\FV@Error{No verbatim text has been saved under name `#1'}\FV@eha}%
4035  {#2{\csname FV@SV@#1\endcsname}}}
4036%    \end{macrocode}
4037% \end{macro}
4038%
4039% \begin{macro}{\UseVerbatim}
4040%    \begin{macrocode}
4041\def\UseVerbatim{\FV@Command{}{UseVerbatim}}
4042%    \end{macrocode}
4043% \end{macro}
4044%
4045% \begin{macro}{\FVC@UseVerbatim}
4046%    \begin{macrocode}
4047\def\FVC@UseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@UseVerbatim}}
4048%    \end{macrocode}
4049% \end{macro}
4050%
4051% \begin{macro}{\LUseVerbatim}
4052%    \begin{macrocode}
4053\def\LUseVerbatim{\FV@Command{}{LUseVerbatim}}
4054%    \end{macrocode}
4055% \end{macro}
4056%
4057% \begin{macro}{\FVC@LUseVerbatim}
4058%    \begin{macrocode}
4059\def\FVC@LUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@LUseVerbatim}}
4060%    \end{macrocode}
4061% \end{macro}
4062%
4063% \begin{macro}{\BUseVerbatim}
4064%    \begin{macrocode}
4065\def\BUseVerbatim{\FV@Command{}{BUseVerbatim}}
4066%    \end{macrocode}
4067% \end{macro}
4068%
4069% \begin{macro}{\FVC@BUseVerbatim}
4070%    \begin{macrocode}
4071\def\FVC@BUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@BUseVerbatim}}
4072%    \end{macrocode}
4073% \end{macro}
4074%
4075% \subsection{Verbatim out}
4076%
4077%    \begin{macrocode}
4078\newwrite\FV@OutFile
4079%    \end{macrocode}
4080%
4081% \begin{macro}{\VerbatimOut}
4082%    \begin{macrocode}
4083\def\VerbatimOut{\FV@Environment{}{VerbatimOut}}
4084%    \end{macrocode}
4085% \end{macro}
4086%
4087% \ifChangeBar\begin{changebar}\fi
4088% \begin{macro}{\FVB@VerbatimOut}
4089%    \begin{macrocode}
4090\def\FVB@VerbatimOut#1{%
4091  \@bsphack
4092  \begingroup
4093    \FV@UseKeyValues
4094    \FV@DefineWhiteSpace
4095    \def\FV@Space{\space}%
4096    \FV@DefineTabOut
4097    \def\FV@ProcessLine{\immediate\write\FV@OutFile}%
4098    \immediate\openout\FV@OutFile #1\relax
4099    \let\FV@FontScanPrep\relax
4100%% DG/SR modification begin - May. 18, 1998 (to avoid problems with ligatures)
4101    \let\@noligs\relax
4102%% DG/SR modification end
4103    \FV@Scan}
4104%    \end{macrocode}
4105% \end{macro}
4106% \ifChangeBar\end{changebar}\fi
4107%
4108% \begin{macro}{\FVE@VerbatimOut}
4109%    \begin{macrocode}
4110\def\FVE@VerbatimOut{\immediate\closeout\FV@OutFile\endgroup\@esphack}
4111%    \end{macrocode}
4112% \end{macro}
4113%
4114% \DescribeEnv{VerbatimOut}
4115%    \begin{macrocode}
4116\DefineVerbatimEnvironment{VerbatimOut}{VerbatimOut}{}
4117%    \end{macrocode}
4118%
4119% \begin{macro}{\FV@DefineTabOut}
4120%    \begin{macrocode}
4121\def\FV@DefineTabOut{%
4122  \def\FV@Tab{}%
4123  \@tempcnta=\FancyVerbTabSize\relax
4124  \loop\ifnum\@tempcnta>\z@
4125    \edef\FV@Tab{\FV@Tab\space}%
4126    \advance\@tempcnta\m@ne
4127  \repeat}
4128%    \end{macrocode}
4129% \end{macro}
4130%
4131% \subsection{Short verbatim}
4132%
4133% \cs{SaveVerb}
4134%
4135% Note ``\verb+\outer\def^^M{}+''. This is so that verbatim commands report an
4136% error when encountering an end-of-line, rather than scanning to
4137% the end of the file each time there is a missing verbatim delimiter.
4138%
4139% If scanning fails (and thus \TeX{} ignores \cs{FV@GetVerb}), \verb+#1+ is
4140% defined to be empty, a group is ended, but \cs{FancyVerbAfterSave} is not
4141% invoked.
4142%
4143% \begin{macro}{\FV@Command}
4144%    \begin{macrocode}
4145\def\SaveVerb{\FV@Command{}{SaveVerb}}
4146%    \end{macrocode}
4147% \end{macro}
4148%
4149% \begin{macro}{\FVC@SaveVerb}
4150%    \begin{macrocode}
4151\begingroup
4152\catcode`\^^M=\active%
4153\gdef\FVC@SaveVerb#1#2{%
4154  \@namedef{FV@SV@#1}{}%
4155  \begingroup%
4156    \FV@UseKeyValues%
4157    \FV@CatCodes%
4158    \outer\def^^M{\FV@EOL}%
4159    \global\let\@tempg\FancyVerbAfterSave%
4160    \catcode`#2=12%
4161    \def\@tempa{\def\FancyVerbGetVerb####1####2}%
4162    \expandafter\@tempa\string#2{\endgroup\@namedef{FV@SV@#1}{##2}\@tempg}%
4163    \FancyVerbGetVerb\FV@EOL}%
4164\endgroup
4165%    \end{macrocode}
4166% \end{macro}
4167%
4168% \begin{macro}{\FV@EOL}
4169%    \begin{macrocode}
4170\def\FV@EOL{%
4171  \endgroup
4172  \FV@Error%
4173    {Could not find the end delimiter of a short verb command}%
4174    {You probably just forget the end delimiter of a \string\Verb\space or
4175      \string\SaveVerb^^J%
4176      command, or you broke the literal text across input lines.^^J%
4177      Hit <return> to procede.}}
4178%    \end{macrocode}
4179% \end{macro}
4180%
4181% \begin{macro}{\FancyVerbAfterSave}
4182%    \begin{macrocode}
4183\define@key{FV}{aftersave}{\def\FancyVerbAfterSave{#1}}
4184\fvset{aftersave=}
4185%    \end{macrocode}
4186% \end{macro}
4187%
4188% \begin{macro}{\FV@UseVerb}
4189%    \begin{macrocode}
4190\def\FV@UseVerb#1{\mbox{\FV@UseKeyValues\FV@FormattingPrep#1}}
4191%    \end{macrocode}
4192% \end{macro}
4193%
4194% \begin{macro}{\UseVerb}
4195%    \begin{macrocode}
4196\def\UseVerb{\FV@Command{}{UseVerb}}
4197%    \end{macrocode}
4198% \end{macro}
4199%
4200% \begin{macro}{\FVC@UseVerb}
4201%    \begin{macrocode}
4202\def\FVC@UseVerb#1{%
4203  \@ifundefined{FV@SV@#1}%
4204    {\FV@Error{Short verbatim text never saved to name `#1'}\FV@eha}%
4205    {\FV@UseVerb{\@nameuse{FV@SV@#1}}}}
4206%    \end{macrocode}
4207% \end{macro}
4208%
4209% \begin{macro}{\Verb}
4210%    \begin{macrocode}
4211\def\Verb{\FV@Command{}{Verb}}
4212%    \end{macrocode}
4213% \end{macro}
4214%
4215% \begin{macro}{\FVC@Verb}
4216%    \begin{macrocode}
4217\begingroup
4218\catcode`\^^M=\active%
4219\gdef\FVC@Verb#1{%
4220  \begingroup%
4221    \FV@UseKeyValues%
4222    \FV@FormattingPrep%
4223    \FV@CatCodes%
4224    \outer\def^^M{}%
4225    \catcode`#1=12%
4226    \def\@tempa{\def\FancyVerbGetVerb####1####2}%
4227    \expandafter\@tempa\string#1{\mbox{##2}\endgroup}%
4228    \FancyVerbGetVerb\FV@EOL}%
4229\endgroup
4230%    \end{macrocode}
4231% \end{macro}
4232%
4233% \begin{macro}{\DefineShortVerb}
4234%    \begin{macrocode}
4235\def\DefineShortVerb{\FV@Command{}{DefineShortVerb}}
4236%    \end{macrocode}
4237% \end{macro}
4238%
4239% \begin{macro}{\FVC@DefineShortVerb}
4240%    \begin{macrocode}
4241\def\FVC@DefineShortVerb#1{%
4242  \@ifundefined{FV@CC@\string#1}%
4243    {\FVC@@DefineShortVerb#1}%
4244    {\FV@Error{`\expandafter\@gobble\string#1' is already a short
4245      verb character.}\FV@eha}}
4246%    \end{macrocode}
4247% \end{macro}
4248%
4249% \begin{macro}{\FVC@@DefineShortVerb}
4250%    \begin{macrocode}
4251\def\FVC@@DefineShortVerb#1{%
4252  \begingroup
4253    \lccode`\~=`#1%
4254    \lowercase{\gdef\@tempg{\edef~}\global\let\@temph~}%
4255  \endgroup
4256  \expandafter\let\csname FV@AC@\string#1\endcsname\@temph
4257  \expandafter\edef\csname FV@CC@\string#1\endcsname{\the\catcode`#1}%
4258  \expandafter\let\csname FV@KV@\string#1\endcsname\FV@KeyValues
4259  \@tempg{%
4260    \let\noexpand\FV@KeyValues\expandafter\noexpand
4261      \csname FV@KV@\string#1\endcsname
4262    \noexpand\FVC@Verb\expandafter\@gobble\string#1}%
4263  \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do#1}%
4264  \expandafter\def\expandafter\@sanitize\expandafter{\@sanitize\@makeother#1}%
4265  \catcode`#1=\active}%
4266%    \end{macrocode}
4267% \end{macro}
4268%
4269% \begin{macro}{\UndefineShortVerb}
4270%    \begin{macrocode}
4271\def\UndefineShortVerb#1{%
4272  \@ifundefined{FV@CC@\string#1}%
4273    {\FV@Error{`\expandafter\@gobble\string#1' is not a short
4274      verb character}\FV@eha}%
4275    {\FV@UndefineShortVerb#1}}
4276%    \end{macrocode}
4277% \end{macro}
4278%
4279% \changes{v2.6}{1998/07/17}{Correct a bug to undefine the macro associated
4280%                            to short verbatim character
4281%                            (reported by Mikhail Kolodin on June 12, 1998).}
4282%
4283% \ifChangeBar\begin{changebar}\fi
4284% \begin{macro}{\FV@UndefineShortVerb}
4285%    \begin{macrocode}
4286\def\FV@UndefineShortVerb#1{%
4287  \catcode`#1=\csname FV@CC@\string#1\endcsname
4288%% DG/SR modification begin - Jun. 12, 1998
4289  \expandafter\let\csname FV@CC@\string#1\endcsname\relax
4290%% DG/SR modification end
4291  \begingroup
4292    \lccode`\~=`#1%
4293    \lowercase{\gdef\@tempg{\let~}}%
4294  \endgroup
4295  \expandafter\@tempg\csname FV@AC@\string#1\endcsname
4296  \def\@tempa##1\do#1##2\@nil##3\@nil##4\@@nil{##3\def\dospecials{##1##2}\fi}%
4297  \expandafter\@tempa\dospecials\@nil\iftrue\@nil\do#1\@nil\iffalse\@nil\@@nil
4298  \def\@tempa##1\@makeother#1##2\@nil##3\@nil##4\@@nil{%
4299    ##3\def\@sanitize{##1##2}\fi}%
4300  \expandafter\@tempa\@sanitize\@nil\iftrue\@nil\do#1\@nil\iffalse\@nil\@@nil}
4301%    \end{macrocode}
4302% \end{macro}
4303% \ifChangeBar\end{changebar}\fi
4304%
4305% Moving verbatim. Need to worry about using separate identifier
4306% for this class of verbatim, and
4307%
4308% \begin{macro}{\SaveMVerb}
4309%    \begin{macrocode}
4310\def\SaveMVerb{\FV@Command{}{SaveMVerb}}
4311%    \end{macrocode}
4312% \end{macro}
4313%
4314% \begin{macro}{\FVC@SaveMVerb}
4315%    \begin{macrocode}
4316\begingroup
4317\catcode`\^^M=\active%
4318\gdef\FVC@SaveMVerb#1#2{%
4319  \@ifundefined{FV@SVM@#1}{}%
4320    {\FV@Error{Moving verbatim name `#1' already used}%
4321      {I will overwrite the old definition. Hit <return> to continue.}}%
4322  \global\@namedef{FV@SVM@#1}{}%
4323  \begingroup%
4324    \let\FV@SavedKeyValues\FV@KeyValues%
4325    \FV@UseKeyValues%
4326    \FV@CatCodes%
4327    \outer\def^^M{}%
4328    \global\let\@tempg\FancyVerbAfterSave%
4329    \catcode`#2=12%
4330    \def\@tempa{\def\FancyVerbGetVerb####1####2}%
4331    \expandafter\@tempa\string#2{%
4332      \if@filesw
4333        \FV@DefineWhiteSpace%
4334        \let\FV@Space\space%
4335        \let\FV@Tab\space%
4336        \FV@MakeUnActive%
4337        \let\protect\string
4338        \immediate\write\@auxout{%
4339          \noexpand\SaveGVerb[\FV@SavedKeyValues]{#1}\string#2##2\string#2}%
4340      \fi
4341      \endgroup%
4342      \@namedef{FV@SV@#1}{##2}%
4343      \@tempg}%
4344    \FancyVerbGetVerb\FV@EOL}%
4345\endgroup
4346%    \end{macrocode}
4347% \end{macro}
4348%
4349% \begin{macro}{\SaveGVerb}
4350%    \begin{macrocode}
4351\def\SaveGVerb{\FV@Command{}{SaveGVerb}}
4352%    \end{macrocode}
4353% \end{macro}
4354%
4355% \begin{macro}{\FVC@SaveGVerb}
4356%    \begin{macrocode}
4357\begingroup
4358\catcode`\^^M=\active%
4359\gdef\FVC@SaveGVerb#1#2{%
4360  \global\@namedef{FV@SVG@#1}{}%
4361  \begingroup%
4362    \FV@UseKeyValues%
4363    \FV@CatCodes%
4364    \outer\def^^M{}%
4365    \catcode`#2=12%
4366    \def\@tempa{\def\FancyVerbGetVerb####1####2}%
4367    \expandafter\@tempa\string#2{\endgroup\global\@namedef{FV@SVG@#1}{##2}}%
4368    \FancyVerbGetVerb\FV@EOL}%
4369\endgroup
4370%    \end{macrocode}
4371% \end{macro}
4372%
4373% \begin{macro}{\UseMVerb}
4374%    \begin{macrocode}
4375\def\UseMVerb{\protect\pUseMVerb}
4376%    \end{macrocode}
4377% \end{macro}
4378%
4379% \begin{macro}{\pUseMVerb}
4380%    \begin{macrocode}
4381\def\pUseMVerb{\FV@Command{}{pUseMVerb}}
4382%    \end{macrocode}
4383% \end{macro}
4384%
4385% \begin{macro}{\FVC@pUseMVerb}
4386%    \begin{macrocode}
4387\def\FVC@pUseMVerb#1{%
4388  \expandafter\ifx \csname FV@SVM@#1\endcsname\relax
4389    \expandafter\ifx \csname FV@SVG@#1\endcsname\relax
4390      \@warning{Moving verbatim text not defined for name `#1'}\FV@eha
4391      {\bf ??}%
4392    \else
4393      \FV@UseVerb{\@nameuse{FV@SVG@#1}}%
4394    \fi
4395  \else
4396    \FV@UseVerb{\@nameuse{FV@SVM@#1}}%
4397  \fi}
4398%    \end{macrocode}
4399% \end{macro}
4400%
4401%    \begin{macrocode}
4402\expandafter\ifx\csname documentclass\endcsname\relax
4403%    \end{macrocode}
4404%
4405% \DescribeEnv{lrbox}
4406%    \begin{macrocode}
4407  \def\lrbox#1{%
4408    \edef\@tempa{%
4409      \endgroup
4410      \setbox#1\hbox{%
4411        \begingroup\aftergroup}%
4412          \def\noexpand\@currenvir{\@currenvir}}%
4413          %\def\noexpand\@currenvline{\on@line}}%
4414    \@tempa
4415      \@endpefalse
4416      \bgroup
4417        \ignorespaces}
4418  \def\endlrbox{\unskip\egroup}
4419%    \end{macrocode}
4420%
4421%    \begin{macrocode}
4422\fi
4423%    \end{macrocode}
4424%
4425%    \begin{macrocode}
4426%% DG/SR modification begin - Jan. 22, 1998
4427%%\@input{fancyvrb.rc}
4428\@input{fancyvrb.cfg}
4429%% DG/SR modification end
4430%    \end{macrocode}
4431%
4432% \noindent Unused code - don't take care! (DG/SR)
4433%
4434% \noindent Error messages to void:
4435%
4436% \begin{verbatim}
4437% \FV@CheckBadBegin
4438% \FV@CheckBadEnd
4439%
4440% \define@key{FV}{noligs}{%
4441%   \def\FV@ActiveLigs{}%
4442%   \def\FV@DefineLigs{}%
4443%   \@tfor\@tempa:=#1\do{%
4444%     {\lccode`\~=`#1\relax\lowercase{\gdef\@tempg{~}}}%
4445%     \expandafter\FV@addtonoligs\@tempg}}
4446% \def\FV@addtonoligs#1{%
4447%   \expandafter\def\expandafter\FV@ActiveLigs\expandafter{%
4448%     \FV@ActiveLigs\catcode`#1=\active}%
4449%   \expandafter\def\expandafter\FV@DefineLigs\expandafter{%
4450%     \FV@DefineLigs\edef#1{{\string#1}}}}
4451%
4452% \fvset{suppressligs=\'}
4453%
4454% \fvset{noligs={>,-}}
4455% \fvset{suppressligs=\>}
4456% \fvset{suppressligs=\<}
4457%
4458% \def\FV@Error#1#2{%
4459%   \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
4460%   \typeout{%
4461%     ^^J** FancyVerb Error:\space\space
4462%     Type \space H <return> \space for immediate help. **}%
4463%   \errmessage{#1^^J}}
4464% \end{verbatim}
4465%
4466%</fancyvrb>
4467%
4468% \Finale
4469% \PrintIndex
4470% \PrintChanges
4471%
4472\endinput
4473%%
4474%% End of file `fancyvrb.dtx'
4475