0% found this document useful (0 votes)
207 views73 pages

Fancyvrb PDF

The 'fancyvrb' package provides sophisticated facilities for typesetting verbatim text in LaTeX. It offers enhanced verbatim commands, various customizable verbatim environments, and the ability to save and restore verbatim content. The package scans text line-by-line, allowing pre-processing of each line through parameters like formatting, numbering, font selection, and more. This allows precise control over how verbatim code examples are displayed.

Uploaded by

dart13
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views73 pages

Fancyvrb PDF

The 'fancyvrb' package provides sophisticated facilities for typesetting verbatim text in LaTeX. It offers enhanced verbatim commands, various customizable verbatim environments, and the ability to save and restore verbatim content. The package scans text line-by-line, allowing pre-processing of each line through parameters like formatting, numbering, font selection, and more. This allows precise control over how verbatim code examples are displayed.

Uploaded by

dart13
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

The fancyvrb package A Fancy Verbatims in L TEX

Timothy Van Zandt Princeton University Princeton USA


[email protected]

Packaging and documentation by


Denis Girou (CNRS/IDRIS France), Sebastian Rahtz (Elsevier GB) and Herbert Vo (FU Berlin DE)

Version 2.8 May 15, 2010


Documentation revised May 15, 2010

Abstract This package provides very sophisticated facilities for reading and writing verbatim TEX code. Users can perform common tasks like changing font family and size, numbering lines, framing code examples, colouring text and conditionally processing text.

Contents
1 Introduction 2 Verbatim material in footnotes 3 Improved verbatim commands 4 Verbatim environments 4.1 Customization of verbatim environments . 4.1.1 Comments . . . . . . . . . . . . . . . . 4.1.2 Initial characters to suppress . . . . . 4.1.3 Customization of formatting . . . . . 4.1.4 Changing individual line formatting 4.1.5 Fonts . . . . . . . . . . . . . . . . . . . 4.1.6 Types and characteristics of frames . 1 3 3 4 4 4 4 5 5 6 6 7

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

4.1.7 Label for the environment . . . . . . . . . . 4.1.8 Line numbering . . . . . . . . . . . . . . . . . 4.1.9 Selection of lines to print . . . . . . . . . . . 4.1.10 Spaces and tab characters . . . . . . . . . . 4.1.11 Space between lines . . . . . . . . . . . . . . 4.1.12 Escape characters for inserting commands 4.1.13 Margins . . . . . . . . . . . . . . . . . . . . . 4.1.14 Overfull box messages . . . . . . . . . . . . 4.1.15 Page breaks . . . . . . . . . . . . . . . . . . . 4.1.16 Catcode characters . . . . . . . . . . . . . . . 4.1.17 Active characters . . . . . . . . . . . . . . . . 4.2 Different kinds of verbatim environments . . . . . 4.2.1 Verbatim environment . . . . . . . . . . . . 4.2.2 BVerbatim environment . . . . . . . . . . . . 4.2.3 LVerbatim environment . . . . . . . . . . . . 4.2.4 Personalized environments . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

9 10 12 13 14 14 15 16 16 16 16 17 17 17 17 18 18 20 21 21 22 22 22 23 23 23 23 24 27 28 29 34 34 36 38 39 44 60 62

5 Saving and restoring verbatim text and environments 6 Writing and reading verbatim les 7 Automatic pretty printing 8 Known problems 9 Thanks 10 Conclusion 11 Driver le 12 fancyvrb code 12.1 Preambule . . . . . . . . . . . . . . . 12.2 Errors . . . . . . . . . . . . . . . . . . 12.3 Verbatim footnotes . . . . . . . . . . 12.4 key=value . . . . . . . . . . . . . . . 12.5 Scanning . . . . . . . . . . . . . . . . 12.6 Codes . . . . . . . . . . . . . . . . . . 12.7 Preprocess line . . . . . . . . . . . . . 12.8 Scanning environments . . . . . . . 12.9 Check end . . . . . . . . . . . . . . . . 12.10Line-by-line scanning . . . . . . . . . 12.11Input . . . . . . . . . . . . . . . . . . . 12.12Formatting Common components 12.13List environments . . . . . . . . . . . 12.14BVerbatim . . . . . . . . . . . . . . . . 12.15Save verbatim . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

12.16Verbatim out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.17Short verbatim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

63 64

1 Introduction
fancyvrb is the development of the verbatim macros of the fancybox package, Section 11 of [1]. It offers six kinds of extended functionality, compared to the standard A L TEX verbatim environment: 1. verbatim commands can be used in footnotes, 2. several verbatim commands are enhanced, 3. a variety of verbatim environments are provided, with many parameters to change the way the contents are printed; it is also possible to dene new customized verbatim environments, 4. a way is provided to save and restore verbatim text and environments, 5. there are macros to write and read les in verbatim mode, with the usual versatility, 6. you can build example environments (showing both result and verbatim text), with the same versatility as normal verbatim. The package works by scanning a line at a time from an environment or a le. This allows it to pre-process each line, rejecting it, removing spaces, numbering it, etc, before going on to execute the body of the line with the appropriate catcodes set.

2 Verbatim material in footnotes


After a \VerbatimFootnotes macro declaration (to use after the preamble), it is A possible to put verbatim commands and environments (the L TEX or fancyvrb ones) A in footnotes, unlike in standard L TEX:
1 2

\VerbatimFootnotes We can put verbatim\footnote{\verb+_Yes!_+} text in footnotes.


We can put verbatim1 text in footnotes.
1

_Yes!_

3 Improved verbatim commands


The \DefineShortVerb macro allows us to dene a special character as an abbreviation to enclose verbatim text and the \UndefineShortVerb macro suppresses the special meaning of the specied character (the same functionalities are provided A in the L TEX shortvrb package): We can simply write material
1 2 3 4 5 6

_verbatim_

using a single _delimiter_ And we can _change_ the character.

\DefineShortVerb{\|} We can simply write \Verb+_verbatim_+ material using a single |_delimiter_| \UndefineShortVerb{\|} \DefineShortVerb{\+} And we can +_change_+ the character.

To make matters more versatile, we can nominate escape characters in verbatim text (using the \Verb macro or with a shortverb character dened), to perform formatting or similar tasks, using the commandchars parameter as shown for environments in paragraph 4.1.12.

4 Verbatim environments
Several verbatim environments are available, each with a lot of parameters to customize them. In the following examples we use the Verbatim environment, which is the equivalent of the standard verbatim. The parameters can be set globally using the \fvset macro or in an optional argument after the start of the environment2 ,3 .
1

First verbatim line. 2 Second verbatim line. 3


4

\begin{Verbatim} First verbatim line. Second verbatim line. \end{Verbatim}

4.1 Customization of verbatim environments


The appearance of verbatim environments can be changed in many and varied ways; here we list the keys that can be set. 4.1.1 Comments

commentchar (character) : character to dene comments in the verbatim code, so


that lines starting with this character will not be printed (Default: empty).
For clarication in this paper, note that we generally indent each verbatim line with two spaces. AT X graphics distribution, written by This mechanism uses the keyval package from the standard L E David CARLISLE.
3 2

% A comment Verbatim line.

2 3 4 5

\begin{Verbatim}[commentchar=!] % A comment Verbatim line. ! A comment that you will not see \end{Verbatim}

Take care to a special effect if the comment character is not the rst non blank one: it is because this character is in fact managed as the TEX comment one, that is to say that it gobble the newline character too. So, in this case, the current line will be joined with the next one and, more, the last one will be lost if it contain a comment, as fancyvrb print a line only after nding it end character, which will never occured in this case...
1 2

First line.

Second. 3
4 5

\begin{Verbatim}[commentchar=\%] First line. % First line Second. Third line. % Third line lost... \end{Verbatim}

4.1.2 Initial characters to suppress

gobble (integer) : number of characters to suppress at the beginning of each line (up
to a maximum of 9), mainly useful when environments are indented (Default: empty no character suppressed).

1 2 3

\begin{Verbatim} Verbatim line. \end{Verbatim} \begin{Verbatim}[gobble=2] Verbatim line. \end{Verbatim} \begin{Verbatim}[gobble=8] Verbatim line. \end{Verbatim}

Verbatim line. Verbatim line. im line.

4 5 6 7 8 9 10 11

4.1.3 Customization of formatting

formatcom (command) : command to execute before printing verbatim text (Default: empty).

First verbatim line. 2 Second verbatim line. 3


4

\begin{Verbatim}[formatcom=\color{red}] First verbatim line. Second verbatim line. \end{Verbatim}

4.1.4 Changing individual line formatting The macro \FancyVerbFormatLine denes the way each line is formatted. Its default value is \def\FancyVerbFormatLine#1{#1}, but we can redene it at our convenience (FancyVerbLine is the name of the line counter):

\renewcommand{\FancyVerbFormatLine}[1]{% \makebox[0cm][l]{$\Rightarrow$}#1} First verbatim line. 3 \begin{Verbatim} 4 First verbatim line. Second verbatim line. 5 Second verbatim line. Third verbatim line. 6 Third verbatim line. 7 \end{Verbatim}
1 2

1 2

FIRST VERBATIM LINE. Second verbatim line. THIRD VERBATIM LINE.

3 4 5 6 7 8

\renewcommand{\FancyVerbFormatLine}[1]{% \ifodd\value{FancyVerbLine}% \MakeUppercase{#1}\else#1\fi} \begin{Verbatim} First verbatim line. Second verbatim line. Third verbatim line. \end{Verbatim}

4.1.5 Fonts

fontfamily (family name) : font family to use. tt, courier and helvetica are
pre-dened (Default: tt).

Verbatim line.

2 3

\begin{Verbatim}[fontfamily=helvetica] Verbatim line. \end{Verbatim}

fontsize (font size) : size of the font to use (Default: auto the same as the current font). If you use the relsize package too, you can require a change of the size proportional to the current one (for instance: fontsize=\relsize{-2}).

1 2

Verbatim line.

3 4 5 6 7 8

\begin{Verbatim}[fontsize=\small] Verbatim line. \end{Verbatim} \begin{Verbatim}[fontfamily=courier, fontsize=\large] Verbatim line. \end{Verbatim}

Verbatim line.

fontshape (font shape) : font shape to use (Default: auto the same as the current
font).

Verbatim line.

2 3 4

\begin{Verbatim}[fontfamily=courier, fontshape=it] Verbatim line. \end{Verbatim}

A fontseries (series name) : L TEX font series to use (Default: auto the same as the

current font).

Verbatim line.

2 3 4

\begin{Verbatim}[fontfamily=courier, fontseries=b] Verbatim line. \end{Verbatim}

4.1.6 Types and characteristics of frames

frame (none|leftline|topline|bottomline|lines|single) : type of frame around the verbatim environment (Default: none no frame). With leftline and single modes, A a space of a length given by the L TEX \fboxsep macro is added between the
left vertical line and the text.

1 2 3 4

\begin{Verbatim}[frame=leftline] Verbatim line. \end{Verbatim} \begin{Verbatim}[frame=topline] Verbatim line. \end{Verbatim} \begin{Verbatim}[frame=bottomline] Verbatim line. \end{Verbatim} \begin{Verbatim}[frame=lines] Verbatim line. \end{Verbatim} \begin{Verbatim}[frame=single] Verbatim line. \end{Verbatim}

Verbatim line. Verbatim line. Verbatim line.

5 6 7 8 9 10 11

Verbatim line. Verbatim line.

12 13 14 15 16 17 18 19

framerule (dimension) : width of the rule of the frame (Default: 0.4pt if framing
specied).

Verbatim line.

2 3 4

\begin{Verbatim}[frame=single, framerule=1mm] Verbatim line. \end{Verbatim}

framesep (dimension) : width of the gap between the frame and the text (Default: \fboxsep).
1

Verbatim line.

2 3 4

\begin{Verbatim}[frame=single, framesep=5mm] Verbatim line. \end{Verbatim}

A rulecolor (color command) : color of the frame rule, expressed in the standard L TEX

way (Default: black).

Verbatim line.

2 3 4

\begin{Verbatim}[frame=single, rulecolor=\color{red}] Verbatim line. \end{Verbatim}

llcolor (color command) : color used to ll the space between the frame and the text (its thickness is given by framesep) (Default: none no color).
1 2

Verbatim line.

3 4 5 6

\begin{Verbatim}[frame=single, framerule=1mm,framesep=3mm, rulecolor=\color{red}, fillcolor=\color{yellow}] Verbatim line. \end{Verbatim}

4.1.7 Label for the environment

label ({[string]string}) : label(s) to print on top, bottom or both frame


lines of the environment to describe it content (Default: empty no label). If the label(s) contains special characters, as a comma or an equal sign, it must be put inside a group. If only one string is given, it will be used for both top and bottom lines (if the two are printed), but if an optional rst label is given too, this one will be used for the top line and the second one for the bottom line. Note also that, if another value than topline, bottomline, lines or single is used for the frame parameter, the label(s) will not be printed.
1 2

My text First verbatim line. Second verbatim line.

3 4 5 6 7

\fvset{gobble=2} \begin{Verbatim}[frame=single, label=My text] First verbatim line. Second verbatim line. \end{Verbatim} \begin{Verbatim}[frame=topline, framesep=4mm, label=\fbox{\Large\emph{The code}}] First verbatim line. Second verbatim line. \end{Verbatim}

The code
First verbatim line. Second verbatim line.

8 9 10 11 12 13

labelposition (none|topline|bottomline|all) : position where to print the label if one

is dened, which must be coherent with the kind of frame chosen (Default: none if the label is empty, topline if one label is dened and all if two are dened). Of course, some incompatible options (like frame=topline,labelposition=bottomline) will not print the label.
1 2

Text First verbatim line. Second verbatim line. Text Text First verbatim line. Second verbatim line.

3 4 5 6 7 8 9 10 11 12 13

\fvset{gobble=2} \begin{Verbatim}[frame=single, framesep=2mm, label=Text,labelposition=all] First verbatim line. Second verbatim line. \end{Verbatim} \begin{Verbatim}[frame=lines, label=Text,labelposition=topline] First verbatim line. Second verbatim line. \end{Verbatim}

1 2 3

First verbatim line. 4 Second verbatim line. 5 6 Code included


7

\begin{Verbatim}[frame=bottomline, framesep=3mm, label=\textit{Code included}, labelposition=bottomline] First verbatim line. Second verbatim line. \end{Verbatim}

Beginning of code 8 First verbatim line. 9 \begin{Verbatim}[frame=lines, framesep=3mm, Second verbatim line. 10 End of code 11 label={[Beginning of code]End of code}] 12 First verbatim line. 13 Second verbatim line. 14 \end{Verbatim}

4.1.8 Line numbering

numbers (none|left|right) : numbering of the verbatim lines (Default: none no


numbering). If requested, this numbering is done outside the verbatim environment.

10

1 2

1 2

First verbatim line. Second verbatim line. First verbatim line. Second verbatim line.
1

3 4 5 6 7 2 8 9 10

\begin{Verbatim}[gobble=2,numbers=left] First verbatim line. Second verbatim line. \end{Verbatim} \begin{Verbatim}[gobble=2, numbers=right,numbersep=0pt] First verbatim line. Second verbatim line. \end{Verbatim}

numbersep (dimension) : gap between numbers and verbatim lines (Default: 12pt).
1

1 2

First verbatim line. Second verbatim line.

2 3 4 5

\begin{Verbatim}[gobble=2, numbers=left,numbersep=2pt] First verbatim line. Second verbatim line. \end{Verbatim}

rstnumber (auto|last|integer) : number of the rst line (Default: auto numbering starts from 1). last means that the numbering is continued from the previous verbatim environment. If an integer is given, its value will be used to start the numbering.

1 2 3 4 1

Verbatim line. Verbatim line. Verbatim line.

5 6

\fvset{gobble=2, numbers=left,numbersep=3pt} \begin{Verbatim} Verbatim line. \end{Verbatim} \begin{Verbatim}[firstnumber=last] Verbatim line. \end{Verbatim} \begin{Verbatim}[firstnumber=100] Verbatim line. \end{Verbatim}

7 8

100

9 10 11 12 13

stepnumber (integer) : interval at which line numbers are printed (Default: 1 all
lines are numbered).

11

First verbatim line. Second verbatim line. Third verbatim line.

2 3 4 5 6

\begin{Verbatim}[gobble=2,numbers=left, numbersep=3pt,stepnumber=2] First verbatim line. Second verbatim line. Third verbatim line. \end{Verbatim}

The macro \theFancyVerbLine denes the typesetting style of the numbering, and the counter used is FancyVerbLine:
1 2 3

8.a First verbatim line. 8.b Second verbatim line. 8.c Third verbatim line.

4 5 6 7 8 9

\renewcommand{\theFancyVerbLine}{% \textcolor{red}{\small 8.\alph{FancyVerbLine}}} \begin{Verbatim}[gobble=2, numbers=left,numbersep=2pt] First verbatim line. Second verbatim line. Third verbatim line. \end{Verbatim}

numberblanklines (boolean) : to number or not the empty lines (really empty or


containing blank characters only) (Default: true all lines are numbered).

1 2 1

First verbatim line. Second verbatim line.

3 4 5

\begin{Verbatim}[gobble=2,numbers=left, numbersep=3pt, numberblanklines=false] First verbatim line. Second verbatim line. \end{Verbatim}

6 7 8

4.1.9 Selection of lines to print

rstline (integer) : rst line to print (Default: empty all lines from the rst are
printed).

12

1 2 2 3

Second verbatim line. Third verbatim line.

3 4 5 6

\begin{Verbatim}[gobble=2,firstline=2, numbers=left,numbersep=2pt] First verbatim line. Second verbatim line. Third verbatim line. \end{Verbatim}

lastline (integer) : last line to print (Default: empty all lines until the last one are
printed).
1 2

First verbatim line.

3 4 5 6

\begin{Verbatim}[gobble=2,lastline=1, numbers=left,numbersep=2pt] First verbatim line. Second verbatim line. Third verbatim line. \end{Verbatim}

Instead of specifying a rstline at which to start printing a range of lines, you can dene a start string; the start of the range is the rst line that exactly equals the string. (The comparison is made before any characters are gobbled off the front of the line.) Similarly for a stop string. You can mix line-numbers and strings, e.g. start at rstline, and end at a stop string. Specifying the strings is a bit klunky. Initially you must dene the strings with \newcommand* as in: Second verbatim line.
1 2 3 4 5 6 7 8 9

\newcommand*\FancyVerbStartString{FROM} \newcommand*\FancyVerbStopString{TO} \begin{Verbatim}[gobble=2] First verbatim line. FROM Second verbatim line. TO Third verbatim line. \end{Verbatim}

To redene the strings, you must use \renewcommand*. 4.1.10 Spaces and tab characters

showspaces (boolean) : print a special character representing each space (Default:


false spaces not shown).
1

Verbatimline.

2 3

\begin{Verbatim}[showspaces=true] Verbatim line. \end{Verbatim}

13

In practice, all verbatim environments have a * variant, which sets showspaces=true:


1

Verbatimline.

2 3

\begin{Verbatim*} Verbatim line. \end{Verbatim*}

There are also some parameters to determine the way tab characters are interpreted (using tabs is in fact a rather old-fashioned style of coding):

showtabs (boolean) : explicitly show tab characters (Default: false tab characters
not shown).

obeytabs (boolean) : position characters according to the tabs (Default: false tab
characters are added to the current position).

tabsize (integer) : number of spaces given by a tab character (Default: 8).


4.1.11 Space between lines

A baselinestretch (auto|dimension) : value to give to the usual baselinestretch L TEX

parameter (Default: auto its current value just before the verbatim command).
1 2 3

First verbatim line.

Second verbatim line. 4

\begin{Verbatim}[baselinestretch=2] First verbatim line. Second verbatim line. \end{Verbatim}

4.1.12

Escape characters for inserting commands

commandchars (three characters) : characters which dene the character which


starts a macro and marks the beginning and end of a group; thus lets us introduce escape sequences in verbatim code. Of course, it is better to choose special characters which are not used in the verbatim text! (Default: empty).

\begin{Verbatim}[commandchars=\\\{\}] \textit{% This is a comment} First verbatim line. % This is a comment 3 \fbox{Second} verbatim line. First verbatim line. 4 5 \textcolor{red}{Third} verbatim line. Second verbatim line. Third verbatim line. 6 \end{Verbatim}
1 2 7

\textbf{Verbatim} line. 8 \begin{Verbatim}[commandchars=+\[\]] 9 +textit[\textbf{Verbatim} line]. 10 \end{Verbatim}

14

Using this way, it is also possible to put labels to be able, later, to make reference to some lines of the verbatim environments:
1

1 2 3

First verbatim line. Second line. Third verbatim line.


As I previously shown line 2, it is...

2 3 4 5 6 7 8 9

\begin{Verbatim}[commandchars=\\\{\}, numbers=left,numbersep=2pt] First verbatim line. Second line.\label{vrb:Important} Third verbatim line. \end{Verbatim} As I previously shown line~\ref{vrb:Important}, it is...

4.1.13

Margins

xleftmargin (dimension) : indentation to add at the start of each line (Default: 0pt
no left margin).

Verbatim line.

2 3 4

\begin{Verbatim}[frame=single, xleftmargin=5mm] Verbatim line. \end{Verbatim}

xrightmargin (dimension) : right margin to add after each line (Default: 0pt no
right margin).

Verbatim line.

2 3 4

\begin{Verbatim}[frame=single, xrightmargin=1cm] Verbatim line. \end{Verbatim}

resetmargins (boolean) : reset the left margin, which is useful if we are inside other
indented environments (Default: false no reset of the margin).

15

First item

2 3 4 5 6

Verbatim line.
Second item

7 8

Verbatim line.

9 10 11

\begin{itemize} \item First item \begin{Verbatim}[frame=single] Verbatim line. \end{Verbatim} \item Second item \begin{Verbatim}[frame=single, resetmargins=true] Verbatim line. \end{Verbatim} \end{itemize}

4.1.14

Overfull box messages

hfuzz (dimension) : value to give to the TEX \hfuzz dimension for text to format.
This can be used to avoid seeing some unimportant Overfull box messages (Default: 2pt). 4.1.15 Page breaks

samepage (boolean) : in very special circumstances, we may want to make sure that
a verbatim environment is not broken, even if it does not t on the current page. To avoid a page break, we can set the samepage parameter to true (Default: false). 4.1.16 Catcode characters

codes (macro) : to specify catcode changes (Default: empty).


For instance, this allows us to include formatted mathematics in verbatim text:
1

x=1/sqrt(z**2) !

1 z2

2 3 4

\begin{Verbatim}[commandchars=\\\{\}, codes={\catcode$=3\catcode^=7}] x=1/sqrt(z**2) ! $\frac{1}{\sqrt{z^2}}$ \end{Verbatim}

4.1.17

Active characters

deneactive (macro) : to dene the effect of active characters (Default: empty).


This allows us to do some devious tricks: see the example in Section 6 on page 20.

16

4.2 Different kinds of verbatim environments


4.2.1 Verbatim environment This is the normal verbatim environment which we have been using up to now. 4.2.2 BVerbatim environment This environment puts the verbatim material in a TEX box. Some parameters do not work inside this environment (notably the framing ones), but two new ones are available:

boxwidth (auto|dimension) : size of the box used (Default: auto the width of the
longest line is used).

baseline (b|c|t) : position of the baseline (on the baseline, the center or the top
of the box) (Default: b).

1 2 3

First First Second Second

4 5 6 7 8 9

\fvset{gobble=2} \begin{BVerbatim} First Second \end{BVerbatim} \begin{BVerbatim}[baseline=c] First Second \end{BVerbatim} \begin{BVerbatim}[boxwidth=2cm] First Second \end{BVerbatim} \begin{BVerbatim}[boxwidth=2cm, baseline=t] First Second \end{BVerbatim}

1 2 3

First Second

First Second

5 6 7 8 9

4.2.3 LVerbatim environment


A This environment puts verbatim material into L TEX LR mode (the so-called left-toright mode, which in fact is the same thing that TEX itself calls restricted horizontal mode).

17

4.2.4 Personalized environments It is easy to dene personal customized environments. You can redene the existing ones using the \RecustomVerbatimEnvironment macro or create your own ones, using the \DefineVerbatimEnvironment macro4 . In each case, you specify the name of the new environment, the type of environment on which it is based, and a set of initial option values. The options can be overridden with an optional argument in the normal way:
1 2

First verbatim line. Second verbatim line.

3 4 5 6 7

\RecustomVerbatimEnvironment {Verbatim}{Verbatim} {gobble=2,frame=single} \begin{Verbatim} First verbatim line. Second verbatim line. \end{Verbatim} \DefineVerbatimEnvironment% {MyVerbatim}{Verbatim} {gobble=2,numbers=left,numbersep=2mm, frame=lines,framerule=0.8mm} \begin{MyVerbatim} First verbatim line. Second verbatim line. \end{MyVerbatim} \begin{MyVerbatim}[numbers=none, framerule=1pt] First verbatim line. Second verbatim line. \end{MyVerbatim}

1 2 3 4 1 2

First verbatim line. Second verbatim line.

5 6 7 8

First verbatim line. Second verbatim line.

9 10 11 12 13 14

5 Saving and restoring verbatim text and environments


The \SaveVerb and \UseVerb macros allow us to save and restore verbatim material.
4 For verbatim commands, the \CustomVerbatimCommand and \RecustomVerbatimCommand macros also exist; for instance:

\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{frame=lines}

18

I have saved _verbatim_ and reuse it later as many times as I want _verbatim_.

1 2 3 4 5

\DefineShortVerb{\|} \SaveVerb{Verb}|_verbatim_| I have saved \UseVerb{Verb} and reuse it later as many times as I want \UseVerb{Verb}.

A This also provides a solution to putting verbatim text inside L TEX commands which do not normally permit it:

1 2 3

\DefineShortVerb{\|} \SaveVerb{Verb}|_OK^| \marginpar{\UseVerb{Verb}}


There is a useful ability to use verbatim text as the item text in a description list A (something not normally permitted in L TEX), using the aftersave parameter:

_OK^

aftersave (macro) : macro to dynamically save some verbatim material (Default:


empty).

1 2

\MyCommand :
mand

my com-

3 4 5 6 7

\newcommand{\Vitem}{% \SaveVerb[aftersave={% \item[\UseVerb{Vitem}]}]{Vitem}} \DefineShortVerb{\|} \begin{description} \Vitem|\MyCommand|: my command \end{description}

In the same way, we can use and restore (in normal, boxed and LR mode, using

\UseVerbatim, \BUseVerbatim and \LUseVerbatim respectively) entire verbatim environments:

Verbatim line.
and

1 2 3 4

Verbatim line.

\begin{SaveVerbatim}{VerbEnv} Verbatim line. \end{SaveVerbatim} \UseVerbatim{VerbEnv} and \UseVerbatim{VerbEnv}

19

st st ond and ond. st ond


and

1 2 3 4 5 6 7 8

\begin{SaveVerbatim}[gobble=5]{VerbEnv} First Second \end{SaveVerbatim} \fbox{\BUseVerbatim{VerbEnv}} and \BUseVerbatim{VerbEnv}. \LUseVerbatim{VerbEnv} and \LUseVerbatim{VerbEnv}

st ond

9 10

6 Writing and reading verbatim les


The command \VerbatimInput (the variants \BVerbatimInput and \LVerbatimInput also exist) allows inclusion of the contents of a le with verbatim formatting. Of course, the various parameters which we have described for customizing can still be used: ! A "hello" program

program hello print *,"Hello world" end program hello


1 2 3 4 5

1 2

\fvset{fontsize=\small} \VerbatimInput{hello.f90} \fvset{frame=single,numbers=left, numbersep=3pt} \VerbatimInput{hello.f90} \VerbatimInput[firstline=3, rulecolor=\color{green}] {hello.f90} \VerbatimInput[frame=lines, fontshape=sl,fontsize=\footnotesize] {hello.f90}

! A "hello" program program hello print *,"Hello world" end program hello program hello print *,"Hello world" end program hello

3 4 5 6 7 8

3 4 5

9 10 11 12 13

1 2 3 4 5

! A "hello" program program hello print *,"Hello world" end program hello

14

We can make use of the deneactive parameter to set the comment lines in the program text in a different style:

20

! A "hello" program

2 3

program hello 4 print *,"Hello world" 5 end program hello 6


7

\def\ExclamationPoint{\char33} \catcode!=\active \VerbatimInput% [defineactive=% \def!{\color{cyan}\itshape \ExclamationPoint}] {hello.f90}

It is important to note that if the contents of the le does not t on the page, it will be automatically broken across pages as needed (unless the samepage parameter has been set to true). There is also a VerbatimOut environment to write verbatim text to an output le, in the same way:
1 2

1 2

I write that. And that too.

3 4 5 6 7

\begin{VerbatimOut}{file.txt} I write that. And that too. \end{VerbatimOut} \VerbatimInput[frame=single, numbers=left,numbersep=6pt]{file.txt}

7 Automatic pretty printing


Obviously, automatic pretty printing is outside the scope of this package. Nevertheless, this is specially interesting for verbatim inclusion of programming code les or A fragments. In the L TEX world (not speaking of the literate programming way), there are software for some special languages, as the C++2LaTeX package from Norbert KIESEL, but mainly two generic ones, which use completely different modes (an external preprocessor written in C and a TEX based solution): the LGrind [3] system, currently maintened by Michael PIEFEL, and the listings [4] package from Carsten HEINZ . Future versions of fancyvrb and listings packages are planned to cooperate, which will offer great advantages to both users of the two actual packages, and will allow fancyvrb users to have automatic pretty printing of programming codes.

8 Known problems
Vladimir VOLOVICH <[email protected]> reported that the special character \th, available with T1 encoding, cant be included as verbatim with fancyvrb. It can be true for other special characters too.

21

9 Thanks
For interesting comments and suggestions, we would like to thank specially (alphabetic order): Philippe ESPERET [email protected], Michael FRIENDLY [email protected], Rolf NIEPRASCHK niepraschk@ gmx.de and for bug reports Mario HASSLER [email protected], Mikhail KOLODIN [email protected], Andreas Matthias, Ulrich M. Schwarz, and Vladimir VOLOVICH <[email protected]>.

10 Conclusion
There are a few other possibilities that we have not described here. Note specially that it is possible to dene a customization le (fancyvrb.cfg) loaded at the end of the package, to store denitions of your customized commands and environments and to redene the attributes of existing ones.

References
A [1] Timothy VAN ZANDT, Documentation for fancybox: Box tips and tricks for L TEX. Available from CTAN: macros/latex/contrib/supported/fancybox, 1993.

[2] Timothy

VAN

A ZANDT, fancyvrb: Fancy Verbatims in L TEX. Available from CTAN:

macros/latex/contrib/supported/fancyvrb, 1998.
[3] Various authors (current maintainer: Michael PIEFEL), The LGrind package. Available from CTAN: support/lgrind, 1998. [4] Carsten HEINZ , The Listings package. Available from

CTAN:

macros/latex/contrib/supported/listings, 1996-1997.

11 Driver le
The next bit of code contains the documentation driver le for TEX, i.e., the le that will produce the documentation you are currently reading. It will be extracted from this le by the docstrip program.
1 driver 2 \documentclass{ltxdoc} 3 \GetFileInfo{fancyvrb.dtx} 4 \usepackage{color} 5 \usepackage{fancyvrb,shortvrb} 6 \usepackage[T1]{fontenc} 7 \usepackage[latin1]{inputenc} 8 \usepackage[charter]{mathdesign}

22

9 \usepackage{url} 10 \newif\ifChangeBar 11 \IfFileExists{changebar.sty}% 12

{\ChangeBartrue\usepackage[dvips,rightbars]{changebar}}{}

13 \EnableCrossrefs 14 \CodelineIndex 15 \RecordChanges 16 \OnlyDescription 17 %\Oldmakeindex 18 \hbadness=7000 19 \hfuzz=3pt 20 \begin{document} 21

% Comment it for implementation details % Uncomment if your MakeIndex is pre-0.9 % Over and under full box warnings

\DocInput{fancyvrb.dtx}

22 \end{document} 23 /driver

12 fancyvrb code
<*fancyvrb>

Disclaimer (D.G./S.R.): This is the original comments of the code by


Timothy
VAN

ZANDT. We have not change them.

12.1 Preambule
What we need. 24 \NeedsTeXFormat{LaTeX2e} Who we are.
25 \def\fileversion{2.7a,

with DG/SPQR fixes, and firstline=lastline fix} <\filedate> (tvz)}

26 \def\filedate{2008/02/07} 27 \ProvidesPackage{fancyvrb}[\filedate]

option: fancyvrb v\fileversion \space fancyvrb@loaded\endcsname 30 \let\fancyvrb@loaded\endinput


29 \csname

28 \message{Style

12.2 Errors
31 \def\FV@Error#1#2{% 32 33 34 35 \def\FV@eha{Your

\edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}% \errmessage{FancyVerb Error:^^J\space\space #1^^J}} command was ignored. Type <return> to continue.}

12.3 Verbatim footnotes


Color has to be protected. Wont work for some denitions of \@makefntext. If it werent for \@makefntext, I would do this properly by dening a footnote environment. 23

\VerbatimFootnotes
36 %% 37 %%

DG/SR modification begin - Jan. 21, 1998 Suggested by Bernard Gaulle to solve a compatibility problem with french 38 %% (it introduce the restriction to put \VerbatimFootnotes AFTER the preambule) 39 %%\def\VerbatimFootnotes{\let\@footnotetext\V@footnotetext} 40 \let\V@footnote\footnote 41 \def\VerbatimFootnotes{% 42 \let\@footnotetext\V@footnotetext% 43 \let\footnote\V@footnote} 44 %% DG/SR modification end

\V@footnotetext
45 \long\def\V@footnotetext{% 46 47

\afterassignment\V@@footnotetext \let\@tempa}

\V@@footnotetext
48 \def\V@@footnotetext{% 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

\insert\footins\bgroup \csname reset@font\endcsname \footnotesize \interlinepenalty\interfootnotelinepenalty \splittopskip\footnotesep \splitmaxdepth\dp\strutbox \floatingpenalty \@MM \hsize\columnwidth \@parboxrestore \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}% \@makefntext{}% \rule{\z@}{\footnotesep}% \bgroup \aftergroup\V@@@footnotetext \ignorespaces}

\V@@@footnotetext
64 \def\V@@@footnotetext{\strut\egroup}

12.4 key=value
65 \RequirePackage{keyval}

Extensions to keyval.sty:

\define@booleankey{<family>}{<key>}{<iftrue>}{<iffalse>} Denes a <key> for <family> that executes: <iftrue> clause when value begins with t or T, or is omitted. <iffalse> clause otherwise.
\define@booleankey
66 \def\define@booleankey#1#2#3#4{% 67

\@namedef{KV@#1@#2@default}{#3}%
24

68 69

\@namedef{KV@#1@#2@false}{#4}% \@namedef{KV@#1@#2}##1{\KV@booleankey{##1}{#1}{#2}}}

\KV@booleankey
70 \def\KV@booleankey#1#2#3{% 71

\edef\@tempa{#1}\expandafter\KV@@booleankey\@tempa\relax\@nil{#2}{#3}}

\KV@@booleankey
72 \def\KV@@booleankey#1#2\@nil#3#4{% 73

\@nameuse{KV@#3@#4@\if t#1default\else\if T#1default\else false\fi\fi}}

\FV@None
74 \def\FV@None{none}

\FV@Auto
75 \def\FV@Auto{auto}

\fvset
76 \def\fvset#1{\setkeys{FV}{#1}}

\FV@Command is for verbatim commands. Example: \def\VerbatimInput{\FV@Command{}{VerbatimInput}} \FV@Command{<key=value>}{<name>}:


1. Denes \FV@KeyValues to be <key=value>. 2. Looks for , and adds showspaces to \FV@KeyValues if found. 3. Looks for [<key=value>] argument, and adds it to \FV@KeyValues if found. 4. Executes \FVC@<name>.

\FV@Command
77 \def\FV@Command#1#2{% 78 79 80

\@ifstar {\def\FV@KeyValues{#1,showspaces}\FV@@Command{#2}}% {\def\FV@KeyValues{#1}\FV@@Command{#2}}}

\FV@@Command
81 \def\FV@@Command#1{% 82 83 84

\@ifnextchar[% {\FV@GetKeyValues{\@nameuse{FVC@#1}}}% {\@nameuse{FVC@#1}}}

\FV@GetKeyValues
85 \def\FV@GetKeyValues#1[#2]{% 86

\expandafter\def\expandafter\FV@KeyValues\expandafter{\FV@KeyValues,#2}#1}

25

\@CustomVerbatimCommand
87 \def\@CustomVerbatimCommand#1#2#3#4{%

\begingroup\fvset{#4}\endgroup % If there are errors, it easier to locate. DG/SR modification begin - Jan. 13, 1998 90 %% \def\@tempa##1##2\@nil{\def\@tempa{##2}}% 91 %% \expandafter\@tempa\string#3\@empty\@nil 92 %% \@ifundefined{FVC@\@tempa}% 93 \@ifundefined{FVC@#3}% 94 %% DG/SR modification end 95 {\FV@Error{Command \string#3 is not a FancyVerb command.}\@eha}% 96 {#1{#2}{\FV@Command{#4}{#3}}}}
88 89 %%

\CustomVerbatimCommand
97 \def\CustomVerbatimCommand{\@CustomVerbatimCommand\newcommand}

\RecustomVerbatimCommand
98 \def\RecustomVerbatimCommand{\@CustomVerbatimCommand\renewcommand}

\FV@Environment is for verbatim environments. Example: \def\Verbatim{\FV@Environment{}{Verbatim}} \@namedef{Verbatim*}{\FV@Environment{showspaces}{Verbatim}} \FV@Environment{<key=value>}{<name>}:


1. Denes \FV@KeyValues to be <key=value>. 2. Sets \catcode\^^M=13, checks for [, and resets \catcode^^M=5. 3. Reads [<key=value>] and adds it to \FV@KeyValues if [ was found. 4. Executes \FVB@<name>.

\FV@Environment is like \FV@Command, except:


It omits step 2 (looking for ), and It sets \catcode\^^M=13 when checking for the [ of the optional argument, so that it does not skip over ^^M if there is no [.

\FV@Environment
99 \def\FV@Environment#1#2{% 100 101 102 103 104

\def\FV@KeyValues{#1}% \catcode\^^M=\active \@ifnextchar[% {\catcode\^^M=5 \FV@GetKeyValues{\@nameuse{FVB@#2}}}% {\catcode\^^M=5 \@nameuse{FVB@#2}}}

\CustomVerbatimEnvironment
105 \def\CustomVerbatimEnvironment{\@CustomVerbatimEnvironment\newenvironment}

26

\RecustomVerbatimEnvironment
106 \def\RecustomVerbatimEnvironment{\@CustomVerbatimEnvironment\renewenvironment}

\@CustomVerbatimEnvironment
107 \def\@CustomVerbatimEnvironment#1#2#3#4{% 108 109 110 111 112

\begingroup\fvset{#4}\endgroup % If there are errors, it easier to locate. \@ifundefined{FVB@#3}% {\FV@Error{#3 is not a FancyVerb environment.}\@eha}% {#1{#2}{\FV@Environment{#4}{#3}}{\@nameuse{FVE@#3}}% #1{#2*}{\FV@Environment{#4,showspaces}{#3}}{\@nameuse{FVE@#3}}}}

\DefineVerbatimEnvironment
113 \def\DefineVerbatimEnvironment#1#2#3{% 114 115 116 117

\@namedef{#1}{\FV@Environment{#3}{#2}}% \@namedef{end#1}{\@nameuse{FVE@#2}}% \@namedef{#1*}{\FV@Environment{#3,showspaces}{#2}}% \@namedef{end#1*}{\@nameuse{FVE@#2}}}

Then commands or environments set key values with \FV@UseKeyValues, within a group.

\FV@UseKeyValues
118 \def\FV@UseKeyValues{% 119 120 121 122 123

\ifx\FV@KeyValues\@empty\else \def\KV@prefix{KV@FV@}% \expandafter\KV@do\FV@KeyValues,\relax,% \def\FV@KeyValues{}% \fi}

12.5 Scanning
Scanning macros: read a line at a time from an environment or a le, save the line in \FV@Line, and execute \FV@PreProcessLine.

\FV@PreProcessLine:
Determines whether line is in a user-specied ranges, and if so, Strips the line of a user-specied no. of tokens, and Executes \FV@ProcessLine{<line>}. Two things are common to scanning an environment or reading a le: \FV@CatCodes = Change \catcodes. \FV@PreProcessLine = See above. 27

12.6 Codes
\FV@CatCodes
124 \def\FV@CatCodes{% 125 126 127 128 129

\let\do\@makeother\dospecials \FV@ActiveWhiteSpace \FV@FontScanPrep \FV@CatCodesHook \FancyVerbCodes}

% % % % %

The usual stuff. See below. See below. A style hook. A user-defined hook.

\FV@ActiveWhiteSpace
130 \def\FV@ActiveWhiteSpace{% 131 132 133

\catcode\^^M=\active \catcode\ =\active \catcode\^^I=\active}


CM Ligatures:

% End of line % Space % Tab

Left-quote: Letter f: ff f f Hyphen: -- ---

\FV@CatCodesHook
134 \def\FV@CatCodesHook{}

\FV@AddToHook
135 \def\FV@AddToHook#1#2{% 136

\expandafter\def\expandafter#1\expandafter{#1#2\relax}}

\FancyVerbCodes
137 \define@key{FV}{codes}[]{\def\FancyVerbCodes{#1\relax}} 138 \define@key{FV}{codes*}{% 139

\expandafter\def\expandafter\FancyVerbCodes\expandafter{% \FancyVerbCodes#1\relax}} 141 \fvset{codes}


140 142 \define@key{FV}{commandchars}[\\\{\}]% 143 144 145 146 147 148

{\def\@tempa{#1}% \ifx\@tempa\FV@None \let\FV@CommandChars\relax \else \FV@DefineCommandChars#1\relax\relax\relax \fi}

\FV@DefineCommandChars
149 \def\FV@DefineCommandChars#1#2#3{% 150 151

\def\FV@CommandChars{% \catcode#1=0\relax\catcode#2=1\relax\catcode#3=2\relax}}

152 \FV@AddToHook\FV@CatCodesHook\FV@CommandChars

28

\FV@CommentChar
153 \define@key{FV}{commentchar}[\%]{% 154 155 156 157 158 159

\def\@tempa{#1}% \ifx\@tempa\FV@None \let\FV@CommentChar\relax \else \def\FV@CommentChar{\catcode#1=14}% \fi}

160 \FV@AddToHook\FV@CatCodesHook\FV@CommentChar 161 \fvset{commandchars=none,commentchar=none}

12.7 Preprocess line


These is tedious and takes up macro space, but it doesnt slow things down much when the parameters are not used. start, stop and gobble parameters: if value is a number, then after the assignment the next token is \relax. "Preprocessing the line" involves: Checking whether this line falls in the range specied by start or stop strings. or firstline or lastline line-numbers, or a mixture. Gobbleing initial characters.
162 \define@key{FV}{firstline}{% 163

\afterassignment\FV@ParseStart\@tempcnta=0#1\relax\@nil{#1}}

\FV@ParseStart
164 \def\FV@ParseStart#1\relax\@nil#2{% 165 166 167 168 169 170

\ifx\@nil#1\@nil \edef\FancyVerbStartNum{\the\@tempcnta}% \let\FancyVerbStartString\relax \else \edef\FancyVerbStartString{#2}% \fi}

\KV@FV@firstline@default
171 \def\KV@FV@firstline@default{% 172 173

\let\FancyVerbStartNum\z@ \let\FancyVerbStartString\relax} \afterassignment\FV@ParseStop\@tempcnta=0#1\relax\@nil{#1}}

174 \define@key{FV}{lastline}{% 175

\FV@ParseStop
176 \def\FV@ParseStop#1\relax\@nil#2{% 177 178

\ifx\@nil#1\@nil \edef\FancyVerbStopNum{\the\@tempcnta}%
29

179 180 181 182

\let\FancyVerbStopString\relax \else \edef\FancyVerbStopString{#2}% \fi}

\KV@FV@lastline@default
183 \def\KV@FV@lastline@default{% 184 185

\let\FancyVerbStopNum\z@ \let\FancyVerbStopString\relax}

186 \fvset{firstline,lastline} 187 \newcount\FV@CodeLineNo

If \FV@FindStartStop determines the line should be printed, it executes \FV@@PreProcessLine

\FV@PreProcessLine
188 \def\FV@PreProcessLine{% 189 190

\global\advance\FV@CodeLineNo\@ne \FV@FindStartStop}

\FV@@PreProcessLine
191 \def\FV@@PreProcessLine{% 192 193 194

\FV@StepLineNo \FV@Gobble \expandafter\FV@ProcessLine\expandafter{\FV@Line}}

The denition of \FV@FindStartStop changes, so that we dont have to check irrelevant conditions with each line. Heres how it works; for simplicity we assume firstline and lastline have been specied, rather than start or stop strings. The rst time \FV@FindStartStop is called: 1. It calls \FV@DefineFindStart. (The name roughly means "dene \FV@FindStartStop to detect when weve reached the start of the specied range".) This checks the range parameters that have been specied, and then redenes \FV@FindStartStop (yes, the function that has called this code) to contain only the necessary checks, for efciency reasons: If we havent printed any lines yet, which is true when \FV@FindStartStop is rst called, we only need to check the current line-number against firstline, so we redene \FV@FindStartStop to be \FV@FindStartNum. If firstline isnt set, we only have to check the current line-number against lastline, so we redene \FV@FindStartStop to be \FV@DefineFindStop. (The name roughly means "dene \FV@FindStartStop to detect when weve reached the stop (end) of the specied range", but unlike the START case, it includes code (\FV@@PreProcessLine) to print the current line.) 30

2. It then calls the newly-dened \FV@FindStartStop to see if the current line being processed is within the range to be printed.

\FV@FindStartStop is redened once as described above, but it can be redened again: 1. When we have reached firstline, i.e. have entered the range to be printed, we redene \FV@FindStartStop to be \FV@DefineFindStop. (We know weve reached the start, so theres no point checking that again on future calls.) 2. When we reach lastline and have printed it, we wont want to print any more lines, so we redene \FV@FindStartStop to \relax so we do nothing (and do it efciently). Note that when firstline = lastline (= 6, say), it is \FV@FindStartNum (which \FV@FindStartStop has initially been redened to) that notices when we reach line 6, and prints it, and redenes \FV@FindStartStop to be \FV@DefineFindStop. Then we read line 7, so \FV@DefineFindStop has to check whether weve passed lastline, and therefore shouldnt print the current line, before redening \FV@FindStartStop to \relax as explained above. By contrast, when firstline is less than lastline (= 6, 8, say), when we reach line 8, \FV@DefineFindStop sees that were at the end of the range, and does print the line, before redening \FV@FindStartStop to \relax as above. This slight weirdness is because several of the macros are dening themselves and one another, resulting in a slightly weird execution ow.

\FV@FindStartStop
195 \def\FV@FindStartStop{\FV@DefineFindStart\FV@FindStartStop} 196 %% 197 %%

\def\FV@DefinePreProcessLine{% \setcounter{FancyVerbLine}{0}% 198 %% \FV@DefineFindStart} \FV@DefineFindStart


199 \def\FV@DefineFindStart{% 200 201 202 203 204 205 206 207 208

\ifx\FancyVerbStartString\relax \ifnum\FancyVerbStartNum<\tw@ \FV@DefineFindStop \else \let\FV@FindStartStop\FV@FindStartNum \fi \else \let\FV@FindStartStop\FV@FindStartString \fi}

31

\FV@FindStartNum
209 \def\FV@FindStartNum{% 210 211 212 213

\ifnum\FancyVerbStartNum>\FV@CodeLineNo\else \FV@DefineFindStop \expandafter\FV@@PreProcessLine \fi}

\FV@FindStartString
214 %% 216

SR modification begin - 1996

215 \def\FV@FindStartString{%

\expandafter\FV@@FindStartString

217 {\meaning\FV@Line}% 218 {\meaning\FancyVerbStartString}% 219 }

\FV@@FindStartString
220 \def\FV@@FindStartString#1#2{% 221 \edef\@fooA{#1}\edef\@fooB{#2}% 222 223 224 225 } 226 %%

\ifx\@fooA\@fooB \FV@DefineFindStop \fi SR modification end

\FV@DefineFindStop
227 \def\FV@DefineFindStop{% 228 229 230 231 232 233 234 235 236

\ifx\FancyVerbStopString\relax \ifnum\FancyVerbStopNum<\@ne \let\FV@FindStartStop\FV@@PreProcessLine \else \let\FV@FindStartStop\FV@FindStopNum \fi \else \let\FV@FindStartStop\FV@FindStopString \fi}

\FV@FindStopNum
237 \def\FV@FindStopNum{% 238 239 240 241 242 243 244 245 246 247 248

\ifnum\FancyVerbStopNum>\FV@CodeLineNo \else \let\FV@FindStartStop\relax \ifeof\FV@InFile\else \immediate\closein\FV@InFile \fi \fi \ifnum\FancyVerbStopNum<\FV@CodeLineNo \else \FV@@PreProcessLine \fi}
32

\FV@FindStopString
249 %% 251

SR modification begin - 1996

250 \def\FV@FindStopString{%

\expandafter\FV@@FindStopString

252 {\meaning\FV@Line}% 253 {\meaning\FancyVerbStopString}% 254 }

\FV@@FindStopString
255 \def\FV@@FindStopString#1#2{% 256 \edef\@fooA{#1}\edef\@fooB{#2}%

\ifx\@fooA\@fooB \let\FV@FindStartStop\relax 259 \ifeof\FV@InFile\else 260 \immediate\closein\FV@InFile 261 \fi 262 \else 263 \expandafter\FV@@PreProcessLine 264 \fi} 265 %% SR modification end
257 258

Gobblings. \FV@Gobble does nothing, or strips some tokens from the line and A stores the result in \FV@Line again. We use L TEXs \renewcommand to dene a command for gobbling up to 9 arguments. This is not the same as removing 9 tokens, but is easier.

\FV@@Gobble
266 \def\FV@@Gobble{% 267 268 269

\expandafter\expandafter\expandafter\FV@@@Gobble \expandafter\FV@@@@Gobble\FV@Line \@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@@nil}

\FV@@@Gobble
270 \def\FV@@@Gobble#1\@nil#2\@@nil{\def\FV@Line{#1}}

\FV@Gobble
271 \define@key{FV}{gobble}{% 272 273 274 275 276 277 278 279 280 281 282

\@tempcnta=#1\relax \ifnum\@tempcnta<\@ne \let\FV@Gobble\relax \else \ifnum\@tempcnta>9 \FV@Error{gobble parameter must be less than 10}\FV@eha \else \renewcommand{\FV@@@@Gobble}[\@tempcnta]{}% \let\FV@Gobble\FV@@Gobble \fi \fi}

33

\FV@@@@Gobble
283 \def\FV@@@@Gobble{}

\KV@FV@gobble@default
284 \def\KV@FV@gobble@default{\let\FV@Gobble\relax} 285 \fvset{gobble}

12.8 Scanning environments


\FV@Scan
286 \def\FV@Scan{% 287 288 289 290

\FV@CatCodes \VerbatimEnvironment \FV@DefineCheckEnd \FV@BeginScanning}

\VerbatimEnvironment:
This saves the name of the current environment as \FV@EnvironName, if the latter is not already dened. Then \FV@CheckEnd knows how to nd the end as long as either: \begin and \end are not used within the denition of the environment, OR \VerbatimEnvironment is used in the denition before the rst \begin.

\VerbatimEnvironment
291 \def\VerbatimEnvironment{% 292

\ifx\FV@EnvironName\relax\xdef\FV@EnvironName{\@currenvir}\fi}

293 \let\FV@EnvironName\relax

12.9 Check end


We have to check the argument of the rst \end{} in each line, compare it with \FV@EnvironName, and return \iftrue if it matches and \iffalse otherwise. There are four cases (R=regular): case : i ii iii iv catcode of \ : R 12 12 R catcode of {} : R R 12 12 For uniformity, we use ![] instead of \{} in all the denitions. We rst set the catcodes of \{} to those in effect in the verbatim environment. Then we dene:

!def!FV@CheckEnd#1[!FV@@CheckEnd#1\end{}!@nil]
If have their usual catcodes, we dene:

!def!FV@@CheckEnd#1\end#2#3!@nil[!def!@tempa[#2]]
34

If have catcode 12, we dene:

!def!FV@@CheckEnd#1\end{#2}#3!@nil[!def!@tempa[#2]]
294 \begingroup 295 \catcode\!=0 296 \catcode\[=1 297 \catcode\]=2

Case i:
298 !gdef!FV@CheckEnd@i#1[!FV@@CheckEnd#1\end{}!@nil] 299 !gdef!FV@@CheckEnd@i#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]] 300 !gdef!FV@@@CheckEnd@i[\end{}]

Case ii:
301 \catcode!\=12 302 303 !gdef!FV@CheckEnd@ii#1[!FV@@CheckEnd#1\end{}!@nil] 304 !gdef!FV@@CheckEnd@ii#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]] 305 !gdef!FV@@@CheckEnd@ii[\end{}]

Case iii:
306 !catcode!{=12 307 !catcode!}=12 308 309 !gdef!FV@CheckEnd@iii#1[!FV@@CheckEnd#1\end{}!@nil] 310 !gdef!FV@@CheckEnd@iii#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]] 311 !gdef!FV@@@CheckEnd@iii[\end{}]

Case iv:
312 !catcode!\=0 313 314 !gdef!FV@CheckEnd@iv#1[!FV@@CheckEnd#1\end{}!@nil] 315 !gdef!FV@@CheckEnd@iv#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]] 316 !gdef!FV@@@CheckEnd@iv[\end{}] 317 \endgroup

\FV@BadCodes
318 \def\FV@BadCodes#1{% 319 320 321 322 323 324 325 326

\FV@Error {\string\catcode\space of \expandafter\@gobble\string#1 is wrong: \the\catcode#1}% {Only the following catcode values are allowed: ^^J\@spaces \expandafter\@gobble\string\\ \space\space --> 0 or 12. ^^J\@spaces \string{ \string} --> 1 and 2, resp., or both 12. ^^JTo get this error, either you are a hacker or you got bad advice.}% \def\FV@CheckEnd##1{\iftrue}}

\FV@DefineCheckEnd
327 \def\FV@DefineCheckEnd{% 328

\ifnum\catcode\\=\z@
35

329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360

\ifnum\catcode\{=\@ne \let\FV@CheckEnd\FV@CheckEnd@i \let\FV@@CheckEnd\FV@@CheckEnd@i \let\FV@@@CheckEnd\FV@@@CheckEnd@i \else \ifnum\catcode\{=12 \let\FV@CheckEnd\FV@CheckEnd@iv \let\FV@@CheckEnd\FV@@CheckEnd@iv \let\FV@@@CheckEnd\FV@@@CheckEnd@iv \else \FV@BadCodes\{% \fi \fi \else \ifnum\catcode\\=12 \ifnum\catcode\{=\@ne \let\FV@CheckEnd\FV@CheckEnd@ii \let\FV@@CheckEnd\FV@@CheckEnd@ii \let\FV@@@CheckEnd\FV@@@CheckEnd@ii \else \ifnum\catcode\{=12 \let\FV@CheckEnd\FV@CheckEnd@iii \let\FV@@CheckEnd\FV@@CheckEnd@iii \let\FV@@@CheckEnd\FV@@@CheckEnd@iii \else \FV@BadCodes\{% \fi \fi \else \FV@BadCodes\\% \fi \fi}

12.10 Line-by-line scanning


We rst skip everything after the beginning of the environment.

\FV@BeginScanning
361 \begingroup 362 \catcode\^^M=\active

\gdef\FV@BeginScanning#1^^M{% \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi% 365 \FV@GetLine}% 366 \endgroup


363 364

\FV@BadBeginError
367 \def\FV@BadBeginError#1{% 368 369

\expandafter\@temptokena\expandafter{\@tempa}% \FV@Error

36

370 371 372

{Extraneous input \the\@temptokena between \string\begin{\FV@EnvironName}[<key=value>] and line end}% {This input will be discarded. Hit <return> to continue.}}

If \FancyVerbGetLine does not nd a ^^M, then we are at the end of the le, and \FV@EOF attempts to terminate the document. Otherwise, \FV@EOF is gobbled by \FancyVerbGetLine.

\FV@GetLine
373 %% 374 %%

DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures) \def\FV@GetLine{\expandafter\FV@CheckScan\FancyVerbGetLine} 375 \def\FV@GetLine{\@noligs\expandafter\FV@CheckScan\FancyVerbGetLine} 376 %% DG/SR modification end

\FancyVerbGetLine
377 \begingroup 378 \catcode\^^M=\active 379 \gdef\FancyVerbGetLine#1^^M{%

\@nil% \FV@CheckEnd{#1}% 382 \ifx\@tempa\FV@EnvironName% % True if end is found 383 \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi% 384 \let\next\FV@EndScanning% 385 \else% 386 \def\FV@Line{#1}% 387 \def\next{\FV@PreProcessLine\FV@GetLine}% 388 \fi% 389 \next}% 390 \endgroup
380 381

\FV@BadEndError
391 \def\FV@BadEndError{% 392 393 394 395 396

\expandafter\@temptokena\expandafter{\@tempb}% \FV@Error {Extraneous input \the\@temptokena between \string\end{\FV@EnvironName} and line end}% {This input will be discarded. Type <return> to continue.}}

\FV@EndScanning
397 \def\FV@EndScanning{% 398 399 400

\edef\next{\noexpand\end{\FV@EnvironName}}% \global\let\FV@EnvironName\relax \next}

401 \@ifundefined{@currenvline}{\let\@currenvline\@empty}{}

\FV@CheckScan
402 \def\FV@CheckScan#1{\@ifnextchar\@nil{\@gobble}{\FV@EOF}} 403 \def\FV@CheckScan#1{\ifx\@nil#1\@empty\else\expandafter\FV@EOF\fi}

37

\FV@EOF
404 \def\FV@EOF{% 405 406 407 408 409 410 411

\FV@Error{Couldnt find \string\end{\FV@EnvironName} to end a verbatim environment\@currenvline.}% {Probably you mistyped the environment name or included an extraneous ^^Jspace, or are using an improperly defined verbatim environment. ^^JHit return and I will try to terminate this job.}% \FV@EndScanning \end{document}}

12.11 Input
412 \newread\FV@InFile

\FV@Input
413 \def\FV@Input#1{% 414 415 416 417 418 419 420 421

\immediate\openin\FV@InFile #1\relax \ifeof\FV@InFile \FV@Error{No verbatim file #1}\FV@eha \immediate\closein\FV@InFile \else \FV@CatCodes \expandafter\FV@@Input \fi}

TEX reports EOF when reading after the last newline character. Thus, we read to InLine, and if TEX reports EOF: If InLine=Empty, previous line was last line in le (le ends nl). Otherwise, InLine holds last line in le (le doesnt end in nl).

\FV@@Input handles both cases correctly.


\FV@@Input
422 \def\FV@@Input{% 423 424 425 426 427 428 429 430 431 432 433

\def\FV@Line{}% \FV@ReadLine \ifeof\FV@InFile \ifx\FV@Line\@empty\else \FV@PreProcessLine \fi \immediate\closein\FV@InFile \else \FV@PreProcessLine \expandafter\FV@@Input \fi}

We also want to handle true comment characters correctly. This means that we keep accumulating text in InLine until we nd a ^^M (indicating that the line did not contain a comment character). 38

\FV@ReadLine
434 \begingroup 435 \catcode\^^M=\active 436 \gdef\FV@ReadLine{% 437 438 439 440

\ifeof\FV@InFile\else \immediate\read\FV@InFile to\@tempa% \expandafter\FV@@ReadLine\@tempa^^M\relax^^M\@nil% \fi}

#2 is empty if line ends in ^^M, #2=\relax otherwise


\FV@@ReadLine
441 \gdef\FV@@ReadLine#1^^M#2^^M#3\@nil{%

\expandafter\def\expandafter\FV@Line\expandafter{% \FV@Line#1}% 444 \ifx\relax#2\@empty\expandafter\FV@ReadLine\fi}% 445 \endgroup


442 443

12.12 Formatting Common components


Some things that are common to all verbatim formatting:

\FV@FormattingPrep
446 \def\FV@FormattingPrep{% 447 448 449 450 451 452

\global\FV@CodeLineNo\z@ \frenchspacing \FV@SetupFont \FV@DefineWhiteSpace \FancyVerbDefineActive \FancyVerbFormatCom}


Fonts

% Cancels special punctuation spacing. % See below. % See below. % A user-defined hook (formatcom parameter).

453 \expandafter\ifx\csname

selectfont\endcsname\relax

\FV@SetupFont
454 \def\FV@SetupFont{% 455 456 457 458 459 460 \else 461 462 \def\FV@SetupFont{% 463 464 465 466

\FV@BaseLineStretch \ifx\@currsize\small\normalsize\else\small\fi\@currsize \FV@FontSize \FV@FontFamily}

\FV@BaseLineStretch \FV@FontSize \FV@FontFamily \FV@FontSeries

39

\FV@FontShape \selectfont 469 %% DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures) 470 \@noligs} 471 %% DG/SR modification end
467 468 472 \fi

\FV@FontSize
473 \define@key{FV}{fontsize}{% 474 475 476 477 478 479

\def\@tempa{#1}% \ifx\@tempa\FV@Auto \let\FV@FontSize\relax \else \def\FV@FontSize{#1}% \fi}

\KV@FV@fontsize@default
480 \def\KV@FV@fontsize@default{\let\FV@FontSize\relax}

\FV@BaseLineStretch
481 \define@key{FV}{baselinestretch}[auto]{% 482 483 484 485 486 487

\def\@tempa{#1}% \ifx\@tempa\FV@Auto \let\FV@BaseLineStretch\relax \else \def\FV@BaseLineStretch{\def\baselinestretch{#1}}% \fi}

KV@FV@baselinestretch@default
488 \def\KV@FV@baselinestretch@default{\let\FV@BaseLineStretch\relax} 489 \define@key{FV}{fontfamily}{% 490 491 492

\@ifundefined{FV@fontfamily@#1}% {\def\FV@FontScanPrep{}\def\FV@FontFamily{\fontfamily{#1}}} {\csname FV@fontfamily@#1\endcsname}}

\FV@FontSeries
493 \define@key{FV}{fontseries}{% 494 495 496 497 498 499

\def\@tempa{#1}% \ifx\@tempa\FV@Auto \let\FV@FontSeries\relax \else \def\FV@FontSeries{\fontseries{#1}}% \fi}

\FV@FontShape
500 \define@key{FV}{fontshape}{% 501

\def\@tempa{#1}%

40

502 503 504 505 506

\ifx\@tempa\FV@Auto \let\FV@FontShape\relax \else \def\FV@FontShape{\fontshape{#1}}% \fi}


Font family styles have to dene \FV@FontScanPrep and \FV@FontFamily.

\FV@MakeActive
507 \def\FV@MakeActive#1{% 508 509 510 511

\catcode#1=\active \def\next##1{\expandafter\def\expandafter\FV@MakeUnActive\expandafter{% \FV@MakeUnActive\def##1{\string##1}}}% \begingroup\lccode~=#1\relax\expandafter\next\expandafter~\endgroup}

\FV@MakeUnActive
512 \def\FV@MakeUnActive{} 513 \begingroup 514 \catcode\=\active

\FV@fontfamily@tt
515 \gdef\FV@fontfamily@tt{%

\def\FV@FontScanPrep{\FV@MakeActive\}% SR modification begin - 1995 518 %% \def\FV@FontFamily{\tt{{\string}}}} 519 \def\FV@FontFamily{\ttfamily\edef{{\string}}}} 520 %% SR modification end
516 517 %%

\FV@fontfamily@cmtt
521 \gdef\FV@fontfamily@cmtt{% 522 523

\def\FV@FontScanPrep{\FV@MakeActive\}% \def\FV@FontFamily{\edef{{\string}}\fontfamily{cmtt}}}

524 \endgroup

\FV@fontfamily@cmtt-spanish
525 \@namedef{FV@fontfamily@cmtt-spanish}{% 526 527

\def\FV@FontScanPrep{}% \def\FV@FontFamily{\fontfamily{cmtt}}}
Fix me

\FV@fontfamily@courier
528 \@namedef{FV@fontfamily@courier}{%

\def\FV@FontScanPrep{}% SR modification begin - 1995 531 %% \def\FV@FontFamily{\fontfamily{rpcr}}} 532 \def\FV@FontFamily{\fontfamily{pcr}}} 533 %% SR modification end
529 530 %%

41

\FV@fontfamily@helvetica
534 \@namedef{FV@fontfamily@helvetica}{%

\def\FV@FontScanPrep{}% SR modification begin - 1995 537 %% \def\FV@FontFamily{\fontfamily{rphv}}} 538 \def\FV@FontFamily{\fontfamily{phv}}} 539 %% SR modification end
535 536 %% 540 \fvset{fontfamily=tt,fontsize=auto,fontshape=auto,fontseries=auto, 541

baselinestretch=auto}

\FV@DefineWhiteSpace
We just dene the active characters to be ordinary commands, which are easier to redene. We do with any macros that use verbatim text.
542 \begingroup 543 \catcode\

=\active

544 \catcode\^^I=\active

\FV@DefineWhiteSpace
545 \gdef\FV@DefineWhiteSpace{\def 546 \endgroup

{\FV@Space}\def^^I{\FV@Tab}}%

\FancyVerbDefineActive
547 \define@key{FV}{defineactive}[]{\def\FancyVerbDefineActive{#1\relax}} 548 \define@key{FV}{defineactive*}{% 549

\expandafter\def\expandafter\FancyVerbDefineActive\expandafter{% \FancyVerbDefineActive#1\relax}} 551 \fvset{defineactive}


550

\FV@Space:
\FV@Space
552 \define@booleankey{FV}{showspaces}% 553 554

{\def\FV@Space{{\FancyVerbSpace}}}% {\def\FV@Space{\ }} =12 \gdef\FancyVerbSpace{\tt }}

555 {\catcode\

556 \fvset{showspaces=false}

\FV@Tab:
\FV@Tab
557 \def\FV@Tab{\hbox

to\FancyVerbTabSize\fontdimen2\font{\hss\FV@TabChar}}

\FancyVerbTabSize
558 \define@key{FV}{tabsize}{% 559 560 561

\@tempcnta=#1\relax \ifnum\@tempcnta>100 \FV@Error{Tab size too large: \the\@tempcnta. (Max size = 100)}\FV@eha
42

562 563 564

\else \edef\FancyVerbTabSize{\the\@tempcnta}% \fi}

\FV@TabChar
565 \define@booleankey{FV}{showtabs}% 566 567

{\def\FV@TabChar{\FancyVerbTab}}% {\let\FV@TabChar\relax}

568 \fvset{tabsize=8,showtabs=false}

Here is a weak attempt at a tab character. It may exceed the width of a space character when the verbatim font is small. The only proper way to do this is making it part of the verbatim font.

\FancyVerbTab
569 \def\FancyVerbTab{% 570 571 572 573 574

\valign{% \vfil##\vfil\cr \hbox{$\scriptscriptstyle-$}\cr \hbox to 0pt{\hss$\scriptscriptstyle\rangle\mskip -.8mu$}\cr \hbox{$\scriptstyle\mskip -3mu\mid\mskip -1.4mu$}\cr}}


Obey Tabs:

575 \newbox\FV@TabBox

\FV@@ObeyTabsInit
576 \def\FV@@ObeyTabsInit{% 577 578 579 580 581 582 583

\@tempdimb=\FancyVerbTabSize\fontdimen\tw@\font \edef\FV@ObeyTabSize{\number\@tempdimb}% \advance\@tempdimb\fontdimen\tw@\font \advance\@tempdimb-\FancyVerbTabSize sp % Allow for rounding errors. \edef\FV@@ObeyTabSize{\number\@tempdimb}% \let\FV@ObeyTabs\FV@@ObeyTabs \let\FV@Tab\FV@TrueTab}

\FV@@ObeyTabs
584 \def\FV@@ObeyTabs#1{\setbox\FV@TabBox=\hbox{#1}\box\FV@TabBox} 585 \let\FV@ObeyTabs\relax

\FV@TrueTab
586 \def\FV@TrueTab{% 587 588 589 590 591 592

\egroup \@tempdima=\FV@ObeyTabSize sp\relax \@tempcnta=\wd\FV@TabBox \advance\@tempcnta\FV@@ObeyTabSize\relax \divide\@tempcnta\@tempdima \multiply\@tempdima\@tempcnta

43

593 594 595

\advance\@tempdima-\wd\FV@TabBox \setbox\FV@TabBox=\hbox\bgroup \unhbox\FV@TabBox\kern\@tempdima\hbox to\z@{\hss\FV@TabChar}}

\FV@ObeyTabsInit
596 \define@booleankey{FV}{obeytabs}% 597 598

{\let\FV@ObeyTabsInit\FV@@ObeyTabsInit}% {\let\FV@ObeyTabsInit\relax}

599 \fvset{obeytabs=false}

\FancyVerbFormatCom
\FancyVerbFormatCom
600 \define@key{FV}{formatcom}[]{\def\FancyVerbFormatCom{#1\relax}} 601 \define@key{FV}{formatcom*}{% 602 603

\expandafter\def\expandafter\FancyVerbFormatCom\expandafter{% \FancyVerbFormatCom#1\relax}}

604 \fvset{formatcom}

\FancyVerbFormatLine
605 \def\FancyVerbFormatLine#1{\FV@ObeyTabs{#1}}

12.13 List environments


Some parameters:

\FV@XLeftMargin
606 \define@key{FV}{xleftmargin}{\def\FV@XLeftMargin{#1}} 607 \let\FV@XLeftMargin\z@

\FV@XRightMargin
608 \define@key{FV}{xrightmargin}{\def\FV@XRightMargin{#1}} 609 \let\FV@XRightMargin\z@

\if@FV@ResetMargins
610 \define@booleankey{FV}{resetmargins}%

{\let\if@FV@ResetMargins\iftrue} {\let\if@FV@ResetMargins\iffalse} 613 \fvset{resetmargins=false}


611 612

\FV@ListParameterHook
614 \define@key{FV}{listparameters}{\def\FV@ListParameterHook{#1}} 615 \def\FV@ListParameterHook{}

\FancyVerbHFuzz
616 \define@key{FV}{hfuzz}{%

\@tempdima=#1\relax \edef\FancyVerbHFuzz{\number\@tempdima sp}} 619 \fvset{hfuzz=2pt}


617 618

44

\FV@InterLinePenalty
620 \define@booleankey{FV}{samepage}%

{\def\FV@InterLinePenalty{\interlinepenalty\@M}}% {\let\FV@InterLinePenalty\relax} 623 \fvset{samepage=false}


621 622

Lists:

\FV@List{} is a rewriting of \list{}{}\item[]. The rewrite gives me more control. I might not get the vertical spacing exactly the same, but it is more likely that it will get better than worse. The verbatim environment consists of a series of \hboxs inserted in vertical mode. We need to take care of the following:
leftmargin rightmargin topskip botskip toppenalty botpenalty interlinepenalties Note: A verbatim environment immediately after an \item starts on the same line as the \items label, unless we reset margins. The user can instead have the environment start on a new line by inserting \ between \item and the environment.

\FV@List
624 \def\FV@List#1{% 625 626 627 628 629 630 631 632 633 634 635 636 637 638

\begingroup \FV@UseKeyValues \FV@LeaveVMode \if@inlabel\else\setbox\@labels=\box\voidb@x\fi \FV@ListNesting{#1}% \FV@ListParameterHook \FV@ListVSpace \FV@SetLineWidth \FV@InterLinePenalty \let\FV@ProcessLine\FV@ListProcessLine@i \FV@CatCodes \FV@FormattingPrep \FV@ObeyTabsInit \FV@BeginListFrame}

Cases where we need to leave vmode: 45

After an in-line section (\if@noskipsec=T). After an \item command, if we reset margins. Then we end \vmode, using @noparlist as a ag if in vmode. (Not the usual meaning of @noparlist.)

\FV@LeaveVMode
639 \def\FV@LeaveVMode{% 640 641 642 643 644 645

\if@noskipsec \leavevmode \else \if@FV@ResetMargins\if@inlabel\leavevmode\fi\fi \fi \ifvmode\@noparlisttrue\else\@noparlistfalse\unskip\par\fi}

\FV@ListNesting
646 \def\FV@ListNesting#1{% 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661

\if@FV@ResetMargins \@listdepth=\z@ \else \ifnum\@listdepth>5\relax \@toodeep \else \advance\@listdepth\@ne \fi \fi \rightmargin\z@ \csname @list\romannumeral\the\@listdepth\endcsname \ifnum#1=\z@ \rightmargin\z@ \leftmargin\z@ \fi}

\FV@ListVSpace contains selected parts of \@trivlist and \@item.


Here are the cases: Vmode not in label or after @NOBREAK:

<topskip> = \topsep + \partopsep + \parskip <botskip> = \topsep + \partopsep <toppenalty> = \@beginparpenalty <botpenalty> = \@endparpenalty
Vmode in label:

<topskip> = \parskip % Expected anyway. A <botskip> = \topsep + \partopsep % Omitted in L TEX a bug? <toppenalty> = None <botpenalty> = \@endparpenalty % Ditto.

46

Vmode after @nobreak:

<topskip> = \parskip <botskip> = \topsep + \partopsep <toppenalty> = None <botpenatly> = \@endparpenalty


Hmode:

<topskip> = \topsep + \parskip <botskip> = \topsep <toppenalty> = \@beginparpenalty <botpenatly> = \@endparpenalty


Notes: Except when in label or after nobreak, \parskip is added with \addvspace, so that net space is:

MAX{\topsep (+\partopsep) + \parskip , \lastskip } (The usual \@item works the same way.)
\parskip is added afterwards by a new paragraph, if any. <botskip> == \@topsepadd

\FV@ListVSpace
662 \def\FV@ListVSpace{% 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681

\@topsepadd\topsep \if@noparlist\advance\@topsepadd\partopsep\fi \if@inlabel \vskip\parskip \else \if@nobreak \vskip\parskip \clubpenalty\@M \else \addpenalty\@beginparpenalty \@topsep\@topsepadd \advance\@topsep\parskip \addvspace\@topsep \fi \fi \global\@nobreakfalse \global\@inlabelfalse \global\@minipagefalse \global\@newlistfalse}

\leftmargin := totalleftmargin \rightmargin := totalrightmargin \@totalleftmargin := totalleftmargin of enclosing environment.


47

\FV@SetLineWidth
682 \def\FV@SetLineWidth{% 683 684 685 686 687 688 689 690 691

\if@FV@ResetMargins\else \advance\leftmargin\@totalleftmargin \fi \advance\leftmargin\FV@XLeftMargin\relax \advance\rightmargin\FV@XRightMargin\relax \linewidth\hsize \advance\linewidth-\leftmargin \advance\linewidth-\rightmargin \hfuzz\FancyVerbHFuzz\relax}

We have to insert the right interline penalties (\interlinepenalty, \clubpenalty, \widowpenalty). We could process the environment as one long paragraph and let TEX insert the penalties, but this might cause problems for a very long environment. Line 1 : Insert \@labels (maybe) plus current_line Line 2 : Save current line Line 3 : penalty = interline + club ; Insert last line ; Save current line. Line 4 : penalty = interline ; Insert last line ; Save current line. Then at the end: Next line = 1 : Add null line. Next line = 2 : Nothing. Next line = 3 : penalty = interline + club + widow ; Insert last line. Next line = 4 : penalty = interline + widow ; Insert last line.

\FV@ListProcessLine
692 \def\FV@ListProcessLine#1{%

\hbox to \hsize{% \kern\leftmargin 695 \hbox to \linewidth{% 696 \FV@LeftListNumber 697 \FV@LeftListFrame 698 \FancyVerbFormatLine{#1}\hss 699 %% DG/SR modification begin - Jan. 28, 1998 (for numbers=right add-on) 700 %% \FV@RightListFrame}% 701 \FV@RightListFrame 702 \FV@RightListNumber}% 703 %% DG/SR modification end 704 \hss}}
693 694

48

\FV@ListProcessLine@i
705 \def\FV@ListProcessLine@i#1{% 706 707 708 709 710 711

\hbox{% \ifvoid\@labels\else \hbox to \z@{\kern\@totalleftmargin\box\@labels\hss}% \fi \FV@ListProcessLine{#1}}% \let\FV@ProcessLine\FV@ListProcessLine@ii}

\FV@ListProcessLine@ii
712 \def\FV@ListProcessLine@ii#1{% 713 714

\setbox\@tempboxa=\FV@ListProcessLine{#1}% \let\FV@ProcessLine\FV@ListProcessLine@iii}

\FV@ListProcessLine@iii
715 \def\FV@ListProcessLine@iii#1{% 716 717 718 719

{\advance\interlinepenalty\clubpenalty\penalty\interlinepenalty}% \box\@tempboxa \setbox\@tempboxa=\FV@ListProcessLine{#1}% \let\FV@ProcessLine\FV@ListProcessLine@iv}

\FV@ListProcessLine@iv
720 \def\FV@ListProcessLine@iv#1{% 721 722 723

\penalty\interlinepenalty \box\@tempboxa \setbox\@tempboxa=\FV@ListProcessLine{#1}}%

\FV@EndList
724 \def\FV@EndList{% 725 726 727 728 729

\FV@ListProcessLastLine \FV@EndListFrame \@endparenv \endgroup \@endpetrue}

\FV@ListProcessLastLine
730 \def\FV@ListProcessLastLine{% 731 732 733 734 735 736 737 738 739 740 741 742

\ifx\FV@ProcessLine\FV@ListProcessLine@iv {\advance\interlinepenalty\widowpenalty\penalty\interlinepenalty}% \box\@tempboxa \else \ifx\FV@ProcessLine\FV@ListProcessLine@iii {\advance\interlinepenalty\widowpenalty \advance\interlinepenalty\clubpenalty \penalty\interlinepenalty}% \box\@tempboxa \else \ifx\FV@ProcessLine\FV@ListProcessLine@i \FV@Error{Empty verbatim environment}{}%
49

743 744 745 746

\FV@ProcessLine{}% \fi \fi \fi}


Verbatim environment:

Verbatim
747 \def\FV@VerbatimBegin{\FV@List\z@} 748 \def\FV@VerbatimEnd{\FV@EndList}

\FVB@Verbatim
749 \def\FVB@Verbatim{\FV@VerbatimBegin\FV@Scan}

\FVE@Verbatim
750 \def\FVE@Verbatim{\FV@VerbatimEnd} 751 \DefineVerbatimEnvironment{Verbatim}{Verbatim}{}

With \UseVerbatim, we have to take care of some of the things \end{} would do.

\FV@UseVerbatim
752 \def\FV@UseVerbatim#1{% 753 754

\FV@VerbatimBegin#1\FV@VerbatimEnd \@doendpe\global\@ignorefalse\ignorespaces}

\VerbatimInput
755 \def\VerbatimInput{\FV@Command{}{VerbatimInput}}

\FVC@VerbatimInput
756 \def\FVC@VerbatimInput#1{\FV@UseVerbatim{\FV@Input{#1}}}

LVerbatim environment:

LVerbatim
757 \def\FV@LVerbatimBegin{\FV@List\@ne} 758 \def\FV@LVerbatimEnd{\FV@EndList}

\FVB@LVerbatim
759 \def\FVB@LVerbatim{\FV@LVerbatimBegin\FV@Scan}

\FVE@LVerbatim
760 \def\FVE@LVerbatim{\FV@LVerbatimEnd} 761 \DefineVerbatimEnvironment{LVerbatim}{LVerbatim}{}

\FV@LUseVerbatim
762 \def\FV@LUseVerbatim#1{% 763 764

\FV@LVerbatimBegin#1\FV@LVerbatimEnd \@doendpe\global\@ignorefalse\ignorespaces}
50

\LVerbatimInput
765 \def\LVerbatimInput{\FV@Command{}{LVerbatimInput}}

\FVC@LVerbatimInput
766 \def\FVC@LVerbatimInput#1{\FV@LUseVerbatim{\FV@Input{#1}}}

Frames:

\FV@Frame@none
767 \def\FV@Frame@none{% 768 769 770 771

\let\FV@BeginListFrame\relax \let\FV@LeftListFrame\relax \let\FV@RightListFrame\relax \let\FV@EndListFrame\relax}

\FV@Frame@single
772 \def\FV@Frame@single{% 773 774 775 776

\let\FV@BeginListFrame\FV@BeginListFrame@Single \let\FV@LeftListFrame\FV@LeftListFrame@Single \let\FV@RightListFrame\FV@RightListFrame@Single \let\FV@EndListFrame\FV@EndListFrame@Single}

\FV@Frame@lines
777 \def\FV@Frame@lines{% 778 779 780 781

\let\FV@BeginListFrame\FV@BeginListFrame@Lines \let\FV@LeftListFrame\relax \let\FV@RightListFrame\relax \let\FV@EndListFrame\FV@EndListFrame@Lines}

\FV@Frame@topline
782 \def\FV@Frame@topline{% 783 784 785 786

\let\FV@BeginListFrame\FV@BeginListFrame@Lines \let\FV@LeftListFrame\relax \let\FV@RightListFrame\relax \let\FV@EndListFrame\relax}

\FV@Frame@bottomline
787 \def\FV@Frame@bottomline{% 788 789 790 791

\let\FV@BeginListFrame\relax \let\FV@LeftListFrame\relax \let\FV@RightListFrame\relax \let\FV@EndListFrame\FV@EndListFrame@Lines}

\FV@Frame@leftline
792 %% 794 795

To define a frame with only a left line % To define the \FV@FrameFillLine macro (from \FV@BeginListFrame) \ifx\FancyVerbFillColor\relax
51

793 \def\FV@Frame@leftline{%

796 797 798 799 800 801 802 803 804 805 806 807

\let\FV@FrameFillLine\relax \else \@tempdima\FV@FrameRule\relax \multiply\@tempdima-\tw@ \edef\FV@FrameFillLine{% {\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}% \kern-\number\@tempdima sp}}% \fi \let\FV@BeginListFrame\relax \let\FV@LeftListFrame\FV@LeftListFrame@Single \let\FV@RightListFrame\relax \let\FV@EndListFrame\relax}

\FV@BeginListFrame@Single
808 \def\FV@BeginListFrame@Single{%

\lineskip\z@ \baselineskip\z@ 811 \ifx\FancyVerbFillColor\relax 812 \let\FV@FrameFillLine\relax 813 \else 814 \@tempdima\FV@FrameRule\relax 815 \multiply\@tempdima-\tw@ 816 \edef\FV@FrameFillLine{% 817 {\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}% 818 \kern-\number\@tempdima sp}}% 819 \fi 820 %% DG/SR modification begin - May. 19, 1998 821 %% \FV@SingleFrameLine 822 \FV@SingleFrameLine{\z@}% 823 %% DG/SR modification end 824 \penalty\@M 825 \FV@SingleFrameSep 826 \penalty\@M}
809 810

\FV@Label
827 %% 829 830 831 832 833 834 835

DG/SR modification begin - May. 19, 1998 \def\@tempa{#1}% \ifx\@tempa\FV@None \let\FV@LabelBegin\relax \let\FV@LabelEnd\relax \else \FV@Label@i#1\@nil% \fi}

828 \define@key{FV}{label}{%

\FV@Label@i
836 \def\FV@Label@i{\@ifnextchar[{\FV@Label@ii}{\FV@Label@ii[]}}

52

\FV@Label@ii
837 \def\FV@Label@ii[#1]#2\@nil{% 838 839 840 841 842 843 844 845

\def\@tempa{#1}% \ifx\@tempa\empty \def\FV@LabelBegin{#2}% \else \def\FV@LabelBegin{#1}% \def\FV@LabelPositionBottomLine{\@ne}% \fi \def\FV@LabelEnd{#2}}

846 \fvset{label=none}

\FV@LabelPosition
847 \define@key{FV}{labelposition}[none]{% 848 849 850

\@ifundefined{FV@LabelPosition@#1}% {\FV@Error{Label position #1 not defined.}\FV@eha}% {\@nameuse{FV@LabelPosition@#1}}}

\FV@LabelPosition@none
851 \def\FV@LabelPosition@none{% 852 853

\let\FV@LabelPositionTopLine\relax% \let\FV@LabelPositionBottomLine\relax}

\FV@LabelPosition@topline
854 \def\FV@LabelPosition@topline{% 855 856

\def\FV@LabelPositionTopLine{\@ne}% \let\FV@LabelPositionBottomLine\relax}

\FV@LabelPosition@bottomline
857 \def\FV@LabelPosition@bottomline{% 858 859

\let\FV@LabelPositionTopLine\relax% \def\FV@LabelPositionBottomLine{\@ne}}

\FV@LabelPosition@all
860 \def\FV@LabelPosition@all{% 861 862

\def\FV@LabelPositionTopLine{\@ne}% \def\FV@LabelPositionBottomLine{\@ne}} DG/SR modification end

863 \fvset{labelposition=topline} 864 %%

\FV@SingleFrameLine
865 %% 866 %%

DG/SR modification begin - May. 19, 1998 \def\FV@SingleFrameLine{% 867 \def\FV@SingleFrameLine#1{% 868 %% DG/SR modification end 869 \hbox to\z@{% 870 \kern\leftmargin
53

DG/SR modification begin - Jun. 22, 1998 \ifnum#1=\z@ 873 \let\FV@Label\FV@LabelBegin 874 \else 875 \let\FV@Label\FV@LabelEnd 876 \fi 877 \ifx\FV@Label\relax 878 %% DG/SR modification end 879 \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}% 880 %% DG/SR modification begin - Jun. 22, 1998 881 \else 882 \ifnum#1=\z@ 883 \setbox\z@\hbox{\strut\enspace\FV@LabelBegin\enspace\strut}% 884 \else 885 \setbox\z@\hbox{\strut\enspace\FV@LabelEnd\enspace\strut}% 886 \fi 887 \@tempdimb=\dp\z@ 888 \advance\@tempdimb -.5\ht\z@ 889 \@tempdimc=\linewidth 890 \advance\@tempdimc -\wd\z@ 891 \divide\@tempdimc\tw@ 892 \ifnum#1=\z@ % Top line 893 \ifx\FV@LabelPositionTopLine\relax 894 \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}% 895 \else 896 \FV@FrameLineWithLabel 897 \fi 898 \else % Bottom line 899 \ifx\FV@LabelPositionBottomLine\relax 900 \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}% 901 \else 902 \FV@FrameLineWithLabel 903 \fi 904 \fi 905 \fi 906 %% DG/SR modification end 907 \hss}}
872

871 %%

\FV@FrameLineWithLabel
908 %% 910 911

DG/SR modification begin - May. 19, 1998

909 \def\FV@FrameLineWithLabel{%

\ht\z@\@tempdimb\dp\z@\@tempdimb% \FancyVerbRuleColor{% 912 \vrule \@width\@tempdimc \@height\FV@FrameRule 913 \raise\@tempdimb\box\z@ 914 \vrule \@width\@tempdimc \@height\FV@FrameRule}} 915 %% DG/SR modification end \FV@BeginListFrame@Lines

54

916 \def\FV@BeginListFrame@Lines{%

\begingroup \lineskip\z@skip 919 %% DG modification begin - June 18, 1997 (effect of \baselineskip too earlier) 920 %% \baselineskip\z@skip 921 %% \FV@SingleFrameLine 922 %% DG/SR modification begin - May. 19, 1998 923 %% \FV@SingleFrameLine 924 \FV@SingleFrameLine{\z@}% 925 %% DG/SR modification end 926 \kern-0.5\baselineskip\relax 927 \baselineskip\z@skip 928 %% DG modification end 929 \kern\FV@FrameSep\relax 930 \endgroup}%
917 918

\FV@EndListFrame@Lines
931 \def\FV@EndListFrame@Lines{%

\begingroup \baselineskip\z@skip 934 \kern\FV@FrameSep\relax 935 %% DG/SR modification begin - May. 19, 1998 936 %% \FV@SingleFrameLine 937 \FV@SingleFrameLine{\@ne}% 938 %% DG/SR modification end 939 \endgroup}
932 933

\FV@SingleFrameSep
940 \def\FV@SingleFrameSep{%

\hbox to \z@{% \kern\leftmargin 943 \hbox to\linewidth{% 944 \FancyVerbRuleColor{% 945 %% DG modification begin - June 18, 1997 (\FV@FrameSep missing) 946 \ifx\FancyVerbFillColor\relax 947 \vrule\@width 0pt\@height\FV@FrameSep\relax 948 \fi 949 %% DG modification end 950 \vrule\@width\FV@FrameRule\relax 951 \ifx\FancyVerbFillColor\relax 952 \hfil 953 \else 954 {\FancyVerbFillColor\leaders\hrule\@height\FV@FrameSep\hfil}% 955 \fi 956 %% DG modification begin - June 18, 1997 (\FV@FrameSep missing) 957 \ifx\FancyVerbFillColor\relax 958 \vrule\@width 0pt\@height\FV@FrameSep\relax 959 \fi 960 %% DG modification end
941 942

55

961 962

\vrule\@width\FV@FrameRule\relax}}% \hss}}

\FV@LeftListFrame@Single
963 \def\FV@LeftListFrame@Single{%

\strut {\FancyVerbRuleColor{\vrule \@width\FV@FrameRule}}% 966 \FV@FrameFillLine 967 %% DG modification begin - June 18, 1997 (to fill color on left side) 968 %% \kern\FV@FrameSep} 969 \ifx\FancyVerbFillColor\relax 970 \kern\FV@FrameSep 971 \else 972 {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}% 973 \fi} 974 %% DG modification end
964 965

\FV@RightListFrame@Single
975 \def\FV@RightListFrame@Single{%

DG modification begin - June 18, 1997 (to fill color on right side) \kern\FV@FrameSep 978 \ifx\FancyVerbFillColor\relax 979 \kern\FV@FrameSep 980 \else 981 {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}% 982 \fi 983 {\noexpand\leavevmode\FancyVerbRuleColor{\vrule\@width\FV@FrameRule}}} 984 %% DG modification end
977 %%

976 %%

\FV@EndListFrame@Single
985 \def\FV@EndListFrame@Single{%

\penalty\@M \FV@SingleFrameSep 988 \penalty\@M 989 %% DG/SR modification begin - May. 19, 1998 990 %% \FV@SingleFrameLine} 991 \FV@SingleFrameLine{\@ne}} 992 %% DG/SR modification end
986 987

\FV@FrameRule
993 \define@key{FV}{framerule}{% 994 995

\@tempdima=#1\relax \edef\FV@FrameRule{\number\@tempdima sp\relax}}

\KV@FV@framerule@default
996 \def\KV@FV@framerule@default{\let\FV@FrameRule\fboxrule}

56

\FV@FrameSep
997 \define@key{FV}{framesep}{% 998 999

\@tempdima=#1\relax \edef\FV@FrameSep{\number\@tempdima sp\relax}}

\KV@FV@framesep@default
1000 \def\KV@FV@framesep@default{\let\FV@FrameSep\fboxsep} 1001 \fvset{framerule,framesep}

\FancyVerbRuleColor
1002 \define@key{FV}{rulecolor}{% 1003 1004 1005 1006 1007 1008

\def\@tempa{#1}% \ifx\@tempa\FV@None \let\FancyVerbRuleColor\relax \else \let\FancyVerbRuleColor\@tempa \fi}

\FancyVerbFillColor
1009 \define@key{FV}{fillcolor}{% 1010 1011 1012 1013 1014 1015

\def\@tempa{#1}% \ifx\@tempa\FV@None \let\FancyVerbFillColor\relax \else \let\FancyVerbFillColor\@tempa \fi}

1016 \fvset{rulecolor=none,fillcolor=none}

\FV@Frame@double
1017 \def\FV@Frame@double{% 1018 1019 1020

\let\FV@FrameBegin\FV@FrameBegin@double \let\FV@FrameLine\FV@FrameLine@double \let\FV@FrameEnd\FV@FrameEnd@double} \@ifundefined{FV@Frame@#1}% {\FV@Error{Frame style #1 not defined.}\FV@eha}% {\@nameuse{FV@Frame@#1}}}


Code line numbers:

1021 \define@key{FV}{frame}[none]{% 1022 1023 1024

1025 \fvset{frame=none}

1026 \newcounter{FancyVerbLine}

\FV@SetLineNo
1027 \define@key{FV}{firstnumber}[auto]{% 1028 1029

\def\@tempa{#1}\def\@tempb{auto}% \ifx\@tempa\@tempb
57

\def\FV@SetLineNo{% \c@FancyVerbLine\FV@CodeLineNo 1032 \advance\c@FancyVerbLine\m@ne}% 1033 \else 1034 \def\@tempb{last}% 1035 \ifx\@tempa\@tempb 1036 \let\FV@SetLineNo\relax 1037 \else 1038 %% DG/SR modification begin - Jan. 19, 1998 1039 %% \def\FV@SetLineNo{\c@FancyVerbLine#1}% 1040 \def\FV@SetLineNo{% 1041 \c@FancyVerbLine#1 1042 \advance\c@FancyVerbLine\m@ne}% 1043 %% DG/SR modification end 1044 \fi 1045 \fi}
1030 1031

\if@FV@NumberBlankLines
1046 \define@booleankey{FV}{numberblanklines}%

{\let\if@FV@NumberBlankLines\iftrue} {\let\if@FV@NumberBlankLines\iffalse} 1049 \fvset{numberblanklines=true}


1047 1048

\FV@refstepcounter
1050 %%

DG/SR modification begin - May. 20, 1998 Adapted from latex.ltx 1052 \def\FV@refstepcounter#1{% 1053 %% DG/SR modification end 1054 \stepcounter{#1}% 1055 \protected@edef\@currentlabel 1056 {\csname p@#1\endcsname\arabic{FancyVerbLine}}}
1051 %%\def\refstepcounter#1{%

\FV@StepLineNo
1057 \def\FV@StepLineNo{% 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068

\FV@SetLineNo% \def\FV@StepLineNo{% \if@FV@NumberBlankLines% \FV@refstepcounter{FancyVerbLine}% \else% \ifx\FV@Line\empty% \else% \FV@refstepcounter{FancyVerbLine}% \fi% \fi}% \FV@StepLineNo}

58

\theFancyVerbLine
1069 %%

DG/SR modification begin - 1995 DG/SR modification end \@ifundefined{FV@Numbers@#1}% {\FV@Error{Numbers style #1 not defined.}\FV@eha}% {\@nameuse{FV@Numbers@#1}}}

1070 %%\def\theFancyVerbLine{\rm\tiny\arabic{FancyVerbLine}} 1071 \def\theFancyVerbLine{\rmfamily\tiny\arabic{FancyVerbLine}} 1072 %%

1073 \define@key{FV}{numbers}[none]{% 1074 1075 1076

(D.G. Dec. 20, 1995 and Jan. 28, 1998): Add-on to allow a step when printing the lines counter (stepnumber keyword) Add-on to allow the counter to be printed on right side (numbers=right)

\FV@Numbers@none
1077 %%

DG modification begin - Dec. 20, 1995 and Jan. 28, 1998

1078 %%\def\FV@Numbers@none{\let\FV@LeftListNumber\relax} 1079 \def\FV@Numbers@none{% 1080 \let\FV@LeftListNumber\relax 1081 \let\FV@RightListNumber\relax} 1082 \newcount\FV@StepNumber 1083 \define@key{FV}{stepnumber}{\FV@StepNumber#1}

\KV@FV@stepnumber@default
1084 \def\KV@FV@stepnumber@default{\FV@StepNumber\@ne} 1085 \fvset{stepnumber}

\FV@Numbers@left
1086 %% 1088 %% 1089 %%

DG modification begin - Dec. 20, 1995

1087 %%\def\FV@Numbers@left{%

\def\FV@LeftListNumber{\hbox to\z@{% \hss\theFancyVerbLine\kern\FV@NumberSep}}} 1090 \def\FV@Numbers@left{% 1091 %% DG/SR modification begin - Apr. 28, 1998 1092 \let\FV@RightListNumber\relax 1093 %% DG/SR modification end 1094 \def\FV@LeftListNumber{% 1095 \@tempcnta=\FV@CodeLineNo 1096 \@tempcntb=\FV@CodeLineNo 1097 \divide\@tempcntb\FV@StepNumber 1098 \multiply\@tempcntb\FV@StepNumber 1099 \ifnum\@tempcnta=\@tempcntb 1100 %% DG/SR modification begin - Apr. 28, 1998 1101 %% \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}% 1102 \if@FV@NumberBlankLines 1103 \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}% 1104 \else
59

\ifx\FV@Line\empty \else 1107 \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}% 1108 \fi 1109 \fi 1110 %% DG/SR modification end 1111 \fi}}
1105 1106

\FV@Numbers@right
1112 \def\FV@Numbers@right{%

DG/SR modification begin - Apr. 28, 1998 \let\FV@LeftListNumber\relax 1115 %% DG/SR modification end 1116 \def\FV@RightListNumber{% 1117 \@tempcnta=\FV@CodeLineNo 1118 \@tempcntb=\FV@CodeLineNo 1119 \divide\@tempcntb\FV@StepNumber 1120 \multiply\@tempcntb\FV@StepNumber 1121 \ifnum\@tempcnta=\@tempcntb 1122 %% DG/SR modification begin - Apr. 28, 1998 1123 %% \hbox to \z@{\kern\FV@NumberSep\theFancyVerbLine\hss}% 1124 \if@FV@NumberBlankLines 1125 \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}% 1126 \else 1127 \ifx\FV@Line\empty 1128 \else 1129 \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}% 1130 \fi 1131 \fi 1132 %% DG/SR modification end 1133 \fi}} 1134 %% DG modification end
1114

1113 %%

\FV@NumberSep
1135 \define@key{FV}{numbersep}{% 1136 1137

\@tempdima=#1\relax \edef\FV@NumberSep{\number\@tempdima sp\relax}}

1138 \fvset{numbers=none,numbersep=12pt,firstnumber=auto}

12.14 BVerbatim
BVerbatim
1139 \def\FV@BVerbatimBegin{% 1140 1141 1142 1143

\begingroup \FV@UseKeyValues \FV@BeginVBox \let\FV@ProcessLine\FV@BProcessLine


60

\FV@FormattingPrep \FV@ObeyTabsInit}% 1146 \def\FV@BVerbatimEnd{\FV@EndVBox\endgroup}


1144 1145

\FV@BeginVBox
1147 \def\FV@BeginVBox{% 1148 1149 1150

\leavevmode \hbox\ifx\FV@boxwidth\relax\else to\FV@boxwidth\fi\bgroup \ifcase\FV@baseline\vbox\or\vtop\or$\vcenter\fi\bgroup}

\FV@EndVBox
1151 \def\FV@EndVBox{\egroup\ifmmode$\fi\hfil\egroup}

\FV@boxwidth
1152 \define@key{FV}{boxwidth}{% 1153 1154 1155 1156 1157 1158 1159

\def\@tempa{#1}\def\@tempb{auto}% \ifx\@tempa\@tempb \let\FV@boxwidth\relax \else \@tempdima=#1\relax \edef\FV@boxwidth{\number\@tempdima sp}% \fi}

\KV@FV@boxwidth@default
1160 \def\KV@FV@boxwidth@default{\let\FV@boxwidth\relax}

\FV@baseline
1161 \define@key{FV}{baseline}{% 1162 1163 1164

\if t#1\@empty\let\FV@baseline\@ne\else \if c#1\@empty\let\FV@baseline\tw@\else\let\FV@baseline\z@\fi \fi}

1165 \fvset{baseline=b,boxwidth}

\FV@BProcessLine
1166 \def\FV@BProcessLine#1{\hbox{\FancyVerbFormatLine{#1}}}

\FVB@BVerbatim
1167 \def\FVB@BVerbatim{\FV@BVerbatimBegin\FV@Scan}

\FVE@BVerbatim
1168 \def\FVE@BVerbatim{\FV@BVerbatimEnd} 1169 \DefineVerbatimEnvironment{BVerbatim}{BVerbatim}{}

\FV@BUseVerbatim
1170 \def\FV@BUseVerbatim#1{\FV@BVerbatimBegin#1\FV@BVerbatimEnd}

61

\BVerbatimInput
1171 \def\BVerbatimInput{\FV@Command{}{BVerbatimInput}}

\FVC@BVerbatimInput
1172 \def\FVC@BVerbatimInput#1{\FV@BUseVerbatim{\FV@Input{#1}}}

12.15 Save verbatim


SaveVerbatim
1173 \def\SaveVerbatim{\FV@Environment{}{SaveVerbatim}}

\FVB@SaveVerbatim
1174 \def\FVB@SaveVerbatim#1{%

\@bsphack \begingroup 1177 \FV@UseKeyValues 1178 %% \FV@BeginVBox 1179 %% \let\FV@ProcessLine\FV@BProcessLine 1180 %% \FV@FormattingPrep 1181 %% \FV@ObeyTabsInit% 1182 %% 1183 \def\SaveVerbatim@Name{#1}% 1184 \gdef\FV@TheVerbatim{}% 1185 \def\FV@ProcessLine##1{% 1186 \expandafter\gdef\expandafter\FV@TheVerbatim\expandafter{% 1187 \FV@TheVerbatim\FV@ProcessLine{##1}}}% 1188 \gdef\FV@TheVerbatim{}% 1189 \FV@Scan}
1175 1176

\FVE@SaveVerbatim
1190 \def\FVE@SaveVerbatim{% 1191 1192

\expandafter\global\expandafter\let \csname FV@SV@\SaveVerbatim@Name\endcsname\FV@TheVerbatim 1193 %% \expandafter\gdef 1194 %% \csname FV@SV@\SaveVerbatim@Name\endcsname{\FV@TheVerbatim} 1195 %% \FV@EndVBox 1196 %% \endgroup} 1197 \endgroup\@esphack}

SaveVerbatim
1198 \DefineVerbatimEnvironment{SaveVerbatim}{SaveVerbatim}{}

\FV@CheckIfSaved
1199 \def\FV@CheckIfSaved#1#2{% 1200 1201 1202

\@ifundefined{FV@SV@#1}% {\FV@Error{No verbatim text has been saved under name #1}\FV@eha}% {#2{\csname FV@SV@#1\endcsname}}}

62

\UseVerbatim
1203 \def\UseVerbatim{\FV@Command{}{UseVerbatim}}

\FVC@UseVerbatim
1204 \def\FVC@UseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@UseVerbatim}}

\LUseVerbatim
1205 \def\LUseVerbatim{\FV@Command{}{LUseVerbatim}}

\FVC@LUseVerbatim
1206 \def\FVC@LUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@LUseVerbatim}}

\BUseVerbatim
1207 \def\BUseVerbatim{\FV@Command{}{BUseVerbatim}}

\FVC@BUseVerbatim
1208 \def\FVC@BUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@BUseVerbatim}}

12.16 Verbatim out


1209 \newwrite\FV@OutFile

\VerbatimOut
1210 \def\VerbatimOut{\FV@Environment{}{VerbatimOut}}

\FVB@VerbatimOut
1211 \def\FVB@VerbatimOut#1{%

\@bsphack \begingroup 1214 \FV@UseKeyValues 1215 \FV@DefineWhiteSpace 1216 \def\FV@Space{\space}% 1217 \FV@DefineTabOut 1218 \def\FV@ProcessLine{\immediate\write\FV@OutFile}% 1219 \immediate\openout\FV@OutFile #1\relax 1220 \let\FV@FontScanPrep\relax 1221 %% DG/SR modification begin - May. 18, 1998 (to avoid problems with ligatures) 1222 \let\@noligs\relax 1223 %% DG/SR modification end 1224 \FV@Scan}
1212 1213

\FVE@VerbatimOut
1225 \def\FVE@VerbatimOut{\immediate\closeout\FV@OutFile\endgroup\@esphack}

VerbatimOut
1226 \DefineVerbatimEnvironment{VerbatimOut}{VerbatimOut}{}

63

\FV@DefineTabOut
1227 \def\FV@DefineTabOut{% 1228 1229 1230 1231 1232 1233

\def\FV@Tab{}% \@tempcnta=\FancyVerbTabSize\relax \loop\ifnum\@tempcnta>\z@ \edef\FV@Tab{\FV@Tab\space}% \advance\@tempcnta\m@ne \repeat}

12.17 Short verbatim


\SaveVerb Note \outer\def^^M{}. This is so that verbatim commands report an error
when encountering an end-of-line, rather than scanning to the end of the le each time there is a missing verbatim delimiter. If scanning fails (and thus TEX ignores \FV@GetVerb), #1 is dened to be empty, a group is ended, but \FancyVerbAfterSave is not invoked.

\FV@Command
1234 \def\SaveVerb{\FV@Command{}{SaveVerb}}

\FVC@SaveVerb
1235 \begingroup 1236 \catcode\^^M=\active% 1237 \gdef\FVC@SaveVerb#1#2{%

\@namedef{FV@SV@#1}{}% \begingroup% 1240 \FV@UseKeyValues% 1241 \FV@CatCodes% 1242 \outer\def^^M{\FV@EOL}% 1243 \global\let\@tempg\FancyVerbAfterSave% 1244 \catcode#2=12% 1245 \def\@tempa{\def\FancyVerbGetVerb####1####2}% 1246 \expandafter\@tempa\string#2{\endgroup\@namedef{FV@SV@#1}{##2}\@tempg}% 1247 \FancyVerbGetVerb\FV@EOL}% 1248 \endgroup
1238 1239

\FV@EOL
1249 \def\FV@EOL{% 1250 1251 1252 1253 1254 1255 1256

\endgroup \FV@Error% {Could not find the end delimiter of a short verb command}% {You probably just forget the end delimiter of a \string\Verb\space or \string\SaveVerb^^J% command, or you broke the literal text across input lines.^^J% Hit <return> to procede.}}

64

\FancyVerbAfterSave
1257 \define@key{FV}{aftersave}{\def\FancyVerbAfterSave{#1}} 1258 \fvset{aftersave=}

\FV@UseVerb
1259 \def\FV@UseVerb#1{\mbox{\FV@UseKeyValues\FV@FormattingPrep#1}}

\UseVerb
1260 \def\UseVerb{\FV@Command{}{UseVerb}}

\FVC@UseVerb
1261 \def\FVC@UseVerb#1{% 1262 1263 1264

\@ifundefined{FV@SV@#1}% {\FV@Error{Short verbatim text never saved to name #1}\FV@eha}% {\FV@UseVerb{\@nameuse{FV@SV@#1}}}}

\Verb
1265 \def\Verb{\FV@Command{}{Verb}}

\FVC@Verb
1266 \begingroup 1267 \catcode\^^M=\active% 1268 \gdef\FVC@Verb#1{%

\begingroup% \FV@UseKeyValues% 1271 \FV@FormattingPrep% 1272 \FV@CatCodes% 1273 \outer\def^^M{}% 1274 \catcode#1=12% 1275 \def\@tempa{\def\FancyVerbGetVerb####1####2}% 1276 \expandafter\@tempa\string#1{\mbox{##2}\endgroup}% 1277 \FancyVerbGetVerb\FV@EOL}% 1278 \endgroup
1269 1270

\DefineShortVerb
1279 \def\DefineShortVerb{\FV@Command{}{DefineShortVerb}}

\FVC@DefineShortVerb
1280 \def\FVC@DefineShortVerb#1{% 1281 1282 1283 1284

\@ifundefined{FV@CC@\string#1}% {\FVC@@DefineShortVerb#1}% {\FV@Error{\expandafter\@gobble\string#1 is already a short verb character.}\FV@eha}}

\FVC@@DefineShortVerb
1285 \def\FVC@@DefineShortVerb#1{% 1286 1287

\begingroup \lccode\~=#1%

65

1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299

\lowercase{\gdef\@tempg{\edef~}\global\let\@temph~}% \endgroup \expandafter\let\csname FV@AC@\string#1\endcsname\@temph \expandafter\edef\csname FV@CC@\string#1\endcsname{\the\catcode#1}% \expandafter\let\csname FV@KV@\string#1\endcsname\FV@KeyValues \@tempg{% \let\noexpand\FV@KeyValues\expandafter\noexpand \csname FV@KV@\string#1\endcsname \noexpand\FVC@Verb\expandafter\@gobble\string#1}% \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do#1}% \expandafter\def\expandafter\@sanitize\expandafter{\@sanitize\@makeother#1}% \catcode#1=\active}%

\UndefineShortVerb
1300 \def\UndefineShortVerb#1{% 1301 1302 1303 1304

\@ifundefined{FV@CC@\string#1}% {\FV@Error{\expandafter\@gobble\string#1 is not a short verb character}\FV@eha}% {\FV@UndefineShortVerb#1}}

\FV@UndefineShortVerb
1305 \def\FV@UndefineShortVerb#1{%

\catcode#1=\csname FV@CC@\string#1\endcsname DG/SR modification begin - Jun. 12, 1998 1308 \expandafter\let\csname FV@CC@\string#1\endcsname\relax 1309 %% DG/SR modification end 1310 \begingroup 1311 \lccode\~=#1% 1312 \lowercase{\gdef\@tempg{\let~}}% 1313 \endgroup 1314 \expandafter\@tempg\csname FV@AC@\string#1\endcsname 1315 \def\@tempa##1\do#1##2\@nil##3\@nil##4\@@nil{##3\def\dospecials{##1##2}\fi}% 1316 \expandafter\@tempa\dospecials\@nil\iftrue\@nil\do#1\@nil\iffalse\@nil\@@nil 1317 \def\@tempa##1\@makeother#1##2\@nil##3\@nil##4\@@nil{% 1318 ##3\def\@sanitize{##1##2}\fi}% 1319 \expandafter\@tempa\@sanitize\@nil\iftrue\@nil\do#1\@nil\iffalse\@nil\@@nil}
1306 1307 %%

Moving verbatim. Need to worry about using separate identier for this class of verbatim, and

\SaveMVerb
1320 \def\SaveMVerb{\FV@Command{}{SaveMVerb}}

\FVC@SaveMVerb
1321 \begingroup 1322 \catcode\^^M=\active% 1323 \gdef\FVC@SaveMVerb#1#2{% 1324 1325

\@ifundefined{FV@SVM@#1}{}% {\FV@Error{Moving verbatim name #1 already used}%


66

{I will overwrite the old definition. Hit <return> to continue.}}% \global\@namedef{FV@SVM@#1}{}% 1328 \begingroup% 1329 \let\FV@SavedKeyValues\FV@KeyValues% 1330 \FV@UseKeyValues% 1331 \FV@CatCodes% 1332 \outer\def^^M{}% 1333 \global\let\@tempg\FancyVerbAfterSave% 1334 \catcode#2=12% 1335 \def\@tempa{\def\FancyVerbGetVerb####1####2}% 1336 \expandafter\@tempa\string#2{% 1337 \if@filesw 1338 \FV@DefineWhiteSpace% 1339 \let\FV@Space\space% 1340 \let\FV@Tab\space% 1341 \FV@MakeUnActive% 1342 \let\protect\string 1343 \immediate\write\@auxout{% 1344 \noexpand\SaveGVerb[\FV@SavedKeyValues]{#1}\string#2##2\string#2}% 1345 \fi 1346 \endgroup% 1347 \@namedef{FV@SV@#1}{##2}% 1348 \@tempg}% 1349 \FancyVerbGetVerb\FV@EOL}% 1350 \endgroup
1326 1327

\SaveGVerb
1351 \def\SaveGVerb{\FV@Command{}{SaveGVerb}}

\FVC@SaveGVerb
1352 \begingroup 1353 \catcode\^^M=\active% 1354 \gdef\FVC@SaveGVerb#1#2{%

\global\@namedef{FV@SVG@#1}{}% \begingroup% 1357 \FV@UseKeyValues% 1358 \FV@CatCodes% 1359 \outer\def^^M{}% 1360 \catcode#2=12% 1361 \def\@tempa{\def\FancyVerbGetVerb####1####2}% 1362 \expandafter\@tempa\string#2{\endgroup\global\@namedef{FV@SVG@#1}{##2}}% 1363 \FancyVerbGetVerb\FV@EOL}% 1364 \endgroup
1355 1356

\UseMVerb
1365 \def\UseMVerb{\protect\pUseMVerb}

\pUseMVerb
1366 \def\pUseMVerb{\FV@Command{}{pUseMVerb}}

67

\FVC@pUseMVerb
1367 \def\FVC@pUseMVerb#1{% 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377

\expandafter\ifx \csname FV@SVM@#1\endcsname\relax \expandafter\ifx \csname FV@SVG@#1\endcsname\relax \@warning{Moving verbatim text not defined for name #1}\FV@eha {\bf ??}% \else \FV@UseVerb{\@nameuse{FV@SVG@#1}}% \fi \else \FV@UseVerb{\@nameuse{FV@SVM@#1}}% \fi} documentclass\endcsname\relax

1378 \expandafter\ifx\csname

lrbox
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390

\def\lrbox#1{% \edef\@tempa{% \endgroup \setbox#1\hbox{% \begingroup\aftergroup}% \def\noexpand\@currenvir{\@currenvir}}% %\def\noexpand\@currenvline{\on@line}}% \@tempa \@endpefalse \bgroup \ignorespaces} \def\endlrbox{\unskip\egroup} DG/SR modification begin DG/SR modification end Mar 21 2000

1391 \fi 1392 %%

1393 %%\@input{fancyvrb.rc} 1394 \InputIfFileExists{fancyvrb.cfg}{}{} 1395 %%

Unused code - dont take care! (DG/SR) Error messages to void: </fancyvrb>

Index
Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the denition; numbers in roman refer to the code lines where the entry is used.
Symbols

\! . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 \% . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 \= . . . . . . . . . . . . . . . . . . . . . . . 301, 312

\@CustomVerbatimCommand . . 87, 97, 98 \@CustomVerbatimEnvironment . . .


. . . . . . . . . . . . . . . . 105, 106, 107

\@noligs . . . . . . . . . . . . 375, 470, 1222

68

\[ \{ \} \] \^

. . . . . . . . . . . . . . . . . . . . . . . . . 296 . . 142, 329, 334, 339, 344, 349, 354 . . . . . . . . . . . . . . . . . . . . . . . . . 142 . . . . . . . . . . . . . . . . . . . . . . . . . 297 101, 103, 104, 131, 133, 362, 378, 435, 544, 1236, 1267, 1322, 1353 \ . . . . . . . . . . . . . . . . . . . 514, 516, 522 \~ . . . . . . . . . . . . . . . . . . . . . 1287, 1311

. . . . .

. . . .

\FancyVerbRuleColor . . . . . . 879,
894, 900, 911, 944, 965, 983, 1002

\FancyVerbSpace . . . . . . . . . . 553, 555 \FancyVerbStartNum 166, 172, 201, 210 \FancyVerbStartString . . . . . . . .


. . . . . . . . . 167, 169, 173, 200, 218

\FancyVerbStopNum . . . . . . . . . . . .
. . . . . . . . . 178, 184, 229, 238, 245

\FancyVerbStopString . . . . . . . . .
. . . . . . . . . 179, 181, 185, 228, 253

\ . . . . . . . . . . . . . . . 132, 543, 554, 555


B

\FancyVerbTab . . . . . . . . . . . . 566, 569 \FancyVerbTabSize . . . . . . . . . . . .


. . . . . . . . 557, 558, 577, 580, 1229

\BUseVerbatim . . . . . . . . . . . . . . . 1207 BVerbatim (environment) . . . . . . . . . 60 \BVerbatimInput . . . . . . . . . . . . . 1171


C

\CustomVerbatimCommand . . . . . . . 97 \CustomVerbatimEnvironment . . . . 105


D

\define@booleankey . . . . . . . . . . . 66 \DefineShortVerb . . . . . . . . . . . . 1279 \DefineVerbatimEnvironment . . . .


. . 113, 751, 761, 1169, 1198, 1226 E

\empty . . . . . . . . . 839, 1063, 1105, 1127


environments:

BVerbatim . . . . . . . . . . . . . . . . . lrbox . . . . . . . . . . . . . . . . . . . . . LVerbatim . . . . . . . . . . . . . . . . . SaveVerbatim . . . . . . . . . . . . . . Verbatim . . . . . . . . . . . . . . . . . . VerbatimOut . . . . . . . . . . . . . . .


F

60 68 50 62 50 63

\FV@@@@Gobble . . . . . . . . 268, 279, 283 \FV@@@CheckEnd 332, 337, 347, 352, 383 \FV@@@CheckEnd@i . . . . . . . . . . . . . 332 \FV@@@CheckEnd@ii . . . . . . . . . . . . 347 \FV@@@CheckEnd@iii . . . . . . . . . . . 352 \FV@@@CheckEnd@iv . . . . . . . . . . . . 337 \FV@@@Gobble . . . . . . . . . . . . . 267, 270 \FV@@CheckEnd . . . . 331, 336, 346, 351 \FV@@CheckEnd@i . . . . . . . . . . . . . . 331 \FV@@CheckEnd@ii . . . . . . . . . . . . . 346 \FV@@CheckEnd@iii . . . . . . . . . . . . 351 \FV@@CheckEnd@iv . . . . . . . . . . . . . 336 \FV@@Command . . . . . . . . . . . . 79, 80, 81 \FV@@FindStartString . . . . . 216, 220 \FV@@FindStopString . . . . . . 251, 255 \FV@@Gobble . . . . . . . . . . . . . . 266, 280 \FV@@Input . . . . . . . . . . . . . . . 420, 422 \FV@@ObeyTabs . . . . . . . . . . . . 582, 584 \FV@@ObeyTabsInit . . . . . . . . 576, 597 \FV@@ObeyTabSize . . . . . . . . . 581, 590 \FV@@PreProcessLine . . . . . . . . . .
. . . . . . . . . 191, 212, 230, 247, 263

\FancyVerbAfterSave 1243, 1257, 1333 \FancyVerbCodes . . . . . . . . . . 129, 137 \FancyVerbDefineActive . . . 451, 547 \FancyVerbFillColor . . . . . . . . . .
. . 795, 801, 811, 817, 946, 951, 954, 957, 969, 972, 978, 981, 1009 \FancyVerbFormatCom . . . . . . 452, 600 \FancyVerbFormatLine 605, 698, 1166 \FancyVerbGetLine . . . . 374, 375, 377 \FancyVerbGetVerb . . . 1245, 1247, 1275, 1277, 1335, 1349, 1361, 1363 \FancyVerbHFuzz . . . . . . . . . . 616, 691

\FV@@ReadLine . . . . . . . . . . . . 439, 441 \FV@ActiveWhiteSpace . . . . . 126, 130 \FV@AddToHook . . . . . . . . 135, 152, 160 \FV@Auto . . . . . . . 75, 475, 483, 495, 502 \FV@BadBeginError . . . . . . . . 364, 367 \FV@BadCodes . . . . . 318, 339, 354, 358 \FV@BadEndError . . . . . . . . . . 383, 391 \FV@baseline . . . . . . . . . . . 1150, 1161 \FV@BaseLineStretch 455, 463, 481, 488 \FV@BeginListFrame . . . . . . . 638,
768, 773, 778, 783, 788, 794, 804

\FV@BeginListFrame@Lines . . . . . .
. . . . . . . . . . . . . . . . 778, 783, 916

\FV@BeginListFrame@Single . 773, 808 \FV@BeginScanning . . . . . . . . 290, 361

69

\FV@BeginVBox . . . . . 1142, 1147, 1178 \FV@boxwidth . . . . . . 1149, 1152, 1160 \FV@BProcessLine . . 1143, 1166, 1179 \FV@BUseVerbatim . . 1170, 1172, 1208 \FV@BVerbatimBegin 1139, 1167, 1170 \FV@BVerbatimEnd . . 1146, 1168, 1170 \FV@CatCodes . . . . . . . . . 124, 287,
419, 635, 1241, 1272, 1331, 1358

\FV@Error . . . . . . . . . . . . . . . . . 31,
95, 110, 277, 319, 369, 393, 405, 416, 561, 742, 849, 1023, 1075, 1201, 1251, 1263, 1283, 1302, 1325 \FV@FindStartNum . . . . . . . . . 204, 209 \FV@FindStartStop . . . . 190, 195, 204, 207, 230, 232, 235, 240, 258 \FV@FindStartString . . . . . . 207, 214 \FV@FindStopNum . . . . . . . . . . 232, 237 \FV@FindStopString . . . . . . . 235, 249 \FV@FontFamily 458, 465, 491, 518, 519, 523, 527, 531, 532, 537, 538 \FV@fontfamily@cmtt . . . . . . . . . . 521 \FV@fontfamily@cmtt-spanish . . . 525 \FV@fontfamily@courier . . . . . . . 528 \FV@fontfamily@helvetica . . . . . . 534 \FV@fontfamily@tt . . . . . . . . . . . . 515 \FV@FontScanPrep . . . . . . . . . 127, 491, 516, 522, 526, 529, 535, 1220 \FV@FontSeries . . . . . . . . . . . 466, 493 \FV@FontShape . . . . . . . . . . . . 467, 500 \FV@FontSize . . . . . 457, 464, 473, 480 \FV@FormattingPrep . . . . . . . . . . . . 446, 636, 1144, 1180, 1259, 1271 \FV@Frame@bottomline . . . . . . . . . 787 \FV@Frame@double . . . . . . . . . . . . 1017 \FV@Frame@leftline . . . . . . . . . . . 792 \FV@Frame@lines . . . . . . . . . . . . . . 777 \FV@Frame@none . . . . . . . . . . . . . . . 767 \FV@Frame@single . . . . . . . . . . . . . 772 \FV@Frame@topline . . . . . . . . . . . . 782 \FV@FrameBegin . . . . . . . . . . . . . . 1018 \FV@FrameBegin@double . . . . . . . 1018 \FV@FrameEnd . . . . . . . . . . . . . . . . 1020 \FV@FrameEnd@double . . . . . . . . . 1020 \FV@FrameFillLine . . . . . . . . . . . . . . . . . 794, 796, 800, 812, 816, 966 \FV@FrameLine . . . . . . . . . . . . . . . 1019 \FV@FrameLine@double . . . . . . . . 1019 \FV@FrameLineWithLabel 896, 902, 908 \FV@FrameRule . . . . . . . . . . . . . . . . . . 798, 814, 879, 894, 900, 912, 914, 950, 961, 965, 983, 993, 996 \FV@FrameSep . . . . . . . . . 929, 934, 945, 947, 954, 956, 958, 968, 970, 972, 977, 979, 981, 997, 1000 \FV@GetKeyValues . . . . . . . 83, 85, 103 \FV@GetLine . . . . . . . . . . 365, 373, 387 \FV@Gobble . . . . . . . . . . . 193, 271, 284

\FV@CatCodesHook . 128, 134, 152, 160 \FV@CheckEnd . . . . . . . . . . . . . . . . . \FV@CheckEnd@i . . . . . . . . . . . . . . . \FV@CheckEnd@ii . . . . . . . . . . . . . . \FV@CheckEnd@iii . . . . . . . . . . . . . \FV@CheckEnd@iv . . . . . . . . . . . . . . \FV@CheckIfSaved . . . . . . . . . . . . .
. . . . . 326, 330, 335, 345, 350, 381 330 345 350 335 . . . . . . . . . 1199, 1204, 1206, 1208

\FV@CheckScan . . . . . . . . 374, 375, 402 \FV@CodeLineNo . . . . . . . . . . . . . . .


. . . . . . 187, 189, 210, 238, 245, 447, 1031, 1095, 1096, 1117, 1118 \FV@Command . . . . . 77, 96, 755, 765, 1171, 1203, 1205, 1207, 1234, 1260, 1265, 1279, 1320, 1351, 1366 \FV@CommandChars . . . . . 145, 150, 152 \FV@CommentChar . . . . . . . . . . 153, 160 \FV@DefineCheckEnd . . . . . . . 289, 327 \FV@DefineCommandChars . . . 147, 149 \FV@DefineFindStart . . 195, 198, 199 \FV@DefineFindStop 202, 211, 223, 227 \FV@DefinePreProcessLine . . . . . . 196 \FV@DefineTabOut . . . . . . . 1217, 1227 \FV@DefineWhiteSpace . . . . . . . . . . . . . . . . . . . . 450, 545, 1215, 1338 \FV@eha 35, 277, 416, 561, 849, 1023, 1075, 1201, 1263, 1284, 1303, 1370 \FV@EndList . . . . . . . . . . 724, 748, 758 \FV@EndListFrame . . . . . . . . . . . . . . 726, 771, 776, 781, 786, 791, 807 \FV@EndListFrame@Lines 781, 791, 931 \FV@EndListFrame@Single . . . 776, 985 \FV@EndScanning . . . . . . 384, 397, 410 \FV@EndVBox . . . . . . . 1146, 1151, 1195 \FV@Environment . . . . . . . . . . . . . . . 99, 111, 112, 114, 116, 1173, 1210 \FV@EnvironName . . . . . . . . . . 292, 293, 371, 382, 395, 398, 399, 405 \FV@EOF . . . . . . . . . . . . . . 402, 403, 404 \FV@EOL . . . . . . . . . . . . . . . . . . . . . . 1242, 1247, 1249, 1277, 1349, 1363

70

241, 242, 259, 260, 412, 414, 415, 417, 425, 429, 437, 438 \FV@Input . . . . . . . 413, 756, 766, 1172 \FV@InterLinePenalty . . . . . 620, 633 \FV@KeyValues . . . . . . . . 79, 80, 86, 100, 119, 121, 122, 1292, 1294, 1329 \FV@Label . . . . . . . . 827, 873, 875, 877 \FV@Label@i . . . . . . . . . . . . . . 834, 836 \FV@Label@ii . . . . . . . . . . . . . 836, 837 \FV@LabelBegin 831, 840, 842, 873, 883 \FV@LabelEnd . . . . . 832, 845, 875, 885 \FV@LabelPosition . . . . . . . . . . . . 847 \FV@LabelPosition@all . . . . . . . . 860 \FV@LabelPosition@bottomline . . 857 \FV@LabelPosition@none . . . . . . . 851 \FV@LabelPosition@topline . . . . . 854 \FV@LabelPositionBottomLine . . . . . . . . 843, 853, 856, 859, 862, 899 \FV@LabelPositionTopLine . . . . . . . . . . . . . . . 852, 855, 858, 861, 893 \FV@LeaveVMode . . . . . . . . . . . 627, 639 \FV@LeftListFrame . . . . . . . . . . . . . 697, 769, 774, 779, 784, 789, 805 \FV@LeftListFrame@Single . . . . . . . . . . . . . . . . . . . . . . 774, 805, 963 \FV@LeftListNumber . . . . . . . . . . . . 696, 1078, 1080, 1088, 1094, 1114 \FV@Line 194, 217, 252, 268, 270, 386, 423, 426, 442, 443, 1063, 1105, 1127 \FV@List . . . . . . . . . . . . . 624, 747, 757 \FV@ListNesting . . . . . . . . . . 629, 646 \FV@ListParameterHook . . . . 614, 630 \FV@ListProcessLastLine . . . 725, 730 \FV@ListProcessLine . . . . . . . . . . . . . . . . . . . 692, 710, 713, 718, 723 \FV@ListProcessLine@i 634, 705, 741 \FV@ListProcessLine@ii . . . 711, 712 \FV@ListProcessLine@iii 714, 715, 735 \FV@ListProcessLine@iv 719, 720, 731 \FV@ListVSpace . . . . . . . . . . . 631, 662 \FV@LUseVerbatim . . . . 762, 766, 1206 \FV@LVerbatimBegin . . . 757, 759, 763 \FV@LVerbatimEnd . . . . . 758, 760, 763 \FV@MakeActive . . . . . . . 507, 516, 522 \FV@MakeUnActive 509, 510, 512, 1341 \FV@None . 74, 144, 155, 830, 1004, 1011 \FV@Numbers@left . . . . . . . . . . . . 1086 \FV@Numbers@none . . . . . . . . . . . . 1077 \FV@Numbers@right . . . . . . . . . . . 1112

\FV@InFile

\FV@NumberSep . . . . . . . 1089, 1101,


1103, 1107, 1123, 1125, 1129, 1135

\FV@ObeyTabs . . . . . . . . . 582, 585, 605 \FV@ObeyTabsInit 596, 637, 1145, 1181 \FV@ObeyTabSize . . . . . . . . . . 578, 588 \FV@OutFile . . . 1209, 1218, 1219, 1225 \FV@ParseStart . . . . . . . . . . . 163, 164 \FV@ParseStop . . . . . . . . . . . . 175, 176 \FV@PreProcessLine 188, 387, 427, 431 \FV@ProcessLine . . . . . . 194, 634,
711, 714, 719, 731, 735, 741, 743, 1143, 1179, 1185, 1187, 1218 \FV@ReadLine . . . . . . . . . 424, 434, 444 \FV@refstepcounter 1050, 1061, 1065 \FV@RightListFrame . . . . . . . 700, 701, 770, 775, 780, 785, 790, 806 \FV@RightListFrame@Single . 775, 975 \FV@RightListNumber . . . . . . . . . . . . . . . . . . . . 702, 1081, 1092, 1116 \FV@SavedKeyValues . . . . . 1329, 1344 \FV@Scan 286, 749, 759, 1167, 1189, 1224 \FV@SetLineNo . . . . . . . . . . 1027, 1058 \FV@SetLineWidth . . . . . . . . . 632, 682 \FV@SetupFont . . . . . . . . . . . . 449, 454 \FV@SingleFrameLine 821, 822, 865, 921, 923, 924, 936, 937, 990, 991 \FV@SingleFrameSep . . . 825, 940, 987 \FV@Space . . . . . . . 545, 552, 1216, 1339 \FV@StepLineNo . . . . . . . . . . 192, 1057 \FV@StepNumber . . . . . . . . . . . . . . . 10821084, 1097, 1098, 1119, 1120 \FV@Tab 545, 557, 583, 1228, 1231, 1340 \FV@TabBox . . . . 575, 584, 589, 593595 \FV@TabChar . . . . . . . . . . 557, 565, 595 \FV@TheVerbatim . . . . . . . . . . . . . . . . . . 1184, 11861188, 1192, 1194 \FV@TrueTab . . . . . . . . . . . . . . 583, 586 \FV@UndefineShortVerb . . 1304, 1305 \FV@UseKeyValues . . . . . . . . . . . . . . . . . . . . 118, 626, 1141, 1177, 1214, 1240, 1259, 1270, 1330, 1357 \FV@UseVerb . . . 1259, 1264, 1373, 1376 \FV@UseVerbatim . . . . . 752, 756, 1204 \FV@VerbatimBegin . . . . 747, 749, 753 \FV@VerbatimEnd . . . . . . 748, 750, 753 \FV@XLeftMargin . . . . . . . . . . 606, 686 \FV@XRightMargin . . . . . . . . . 608, 687 \FVB@BVerbatim . . . . . . . . . . . . . . 1167 \FVB@LVerbatim . . . . . . . . . . . . . . . 759 \FVB@SaveVerbatim . . . . . . . . . . . 1174

71

\FVB@Verbatim . . . . . . . . . . . . . . . . 749 \FVB@VerbatimOut . . . . . . . . . . . . 1211 \FVC@@DefineShortVerb . . 1282, 1285 \FVC@BUseVerbatim . . . . . . . . . . . 1208 \FVC@BVerbatimInput . . . . . . . . . 1172 \FVC@DefineShortVerb . . . . . . . . 1280 \FVC@LUseVerbatim . . . . . . . . . . . 1206 \FVC@LVerbatimInput . . . . . . . . . . 766 \FVC@pUseMVerb . . . . . . . . . . . . . . 1367 \FVC@SaveGVerb . . . . . . . . . . . . . . 1352 \FVC@SaveMVerb . . . . . . . . . . . . . . 1321 \FVC@SaveVerb . . . . . . . . . . . . . . . 1235 \FVC@UseVerb . . . . . . . . . . . . . . . . 1261 \FVC@UseVerbatim . . . . . . . . . . . . 1204 \FVC@Verb . . . . . . . . . . . . . . 1266, 1296 \FVC@VerbatimInput . . . . . . . . . . . 756 \FVE@BVerbatim . . . . . . . . . . . . . . 1168 \FVE@LVerbatim . . . . . . . . . . . . . . . 760 \FVE@SaveVerbatim . . . . . . . . . . . 1190 \FVE@Verbatim . . . . . . . . . . . . . . . . 750 \FVE@VerbatimOut . . . . . . . . . . . . 1225 \fvset . . . . . . . . . . . . . . . . . . . . . . . 76
I

lrbox (environment) . . . . . . . . . . . . . 68 \LUseVerbatim . . . . . . . . . . . . . . . 1205 LVerbatim (environment) . . . . . . . . . 50 \LVerbatimInput . . . . . . . . . . . . . . 765


P

\pUseMVerb . . . . . . . . . . . . . . . . . . 1366
R

\RecustomVerbatimCommand . . . . . . 98 \RecustomVerbatimEnvironment . . 106


S

\SaveGVerb . . . . . . . . . . . . . 1344, 1351 \SaveMVerb . . . . . . . . . . . . . . . . . . 1320 \SaveVerb . . . . . . . . . . . . . . 1234, 1254 \SaveVerbatim . . . . . . . . . . . . . . . 1173 SaveVerbatim (environment) . . . . . . 62 \SaveVerbatim@Name 1183, 1192, 1194
T

\theFancyVerbLine . . . . . . . . . . . 1069
U

\if@FV@NumberBlankLines . . . . . . .
. . . . . . . . . 1046, 1060, 1102, 1124 \if@FV@ResetMargins . . . . . . . . . . 610 \InputIfFileExists . . . . . . . . . . 1394 K

\UndefineShortVerb . . . . . . . . . . \UseMVerb . . . . . . . . . . . . . . . . . . . \UseVerb . . . . . . . . . . . . . . . . . . . . \UseVerbatim . . . . . . . . . . . . . . . .


V

1300 1365 1260 1203

\KV@@booleankey . . . . . . . . . . . . 71, 72 \KV@booleankey . . . . . . . . . . . . . 69, 70 \KV@do . . . . . . . . . . . . . . . . . . . . . . . 121 \KV@FV@baselinestretch@default 488 \KV@FV@boxwidth@default . . . . . . 1160 \KV@FV@firstline@default . . . . . . 171 \KV@FV@fontsize@default . . . . . . . 480 \KV@FV@framerule@default . . . . . . 996 \KV@FV@framesep@default . . . . . . 1000 \KV@FV@gobble@default . . . . . . . . 284 \KV@FV@lastline@default . . . . . . . 183 \KV@FV@stepnumber@default . . . . 1084 \KV@prefix . . . . . . . . . . . . . . . . . . . 120

\V@@@footnotetext . . . . . . . . . . 62, 64 \V@@footnotetext . . . . . . . . . . . 46, 48 \V@footnote . . . . . . . . . . . . . . . . 40, 43 \V@footnotetext . . . . . . . . . 39, 42, 45 \Verb . . . . . . . . . . . . . . . . . . 1253, 1265 Verbatim (environment) . . . . . . . . . . 50 \VerbatimEnvironment . . . . . 288, 291 \VerbatimFootnotes . . . . . . . . . . . 36 \VerbatimInput . . . . . . . . . . . . . . . 755 \VerbatimOut . . . . . . . . . . . . . . . . 1210 VerbatimOut (environment) . . . . . . . 63

Change History
v2.0 Beta General: shown by Timothy First version personally
VAN

ZANDT . . . . 1

72

v2.5 General: First public release. . . . . . . 1 v2.6 General: . Three bug corrected, options numberblanklines, label, labelposition and leftline added and few precisions. . . . . . . . . . . . . . . 1 Add leftline value for the frame parameter (idea taken from a requirement of Christophe Roudet on June 9, 1998). . . . . . . . . . . . 51 Add the label and labelposition parameters (suggested by Michael Friendly on May 15, 1998). . . . . 52 Add the numberblanklines parameter to allow to dont number empty lines (suggested by Philippe Esperet on April 25, 1998). . . . . . . . . . . . . . . . . . . . 58 Correct a bug for the ligature in

T1 encoding (reported by Mario Hassler on May 12, 1998). . . . . . 39 Correct a bug to undene the macro associated to short verbatim character (reported by Mikhail Kolodin on June 12, 1998). . . . . . . . . . . . . . . . . . . . 66 Correct a bug which didnt allow to use the label macro in verbatim env. (reported by Philippe Esperet on May 20, 1998). . . . . . . . . . . . 58 v2.7 General: DG/SR changed how fancyvrb.cfg included . . . . . . . . . . . . 1 v2.7a General: rstline bug . . . . . . . . . . . . 1 v2.8 General: xed bug with several trailing spaces (hv) . . . . . . . . . . . . . . 1

73

You might also like