changeset 7:f66280e26337

add agda source conversion
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 05 Dec 2013 22:44:00 +0900
parents 442e62a339a6
children 4ba85665eda7
files agda-prog.ind agda2latex.pl fancyvrb.sty ipsj.tex
diffstat 4 files changed, 703 insertions(+), 392 deletions(-) [+]
line wrap: on
line diff
--- a/agda-prog.ind	Thu Dec 05 20:10:27 2013 +0900
+++ b/agda-prog.ind	Thu Dec 05 22:44:00 2013 +0900
@@ -123,40 +123,47 @@
 
 圏の定義は、
 
-   Definition 1.1. A concrete category is a collection of two kind of entities called object and morphisms.
-   The former are sets which are endowed with some kind of structure, and the latte are mappings, tha is functions from
-   one object to another, in some sencse preserving that structure. Among the morphisms, there is atteched to each
-   object A the identity mapping 1_A: A -> A such aht 1_A(a) = a for all a ∈ A.  More over, morphims f : A -> B 
-   and g : b-> C may be compoosed to prodicue a morphism gf: a -> C such hat (gf)a() = g(f(a) for all a ∈ A.
+{\tiny
+Definition 1.1. A concrete category is a collection of two kind of entities called object and morphisms.
+The former are sets which are endowed with some kind of structure, and the latte are mappings, tha is functions from
+one object to another, in some sencse preserving that structure. Among the morphisms, there is atteched to each
+object A the identity mapping $1_A$: A → A such aht $1_A$(a) = a for all a ∈ A.  More over, morphims f : A → B 
+and g : b→ c may be compoosed to prodicue a morphism gf: a → c such hat (gf)a() = g(f(a) for all a ∈ A.
+}
 
 関手の定義は、
 
-   Definition 1.3. A cuntor F: A->B is first of all a morphism of graph, that is, it sends objects of A to
-   object so B and arrows of A to arrows of B such that, if f: A->A' then F(f):F(A)->F(A'). Moreover
-   functor preserves identities and compisition; thus
-      F(1_A) = 1_F(A), F(gf) = F(g)F(f)
+{\tiny
+Definition 1.3. A cuntor F: A→B is first of all a morphism of graph, that is, it sends objects of A to
+object so B and arrows of A to arrows of B such that, if f: A→A' then F(f):F(A)→F(A'). Moreover
+functor preserves identities and compisition; thus
+}
+
+$ F(1_A) = 1_F(A), F(gf) = F(g)F(f)   $
 
 自然変換の定義は、
 
-    Definition 2.1. Given functors F,G: A -> B, a natural transformatin t: F -> G is a familty of
-    arrows t(A): F(A) -> G(A) in B, one arrow for each object A of A, suc that the following
-    square commutes for all arrows f: A -> in A.
-
-    that is to say, such that
+{\tiny
+Definition 2.1. Given functors F,G: A → B, a natural transformatin t: F → G is a familty of
+arrows t(A): F(A) → G(A) in B, one arrow for each object A of A, suc that the following
+square commutes for all arrows f: A → in A.  that is to say, such that
+}
 
        G(f)t(a) = t(B)F(f).
 
 と書かれている。さらに、Monad は関手Tと二つの自然変換の組であり以下のように定義されている。
 
-    Definition 6.1 A triple(T,η,μ) on a category A consists of a functor T: A->A and natural transformation η: 1_A -> T
-    and μ:T^2 -> T satifying the equation
+{tiny
+Definition 6.1 A triple(T,η,μ) on a category A consists of a functor T: A→A and natural transformation η: $1_A$ → T
+and μ:$T^2$ → T satifying the equation
+}
 
-      μ○Tη = 1_T = μ○ηT, μ○μT = μ○Tμ
+      μoTη = 1_T = μoηT, μoμT = μoTμ   
 
 となっている。 ここで、関手Tと自然変換ηの 合成 Tηの定義は
 
-     (Tη)(A) = T(η(A))     \label{comp-of-func-nat}
-     (ηT)(A) = η(T(A))     \label{comp-of-nat-func}
+     (Tη)(A) = T(η(A)) 
+     (ηT)(A) = η(T(A)) 
 
 である。これらの英語は、大学初年度の数学の知識があれば読んで理解することが期待されている。この本の記述は、
 既に圏論を知っている人向けに書かれており、特に簡潔に書かれている。以下に示す Agda の定義は、これらの
@@ -164,7 +171,7 @@
 
 これらの定義から証明するべきなのは、join の結合性であり、join は以下のように記述される。
 
-    g * f =def μ(A'')T(g)f 
+    g * f =def μ(A)T(g)f 
 
 以上の定義に対して、
 
@@ -347,7 +354,7 @@
 a == a というデータ構造を返す。これは、a == a の証明に対応するλ式でもあって、Curry Haward 対応に
 相当する。
 
-これは、実際には、Relation.Binary.PropositionalEquality で \_≡\_  として定義されているので、自分で定義する必要はない。
+これは、実際には、Relation .Binary .PropositionalEquality で \_≡\_  として定義されているので、自分で定義する必要はない。
 
 data 型の他に record 型あり、この append の例題では使わないが、排他的和を表すデータ構造を提供し、圏や関手を定義することができる。
 
@@ -394,8 +401,8 @@
 
 となる。?0 の方は、\_++\_ の定義( [] ++ ys = ys )から ys ++ zs になる。これは、Emacs の ?0 上にカーソルを合わせて、
 
-    \ys zs -> [] ++ ys ++ zs
-    \ys zs -> [] ++ (ys ++ zs)
+    λys zs -> [] ++ ys ++ zs
+    λys zs -> [] ++ (ys ++ zs)
 
 を、それぞれ C-n ( normalize ) すると、両方、
 
@@ -466,7 +473,8 @@
 
 数式変形を使うと、この証明は以下のようになる。
 
-    ++-assoc : ∀{n} (L : Set n) ( xs ys zs : List L ) → (xs ++ ys) ++ zs  == xs ++ (ys ++ zs)
+    ++-assoc : ∀{n} (L : Set n) ( xs ys zs : List L ) → 
+        (xs ++ ys) ++ zs  == xs ++ (ys ++ zs)
     ++-assoc A [] ys zs = let open ==-Reasoning A in
       begin -- to prove ([] ++ ys) ++ zs  == [] ++ (ys ++ zs)                                                                                     
        ( [] ++ ys ) ++ zs
@@ -477,7 +485,7 @@

 
     ++-assoc A (x :: xs) ys zs = let open  ==-Reasoning A in
-      begin -- to prove ((x :: xs) ++ ys) ++ zs == (x :: xs) ++ (ys ++ zs)                                                                        
+      begin 
         ((x :: xs) ++ ys) ++ zs
       ==⟨⟩
          (x :: (xs ++ ys)) ++ zs
@@ -524,7 +532,8 @@
 
 これは List 専用の式変形を定義している。trans-list は、List での等式の三段論法になっている。これは、単一化で証明される。
 
-    trans-list :  ∀{n} {A : Set n} {x y z : List A}  → x ==  y → y == z → x == z
+    trans-list :  ∀{n} {A : Set n} {x y z : List A}  
+         → x ==  y → y == z → x == z
     trans-list reflection reflection = reflection
 
 relTo が、等しくなるべき等式を持っていて、証明の最後を示す \_∎ \_ が、三段論法で繋がったすべての等式が等しいことを要求する。
@@ -549,9 +558,11 @@
         isEquivalence : {A B : Obj} → IsEquivalence {c₂} {ℓ} {Hom A B} _≈_
         identityL : {A B : Obj} → {f : Hom A B} → (Id o f) ≈ f
         identityR : {A B : Obj} → {f : Hom A B} → (f o Id) ≈ f
-        o-resp-≈ : {A B C : Obj} {f g : Hom A B} {h i : Hom B C} → f ≈ g → h ≈ i → (h o f) ≈ (i o g)
-        associative : {A B C D : Obj} {f : Hom C D}  {g : Hom B C} {h : Hom A B}
-                                      → (f o (g o h)) ≈ ((f o g) o h)
+        o-resp-≈ : {A B C : Obj} {f g : Hom A B} {h i : Hom B C} 
+                → f ≈ g → h ≈ i → (h o f) ≈ (i o g)
+        associative : {A B C D : Obj} {f : Hom C D}  
+             {g : Hom B C} {h : Hom A B}
+             → (f o (g o h)) ≈ ((f o g) o h)
 
 ここでは、圏の要素がコンストラクタ IsCategory に列挙されている。そして、圏が満たす性質(公理)が field に列挙
 されている。
@@ -693,7 +704,7 @@
 
 Agda は実行することが目的の言語ではないので、デバッグはコンパイル時エラーに対してのみ行う。主なエラーは三種類である。
 
-最初は構文エラーである。Agda は、ほとんどの場合、語の区切りに空白を要求する。特に -> や =  : の両側に空白を要求する。
+最初は構文エラーである。Agda は、ほとんどの場合、語の区切りに空白を要求する。特に → や =  : の両側に空白を要求する。
 例外は () と {} のみである。空白がないと一つの語だと解釈される。x=y は x=y という一つの変数である。これは、式を
 変数に格納する時には読みやすい。また、さまざまなUnicodeの記号を自由に使えるという利点がある。しかし、実際には、
 構文エラーの大半は空白の入れ忘れである。
@@ -838,7 +849,7 @@
       ∎ where open ≈-Reasoning (A)
 
 ここで、assoc は射の合成の結合法則を使って、式を変形していることを示している。
-nat μ は、自然変換μの commute 規則を呼び出している。≈↑⟨⟩ は、逆向きの推論、≈⟨⟩ は正規型同士が
+nat μ は、自然変換μの commute 規則を呼び出している。≈↑⟨⟩ は、逆向きの推論、≈⟨⟩ は正規型どおしが
 同じ場合の見かけだけの変換である。 distr T は関手Tの分配法則である。car と cdr は、
 括弧のレベルの深い部分に推論規則を適用することを示す。
 begin/∎  の式変形は入れ子にすることができて、式の特定の部分に対して、着目して変形することできる。
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agda2latex.pl	Thu Dec 05 22:44:00 2013 +0900
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+
+while(<>) {
+
+    next if (/\{\\footnotesize/) ;
+    if (/\\begin{[Vv]erbatim}/) {
+        print "\n{\\tiny\\noindent\n";
+        while(<>) {
+           last if (/\\end{[Vv]erbatim}/) ;
+           next if (/^\s*$/) ;
+           chop;
+           s/\{/\\{/g;
+           s/\}/\\}/g;
+           my $pos = 0;
+           if (s/\s+//) {
+               $pos = length($&);
+               print "\\hspace{${pos}pt}";
+           }
+           s/_/\\_\\mbox{}/g;
+           s/<-/←/g;
+           s/->/→/g;
+           s/>/\\>\\mobox{}/g;
+           s/</\\<\\mobox{}/g;
+           print;
+           print "\\newline\n"; 
+        }
+        # print "}\n";
+        next;
+     } else {
+         print;
+     }
+}
--- a/fancyvrb.sty	Thu Dec 05 20:10:27 2013 +0900
+++ b/fancyvrb.sty	Thu Dec 05 22:44:00 2013 +0900
@@ -1,64 +1,66 @@
-%%
-%% This is file `fancyvrb.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
+%% BEGIN fancyvrb.sty
 %%
-%% fancyvrb.dtx  (with options: `fancyvrb')
-%% 
-%% IMPORTANT NOTICE:
-%% 
-%% For the copyright see the source file.
-%% 
-%% Any modified versions of this file must be renamed
-%% with new filenames distinct from fancyvrb.sty.
-%% 
-%% For distribution of the original source see the terms
-%% for copying and modification in the file fancyvrb.dtx.
-%% 
-%% This generated file may be distributed as long as the
-%% original source files, as listed above, are part of the
-%% same distribution. (The sources need not necessarily be
-%% in the same archive or directory.)
+\def\fileversion{2.0-beta, with DG/SPQR fixes}
+\def\filedate{1996/10/05}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{fancyvrb}[\filedate]
+% \usepackage[utf8]{inputenc}
+% \usepackage{autofe}
+
 %%
-%% Package `fancyvrb'
-%%
-%% Timothy Van Zandt <tvz@zandtwerk.kellogg.nwu.edu>
-%% July 17, 1998
-%%
-%% COPYRIGHT 1992-1999, by Timothy Van Zandt <tvz@zandtwerk.kellogg.nwu.edu>
-%%
-%% This package may be distributed under the terms of the LaTeX Project Public
-%% License, as described in lppl.txt in the base LaTeX distribution.
-%% Either version 1.0 or, at your option, any later version.
+%% COPYRIGHT 1992-1994, by Timothy Van Zandt, tvz@Princeton.EDU
 %%
 %% DESCRIPTION:
 %%   fancyvrb.sty is a LaTeX style option, containing flexible
 %%   verbatim environments and commands and extensive documentation.
 %%
-%%   This is a companion to the `fancybox' package.
+%%   This is a companion to fancybox.sty, which is probably available
+%%   from whereever you found fancyvrb.sty.
+%%
+%% INSTALLATION:
+%%   Put this file where your TeX looks for inputs.
+%%
+%% DOCUMENTATION:
+%%   See fancybox.doc, which might be appended to this file.
 %%
-\NeedsTeXFormat{LaTeX2e}
-\def\fileversion{2.6, with DG/SPQR fixes}
-\def\filedate{1998/07/17}
-\ProvidesPackage{fancyvrb}[\filedate]
-\message{Style option: `fancyvrb' v\fileversion \space  <\filedate> (tvz)}
+%% COPYING:
+%%   Copying of part or all of this file is allowed under the following
+%%   conditions only:
+%%   (1) You may freely distribute unchanged copies of the file. Please
+%%       include the documentation when you do so.
+%%   (2) You may modify a renamed copy of the file, but only for personal
+%%       use or use within an organization.
+%%   (3) You may copy fragments from the file, for personal use or for
+%%       distribution, as long as credit is given where credit is due.
+%%
+%%   You are NOT ALLOWED to take money for the distribution or use of
+%%   this file or modified versions or fragments thereof, except for
+%%   a nominal charge for copying etc.
+%%
+%% CODE:
+
 \csname fancyvrb@loaded\endcsname
 \let\fancyvrb@loaded\endinput
+
+\typeout{Style option: `fancyvrb' v\fileversion \space  <\filedate> (tvz)}
+
+%% ERRORS:
+
 \def\FV@Error#1#2{%
   \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
   \errmessage{FancyVerb Error:^^J\space\space #1^^J}}
 
 \def\FV@eha{Your command was ignored. Type <return> to continue.}
-%% DG/SR modification begin - Jan. 21, 1998
-%% Suggested by Bernard Gaulle to solve a compatibility problem with `french'
-%% (it introduce the restriction to put \VerbatimFootnotes AFTER the preambule)
-%%\def\VerbatimFootnotes{\let\@footnotetext\V@footnotetext}
-\let\V@footnote\footnote
-\def\VerbatimFootnotes{%
-\let\@footnotetext\V@footnotetext%
-\let\footnote\V@footnote}
-%% DG/SR modification end
+
+%% VERBATIM FOOTNOTES:
+
+% Color has to be protected.
+% Won't work for some definitions of \@makefntext.
+% If it weren't for \@makefntext, I would do this properly by
+% defining a footnote environment.
+
+\def\VerbatimFootnotes{\let\@footnotetext\V@footnotetext}
+
 \long\def\V@footnotetext{%
   \afterassignment\V@@footnotetext
   \let\@tempa}
@@ -79,7 +81,19 @@
   \aftergroup\V@@@footnotetext
   \ignorespaces}
 \def\V@@@footnotetext{\strut\egroup}
+
+%% KEY=VALUE:
+
 \RequirePackage{keyval}
+
+% Extensions to keyval.sty:
+
+% \define@booleankey{<family>}{<key>}{<iftrue>}{<iffalse>}
+%
+% Defines a <key> for <family> that executes:
+%   <iftrue> clause when value begins with `t' or `T', or is omitted.
+%   <iffalse> clause otherwise.
+
 \def\define@booleankey#1#2#3#4{%
   \@namedef{KV@#1@#2@default}{#3}%
   \@namedef{KV@#1@#2@false}{#4}%
@@ -88,9 +102,23 @@
   \edef\@tempa{#1}\expandafter\KV@@booleankey\@tempa\relax\@nil{#2}{#3}}
 \def\KV@@booleankey#1#2\@nil#3#4{%
   \@nameuse{KV@#3@#4@\if t#1default\else\if T#1default\else false\fi\fi}}
+
 \def\FV@None{none}
 \def\FV@Auto{auto}
+
 \def\fvset#1{\setkeys{FV}{#1}}
+
+% \FV@Command is for verbatim commands. Example:
+%
+%   \def\VerbatimInput{\FV@Command{}{VerbatimInput}}
+%
+% \FV@Command{<key=value>}{<name>}:
+%
+%   1. Defines \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>.
+
 \def\FV@Command#1#2{%
   \@ifstar
     {\def\FV@KeyValues{#1,showspaces}\FV@@Command{#2}}%
@@ -99,63 +127,119 @@
   \@ifnextchar[%
     {\FV@GetKeyValues{\@nameuse{FVC@#1}}}%
     {\@nameuse{FVC@#1}}}
+
 \def\FV@GetKeyValues#1[#2]{%
   \expandafter\def\expandafter\FV@KeyValues\expandafter{\FV@KeyValues,#2}#1}
+
 \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
-%%  \def\@tempa##1##2\@nil{\def\@tempa{##2}}%
-%%  \expandafter\@tempa\string#3\@empty\@nil
-%%  \@ifundefined{FVC@\@tempa}%
-  \@ifundefined{FVC@#3}%
-%% DG/SR modification end
+  \def\@tempa##1##2\@nil{\def\@tempa{##2}}%
+  \expandafter\@tempa\string#3\@empty\@nil
+  \@ifundefined{FVC@\@tempa}%
     {\FV@Error{Command `\string#3' is not a FancyVerb command.}\@eha}%
     {#1{#2}{\FV@Command{#4}{#3}}}}
+
 \def\CustomVerbatimCommand{\@CustomVerbatimCommand\newcommand}
 \def\RecustomVerbatimCommand{\@CustomVerbatimCommand\renewcommand}
+
+% \FV@Environment is for verbatim enviroments. Example:
+%
+%          \def\Verbatim{\FV@Environment{}{Verbatim}}
+%          \@namedef{Verbatim*}{\FV@Environment{showspaces}{Verbatim}}
+%
+% \FV@Environment{<key=value>}{<name>}:
+%
+%   1. Defines \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 `['.
+
 \def\FV@Environment#1#2{%
   \def\FV@KeyValues{#1}%
   \catcode`\^^M=\active
   \@ifnextchar[%
     {\catcode`\^^M=5 \FV@GetKeyValues{\@nameuse{FVB@#2}}}%
     {\catcode`\^^M=5 \@nameuse{FVB@#2}}}
+
 \def\CustomVerbatimEnvironment{\@CustomVerbatimEnvironment\newenvironment}
 \def\RecustomVerbatimEnvironment{\@CustomVerbatimEnvironment\renewenvironment}
+
 \def\@CustomVerbatimEnvironment#1#2#3#4{%
   \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}}}}
+
 \def\DefineVerbatimEnvironment#1#2#3{%
   \@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.
+
 \def\FV@UseKeyValues{%
   \ifx\FV@KeyValues\@empty\else
     \def\KV@prefix{KV@FV@}%
     \expandafter\KV@do\FV@KeyValues,\relax,%
     \def\FV@KeyValues{}%
   \fi}
+
+%% SCANNING:
+%
+% Scanning macros
+%   - read a line at a time from an environment or a file,
+%   - save the line in \FV@Line, and
+%   - execute \FV@PreProcessLine.
+%
+% \FV@PreProcessLine
+%   - Determines whether line is in a user-specified ranges, and if so,
+%   - Strips the line of a user-specified no. of tokens, and
+%   - executes \FV@ProcessLine{<line>}.
+%
+% Two things are common to scanning an environment or reading a file:
+%  \FV@CatCodes              --> Change \catcode's.
+%  \FV@PreProcessLine        --> See above.
+
+%% CODES:
+
 \def\FV@CatCodes{%
-  \let\do\@makeother\dospecials  % The usual stuff.
+  \let\do\@makeother\dospecials 
   \FV@ActiveWhiteSpace           % See below.
   \FV@FontScanPrep               % See below.
   \FV@CatCodesHook               % A style hook.
-  \FancyVerbCodes}               % A user-defined hook.
+  \FancyVerbCodes
+}               % A user-defined hook.
+
 \def\FV@ActiveWhiteSpace{%
   \catcode`\^^M=\active          % End of line
   \catcode`\ =\active            % Space
   \catcode`\^^I=\active}         % Tab
+
+% CM Ligatures:
+%   Left-quote: `` !` ?`
+%   Letter f:   ff fi fl ffi ffl
+%   Hyphen:     -- ---
+
 \def\FV@CatCodesHook{}
+
 \def\FV@AddToHook#1#2{%
   \expandafter\def\expandafter#1\expandafter{#1#2\relax}}
+
 \define@key{FV}{codes}[]{\def\FancyVerbCodes{#1\relax}}
 \define@key{FV}{codes*}{%
   \expandafter\def\expandafter\FancyVerbCodes\expandafter{%
     \FancyVerbCodes#1\relax}}
 \fvset{codes}
+
 \define@key{FV}{commandchars}[\\\{\}]%
   {\def\@tempa{#1}%
     \ifx\@tempa\FV@None
@@ -163,10 +247,13 @@
     \else
       \FV@DefineCommandChars#1\relax\relax\relax
     \fi}
+
 \def\FV@DefineCommandChars#1#2#3{%
   \def\FV@CommandChars{%
     \catcode`#1=0\relax\catcode`#2=1\relax\catcode`#3=2\relax}}
+
 \FV@AddToHook\FV@CatCodesHook\FV@CommandChars
+
 \define@key{FV}{commentchar}[\%]{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@None
@@ -174,8 +261,20 @@
   \else
     \def\FV@CommentChar{\catcode`#1=14}%
   \fi}
+
 \FV@AddToHook\FV@CatCodesHook\FV@CommentChar
+
 \fvset{commandchars=none,commentchar=none}
+
+%% PREPROCESS LINE:
+
+% These is tedious and takes up macro space, but it doesn't 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.
+
 \define@key{FV}{firstline}{%
   \afterassignment\FV@ParseStart\@tempcnta=0#1\relax\@nil{#1}}
 \def\FV@ParseStart#1\relax\@nil#2{%
@@ -188,6 +287,7 @@
 \def\KV@FV@firstline@default{%
   \let\FancyVerbStartNum\z@
   \let\FancyVerbStartString\relax}
+
 \define@key{FV}{lastline}{%
   \afterassignment\FV@ParseStop\@tempcnta=0#1\relax\@nil{#1}}
 \def\FV@ParseStop#1\relax\@nil#2{%
@@ -200,19 +300,32 @@
 \def\KV@FV@lastline@default{%
   \let\FancyVerbStopNum\z@
   \let\FancyVerbStopString\relax}
+
 \fvset{firstline,lastline}
+
 \newcount\FV@CodeLineNo
+
+% If \FV@FindStartStop determines the line should be printed, it
+% executes \FV@@PreProcessLine
+
 \def\FV@PreProcessLine{%
   \global\advance\FV@CodeLineNo\@ne
   \FV@FindStartStop}
+
 \def\FV@@PreProcessLine{%
   \FV@StepLineNo
   \FV@Gobble
   \expandafter\FV@ProcessLine\expandafter{\FV@Line}}
+
+% The definition of \FV@FindStartStop changes, so that we don't
+% have to check irrelevant conditions with each line.
+
 \def\FV@FindStartStop{\FV@DefineFindStart\FV@FindStartStop}
-%% \def\FV@DefinePreProcessLine{%
-%%   \setcounter{FancyVerbLine}{0}%
-%%   \FV@DefineFindStart}
+
+% \def\FV@DefinePreProcessLine{%
+%   \setcounter{FancyVerbLine}{0}%
+%   \FV@DefineFindStart}
+
 \def\FV@DefineFindStart{%
   \ifx\FancyVerbStartString\relax
     \ifnum\FancyVerbStartNum<\tw@
@@ -223,24 +336,25 @@
   \else
     \let\FV@FindStartStop\FV@FindStartString
   \fi}
+
 \def\FV@FindStartNum{%
   \ifnum\FancyVerbStartNum>\FV@CodeLineNo\else
     \FV@DefineFindStop
     \expandafter\FV@@PreProcessLine
   \fi}
-%% SR modification begin - 1996
+
 \def\FV@FindStartString{%
  \expandafter\FV@@FindStartString
 {\meaning\FV@Line}%
 {\meaning\FancyVerbStartString}%
 }
 \def\FV@@FindStartString#1#2{%
-\edef\@fooA{#1}\edef\@fooB{#2}%
+\edef\@fooA{#1}\edef\@fooB{#2}
   \ifx\@fooA\@fooB
     \FV@DefineFindStop
   \fi
 }
-%% SR modification end
+
 \def\FV@DefineFindStop{%
   \ifx\FancyVerbStopString\relax
     \ifnum\FancyVerbStopNum<\@ne
@@ -251,6 +365,7 @@
   \else
     \let\FV@FindStartStop\FV@FindStopString
   \fi}
+
 \def\FV@FindStopNum{%
   \ifnum\FancyVerbStopNum=\FV@CodeLineNo
     \let\FV@FindStartStop\relax
@@ -259,14 +374,14 @@
     \fi
   \fi
   \FV@@PreProcessLine}
-%% SR modification begin - 1996
+
 \def\FV@FindStopString{%
  \expandafter\FV@@FindStopString
 {\meaning\FV@Line}%
 {\meaning\FancyVerbStopString}%
 }
 \def\FV@@FindStopString#1#2{%
-\edef\@fooA{#1}\edef\@fooB{#2}%
+\edef\@fooA{#1}\edef\@fooB{#2}
   \ifx\@fooA\@fooB
     \let\FV@FindStartStop\relax
     \ifeof\FV@InFile\else
@@ -275,12 +390,19 @@
   \else
     \expandafter\FV@@PreProcessLine
   \fi}
-%% SR modification end
+
+% Gobblings. \FV@Gobble does nothing, or strips some tokens from
+% the line and stores the result in \FV@Line again. We use
+% \LaTeX's renewcommand to define a command for gobbling up to
+% 9 arguments. This is not the same as removing 9 tokens, but is
+% easier.
+
 \def\FV@@Gobble{%
   \expandafter\expandafter\expandafter\FV@@@Gobble
   \expandafter\FV@@@@Gobble\FV@Line
     \@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@nil\@@nil}
 \def\FV@@@Gobble#1\@nil#2\@@nil{\def\FV@Line{#1}}
+
 \define@key{FV}{gobble}{%
   \@tempcnta=#1\relax
   \ifnum\@tempcnta<\@ne
@@ -295,39 +417,95 @@
   \fi}
 \def\FV@@@@Gobble{}
 \def\KV@FV@gobble@default{\let\FV@Gobble\relax}
+
 \fvset{gobble}
+
+%% SCANNING ENVIRONMENTS:
+
 \def\FV@Scan{%
     \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 defined.
+% Then \FV@CheckEnd knows how to find the end as long as either:
+%  * \begin and \end are not used within the definition of the environment, OR
+%  * \VerbatimEnvironment is used in the definition before the first \begin.
+
 \def\VerbatimEnvironment{%
   \ifx\FV@EnvironName\relax\xdef\FV@EnvironName{\@currenvir}\fi}
+
 \let\FV@EnvironName\relax
+
+%% CHECK END:
+%
+% We have to check the argument of the first \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 definitions.
+%
+% We first set the catcodes of \{} to those in effect in the
+% verbatim environment. Then we define:
+%
+%   !def!FV@CheckEnd#1[!FV@@CheckEnd#1\end{}!@nil]
+%
+% If {} have their usual catcodes, we define:
+%
+%   !def!FV@@CheckEnd#1\end#2#3!@nil[!def!@tempa[#2]]
+%
+% If {} have catcode 12, we define:
+%
+%   !def!FV@@CheckEnd#1\end{#2}#3!@nil[!def!@tempa[#2]]
+
 \begingroup
 \catcode`\!=0
 \catcode`\[=1
 \catcode`\]=2
+
+% Case i:
+
 !gdef!FV@CheckEnd@i#1[!FV@@CheckEnd#1\end{}!@nil]
 !gdef!FV@@CheckEnd@i#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
 !gdef!FV@@@CheckEnd@i[\end{}]
+
+% Case ii:
+
 \catcode`!\=12
 
 !gdef!FV@CheckEnd@ii#1[!FV@@CheckEnd#1\end{}!@nil]
 !gdef!FV@@CheckEnd@ii#1\end#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
 !gdef!FV@@@CheckEnd@ii[\end{}]
+
+% Case iii:
+
 !catcode`!{=12
 !catcode`!}=12
 
 !gdef!FV@CheckEnd@iii#1[!FV@@CheckEnd#1\end{}!@nil]
 !gdef!FV@@CheckEnd@iii#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
 !gdef!FV@@@CheckEnd@iii[\end{}]
+
+% Case iv:
+
 !catcode`!\=0
 
 !gdef!FV@CheckEnd@iv#1[!FV@@CheckEnd#1\end{}!@nil]
 !gdef!FV@@CheckEnd@iv#1\end{#2}#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
 !gdef!FV@@@CheckEnd@iv[\end{}]
+
 \endgroup
+
 \def\FV@BadCodes#1{%
   \FV@Error
     {\string\catcode\space of \expandafter\@gobble\string#1 is wrong:
@@ -337,6 +515,7 @@
     ^^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}}
+
 \def\FV@DefineCheckEnd{%
   \ifnum\catcode`\\=\z@
     \ifnum\catcode`\{=\@ne
@@ -371,22 +550,31 @@
       \FV@BadCodes\\%
     \fi
   \fi}
+
+%% LINE-BY-LINE SCANNING
+
+% We first skip everything after the beginning of the environment.
+
 \begingroup
 \catcode`\^^M=\active
   \gdef\FV@BeginScanning#1^^M{%
-    \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi%
+    \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi
     \FV@GetLine}%
 \endgroup
+
 \def\FV@BadBeginError#1{%
   \expandafter\@temptokena\expandafter{\@tempa}%
   \FV@Error
     {Extraneous input `\the\@temptokena' between
       \string\begin{\FV@EnvironName}[<key=value>] and line end}%
    {This input will be discarded. Hit <return> to continue.}}
-%% DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures)
-%% \def\FV@GetLine{\expandafter\FV@CheckScan\FancyVerbGetLine}
-\def\FV@GetLine{\@noligs\expandafter\FV@CheckScan\FancyVerbGetLine}
-%% DG/SR modification end
+
+% If \FancyVerbGetLine does not find a ^^M, then we are at
+% the end of the file, and \FV@EOF attempts to terminate the document.
+% Otherwise, \FV@EOF is gobbled by \FancyVerbGetLine.
+
+\def\FV@GetLine{\expandafter\FV@CheckScan\FancyVerbGetLine}
+
 \begingroup
 \catcode`\^^M=\active
 \gdef\FancyVerbGetLine#1^^M{%
@@ -401,19 +589,24 @@
   \fi%
   \next}%
 \endgroup
+
 \def\FV@BadEndError{%
   \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.}}
+
 \def\FV@EndScanning{%
   \edef\next{\noexpand\end{\FV@EnvironName}}%
   \global\let\FV@EnvironName\relax
   \next}
+
 \@ifundefined{@currenvline}{\let\@currenvline\@empty}{}
+
 \def\FV@CheckScan#1{\@ifnextchar\@nil{\@gobble}{\FV@EOF}}
 \def\FV@CheckScan#1{\ifx\@nil#1\@empty\else\expandafter\FV@EOF\fi}
+
 \def\FV@EOF{%
   \FV@Error{Couldn't find `\string\end{\FV@EnvironName}' to end
     a verbatim environment\@currenvline.}%
@@ -422,8 +615,11 @@
     ^^JHit return and I will try to terminate this job.}%
   \FV@EndScanning
   \end{document}}
-                                % \subsection{Input}
+
+%% INPUT:
+
 \newread\FV@InFile
+
 \def\FV@Input#1{%
   \immediate\openin\FV@InFile #1\relax
   \ifeof\FV@InFile
@@ -433,6 +629,13 @@
     \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 file (file ends nl).
+%   Otherwise, InLine holds last line in file (file doesn't end in nl).
+% \FV@@Input handles both cases correctly.
+
 \def\FV@@Input{%
   \def\FV@Line{}%
   \FV@ReadLine
@@ -445,6 +648,11 @@
     \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 find a ^^M (indicating that
+% the line did not contain a comment character).
+
 \begingroup
 \catcode`\^^M=\active
 \gdef\FV@ReadLine{%
@@ -452,11 +660,17 @@
     \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
 \gdef\FV@@ReadLine#1^^M#2^^M#3\@nil{%
   \expandafter\def\expandafter\FV@Line\expandafter{%
     \FV@Line#1}%
   \ifx\relax#2\@empty\expandafter\FV@ReadLine\fi}%
 \endgroup
+
+%% FORMATTING - COMMON COMPONENTS:
+
+% Some things that are common to all verbatim formatting:
+
 \def\FV@FormattingPrep{%
   \global\FV@CodeLineNo\z@
   \frenchspacing             % Cancels special punctuation spacing.
@@ -464,12 +678,17 @@
   \FV@DefineWhiteSpace       % See below.
   \FancyVerbDefineActive
   \FancyVerbFormatCom}       % A user-defined hook (formatcom parameter).
+
+% Fonts
+
 \expandafter\ifx\csname selectfont\endcsname\relax
+
 \def\FV@SetupFont{%
   \FV@BaseLineStretch
   \ifx\@currsize\small\normalsize\else\small\fi\@currsize
   \FV@FontSize
-  \FV@FontFamily}
+  \FV@FontFamily  
+}
 
 \else
 
@@ -479,11 +698,13 @@
   \FV@FontFamily
   \FV@FontSeries
   \FV@FontShape
-  \selectfont
-%% DG/SR modification begin - May. 18, 1998 (added code to turn off ligatures)
-  \@noligs}
-%% DG/SR modification end
+%
+% SPQR Jan 29 1996; added code to turn off ligatures 
+%
+  \selectfont\let\do\do@noligs\verbatim@nolig@list}
+
 \fi
+
 \define@key{FV}{fontsize}{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@Auto
@@ -492,6 +713,7 @@
     \def\FV@FontSize{#1}%
   \fi}
 \def\KV@FV@fontsize@default{\let\FV@FontSize\relax}
+
 \define@key{FV}{baselinestretch}[auto]{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@Auto
@@ -500,10 +722,12 @@
     \def\FV@BaseLineStretch{\def\baselinestretch{#1}}%
   \fi}
 \def\KV@FV@baselinestretch@default{\let\FV@BaseLineStretch\relax}
+
 \define@key{FV}{fontfamily}{%
   \@ifundefined{FV@fontfamily@#1}%
     {\def\FV@FontScanPrep{}\def\FV@FontFamily{\fontfamily{#1}}}
     {\csname FV@fontfamily@#1\endcsname}}
+
 \define@key{FV}{fontseries}{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@Auto
@@ -511,6 +735,7 @@
   \else
     \def\FV@FontSeries{\fontseries{#1}}%
   \fi}
+
 \define@key{FV}{fontshape}{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@Auto
@@ -518,57 +743,75 @@
   \else
     \def\FV@FontShape{\fontshape{#1}}%
   \fi}
+
+% Font family styles have to define \FV@FontScanPrep and \FV@FontFamily.
+
 \def\FV@MakeActive#1{%
   \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}
 \def\FV@MakeUnActive{}
+
 \begingroup
 \catcode`\`=\active
 \gdef\FV@fontfamily@tt{%
   \def\FV@FontScanPrep{\FV@MakeActive\`}%
-%% SR modification begin - 1995
-%%  \def\FV@FontFamily{\tt`{{\string`}}}}
   \def\FV@FontFamily{\ttfamily\edef`{{\string`}}}}
-%% SR modification end
+
 \gdef\FV@fontfamily@cmtt{%
   \def\FV@FontScanPrep{\FV@MakeActive\`}%
   \def\FV@FontFamily{\edef`{{\string`}}\fontfamily{cmtt}}}
 \endgroup
+
 \@namedef{FV@fontfamily@cmtt-spanish}{%
   \def\FV@FontScanPrep{}%
   \def\FV@FontFamily{\fontfamily{cmtt}}}
+
+%% FIX ME
+
 \@namedef{FV@fontfamily@courier}{%
   \def\FV@FontScanPrep{}%
-%% SR modification begin - 1995
-%%  \def\FV@FontFamily{\fontfamily{rpcr}}}
   \def\FV@FontFamily{\fontfamily{pcr}}}
-%% SR modification end
+
 \@namedef{FV@fontfamily@helvetica}{%
   \def\FV@FontScanPrep{}%
-%% SR modification begin - 1995
-%%  \def\FV@FontFamily{\fontfamily{rphv}}}
   \def\FV@FontFamily{\fontfamily{phv}}}
-%% SR modification end
+
 \fvset{fontfamily=tt,fontsize=auto,fontshape=auto,fontseries=auto,
   baselinestretch=auto}
+
+% \FV@DefineWhiteSpace
+%
+% We just define the active characters to be ordinary commands, which
+% are easier to redefine. We do with any macros that use verbatim text.
+
 \begingroup
 \catcode`\ =\active
 \catcode`\^^I=\active
 \gdef\FV@DefineWhiteSpace{\def {\FV@Space}\def^^I{\FV@Tab}}%
 \endgroup
+
 \define@key{FV}{defineactive}[]{\def\FancyVerbDefineActive{#1\relax}}
 \define@key{FV}{defineactive*}{%
   \expandafter\def\expandafter\FancyVerbDefineActive\expandafter{%
     \FancyVerbDefineActive#1\relax}}
 \fvset{defineactive}
+
+% \FV@Space:
+
 \define@booleankey{FV}{showspaces}%
   {\def\FV@Space{{\FancyVerbSpace}}}%
   {\def\FV@Space{\ }}
+
 {\catcode`\ =12 \gdef\FancyVerbSpace{\tt }}
+
 \fvset{showspaces=false}
+
+% \FV@Tab:
+
 \def\FV@Tab{\hbox to\FancyVerbTabSize\fontdimen2\font{\hss\FV@TabChar}}
+
 \define@key{FV}{tabsize}{%
   \@tempcnta=#1\relax
   \ifnum\@tempcnta>100
@@ -576,17 +819,28 @@
   \else
     \edef\FancyVerbTabSize{\the\@tempcnta}%
   \fi}
+
 \define@booleankey{FV}{showtabs}%
   {\def\FV@TabChar{\FancyVerbTab}}%
   {\let\FV@TabChar\relax}
+
 \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.
+
 \def\FancyVerbTab{%
     \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:
+
 \newbox\FV@TabBox
+
 \def\FV@@ObeyTabsInit{%
   \@tempdimb=\FancyVerbTabSize\fontdimen\tw@\font
   \edef\FV@ObeyTabSize{\number\@tempdimb}%
@@ -595,8 +849,10 @@
   \edef\FV@@ObeyTabSize{\number\@tempdimb}%
   \let\FV@ObeyTabs\FV@@ObeyTabs
   \let\FV@Tab\FV@TrueTab}
+
 \def\FV@@ObeyTabs#1{\setbox\FV@TabBox=\hbox{#1}\box\FV@TabBox}
 \let\FV@ObeyTabs\relax
+
 \def\FV@TrueTab{%
   \egroup
   \@tempdima=\FV@ObeyTabSize sp\relax
@@ -607,34 +863,80 @@
   \advance\@tempdima-\wd\FV@TabBox
   \setbox\FV@TabBox=\hbox\bgroup
     \unhbox\FV@TabBox\kern\@tempdima\hbox to\z@{\hss\FV@TabChar}}
+
 \define@booleankey{FV}{obeytabs}%
   {\let\FV@ObeyTabsInit\FV@@ObeyTabsInit}%
   {\let\FV@ObeyTabsInit\relax}
+
 \fvset{obeytabs=false}
+
+% \FancyVerbFormatCom
+
 \define@key{FV}{formatcom}[]{\def\FancyVerbFormatCom{#1\relax}}
 \define@key{FV}{formatcom*}{%
   \expandafter\def\expandafter\FancyVerbFormatCom\expandafter{%
     \FancyVerbFormatCom#1\relax}}
+
 \fvset{formatcom}
+
 \def\FancyVerbFormatLine#1{\FV@ObeyTabs{#1}}
+
+% LIST ENVIRONMENTS:
+
+% Some parameters:
+
 \define@key{FV}{xleftmargin}{\def\FV@XLeftMargin{#1}}
 \let\FV@XLeftMargin\z@
+
 \define@key{FV}{xrightmargin}{\def\FV@XRightMargin{#1}}
 \let\FV@XRightMargin\z@
+
 \define@booleankey{FV}{resetmargins}%
   {\let\if@FV@ResetMargins\iftrue}
   {\let\if@FV@ResetMargins\iffalse}
+
 \fvset{resetmargins=false}
+
 \define@key{FV}{listparameters}{\def\FV@ListParameterHook{#1}}
 \def\FV@ListParameterHook{}
+
 \define@key{FV}{hfuzz}{%
   \@tempdima=#1\relax
   \edef\FancyVerbHFuzz{\number\@tempdima sp}}
+
 \fvset{hfuzz=2pt}
+
 \define@booleankey{FV}{samepage}%
   {\def\FV@InterLinePenalty{\interlinepenalty\@M}}%
   {\let\FV@InterLinePenalty\relax}
+
 \fvset{samepage=false}
+
+% 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 \hbox's 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 \item's label, unless we reset margins.
+%       The user can instead have the environment start on a new
+%       line by inserting `\ ' between \item and the environment.
+
 \def\FV@List#1{%
   \begingroup
   \FV@UseKeyValues
@@ -650,6 +952,13 @@
   \FV@FormattingPrep
   \FV@ObeyTabsInit
   \FV@BeginListFrame}
+
+% Cases where we need to leave vmode:
+%   - After an in-line section (\if@noskipsec=T).
+%   - After an \item command, if we reset margins.
+% Then we end \vmode, using @noparlist as a flag if in vmode.
+% (Not the usual meaning of @noparlist.)
+
 \def\FV@LeaveVMode{%
   \if@noskipsec
     \leavevmode
@@ -657,6 +966,7 @@
     \if@FV@ResetMargins\if@inlabel\leavevmode\fi\fi
   \fi
   \ifvmode\@noparlisttrue\else\@noparlistfalse\unskip\par\fi}
+
 \def\FV@ListNesting#1{%
   \if@FV@ResetMargins
     \@listdepth=\z@
@@ -673,6 +983,42 @@
     \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.
+%   <botskip>    = \topsep + \partopsep   % Omitted in LaTeX--a bug?
+%   <toppenalty> = None
+%   <botpenalty> = \@endparpenalty        % Ditto.
+
+% 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
+
 \def\FV@ListVSpace{%
   \@topsepadd\topsep
   \if@noparlist\advance\@topsepadd\partopsep\fi
@@ -693,6 +1039,11 @@
   \global\@inlabelfalse
   \global\@minipagefalse
   \global\@newlistfalse}
+
+% \leftmargin       := totalleftmargin
+% \rightmargin      := totalrightmargin
+% \@totalleftmargin := totalleftmargin of enclosing environment.
+
 \def\FV@SetLineWidth{%
   \if@FV@ResetMargins\else
     \advance\leftmargin\@totalleftmargin
@@ -703,6 +1054,23 @@
   \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.
+
 \def\FV@ListProcessLine#1{%
   \hbox to \hsize{%
     \kern\leftmargin
@@ -710,12 +1078,9 @@
       \FV@LeftListNumber
       \FV@LeftListFrame
       \FancyVerbFormatLine{#1}\hss
-%% DG/SR modification begin - Jan. 28, 1998 (for numbers=right add-on)
-%%      \FV@RightListFrame}%
-      \FV@RightListFrame
-      \FV@RightListNumber}%
-%% DG/SR modification end
+      \FV@RightListFrame}%
     \hss}}
+
 \def\FV@ListProcessLine@i#1{%
   \hbox{%
     \ifvoid\@labels\else
@@ -723,24 +1088,29 @@
     \fi
     \FV@ListProcessLine{#1}}%
   \let\FV@ProcessLine\FV@ListProcessLine@ii}
+
 \def\FV@ListProcessLine@ii#1{%
   \setbox\@tempboxa=\FV@ListProcessLine{#1}%
   \let\FV@ProcessLine\FV@ListProcessLine@iii}
+
 \def\FV@ListProcessLine@iii#1{%
   {\advance\interlinepenalty\clubpenalty\penalty\interlinepenalty}%
   \box\@tempboxa
   \setbox\@tempboxa=\FV@ListProcessLine{#1}%
   \let\FV@ProcessLine\FV@ListProcessLine@iv}
+
 \def\FV@ListProcessLine@iv#1{%
   \penalty\interlinepenalty
   \box\@tempboxa
   \setbox\@tempboxa=\FV@ListProcessLine{#1}}%
+
 \def\FV@EndList{%
   \FV@ListProcessLastLine
   \FV@EndListFrame
   \@endparenv
   \endgroup
   \@endpetrue}
+
 \def\FV@ListProcessLastLine{%
   \ifx\FV@ProcessLine\FV@ListProcessLine@iv
     {\advance\interlinepenalty\widowpenalty\penalty\interlinepenalty}%
@@ -758,67 +1128,76 @@
       \fi
     \fi
   \fi}
+
+% Verbatim environment:
+
 \def\FV@VerbatimBegin{\FV@List\z@}
 \def\FV@VerbatimEnd{\FV@EndList}
+
 \def\FVB@Verbatim{\FV@VerbatimBegin\FV@Scan}
 \def\FVE@Verbatim{\FV@VerbatimEnd}
+
 \DefineVerbatimEnvironment{Verbatim}{Verbatim}{}
+
+% With \UseVerbatim, we have to take care of some of the things
+% \end{} would do.
+
 \def\FV@UseVerbatim#1{%
   \FV@VerbatimBegin#1\FV@VerbatimEnd
   \@doendpe\global\@ignorefalse\ignorespaces}
+
 \def\VerbatimInput{\FV@Command{}{VerbatimInput}}
 \def\FVC@VerbatimInput#1{\FV@UseVerbatim{\FV@Input{#1}}}
+
+% LVerbatim environment:
+
 \def\FV@LVerbatimBegin{\FV@List\@ne}
 \def\FV@LVerbatimEnd{\FV@EndList}
+
 \def\FVB@LVerbatim{\FV@LVerbatimBegin\FV@Scan}
 \def\FVE@LVerbatim{\FV@LVerbatimEnd}
+
 \DefineVerbatimEnvironment{LVerbatim}{LVerbatim}{}
+
 \def\FV@LUseVerbatim#1{%
   \FV@LVerbatimBegin#1\FV@LVerbatimEnd
   \@doendpe\global\@ignorefalse\ignorespaces}
+
 \def\LVerbatimInput{\FV@Command{}{LVerbatimInput}}
 \def\FVC@LVerbatimInput#1{\FV@LUseVerbatim{\FV@Input{#1}}}
+
+% Frames:
+
 \def\FV@Frame@none{%
   \let\FV@BeginListFrame\relax
   \let\FV@LeftListFrame\relax
   \let\FV@RightListFrame\relax
   \let\FV@EndListFrame\relax}
+
 \def\FV@Frame@single{%
   \let\FV@BeginListFrame\FV@BeginListFrame@Single
   \let\FV@LeftListFrame\FV@LeftListFrame@Single
   \let\FV@RightListFrame\FV@RightListFrame@Single
   \let\FV@EndListFrame\FV@EndListFrame@Single}
+
 \def\FV@Frame@lines{%
   \let\FV@BeginListFrame\FV@BeginListFrame@Lines
   \let\FV@LeftListFrame\relax
   \let\FV@RightListFrame\relax
   \let\FV@EndListFrame\FV@EndListFrame@Lines}
+  
 \def\FV@Frame@topline{%
   \let\FV@BeginListFrame\FV@BeginListFrame@Lines
   \let\FV@LeftListFrame\relax
   \let\FV@RightListFrame\relax
   \let\FV@EndListFrame\relax}
+  
 \def\FV@Frame@bottomline{%
   \let\FV@BeginListFrame\relax
   \let\FV@LeftListFrame\relax
   \let\FV@RightListFrame\relax
   \let\FV@EndListFrame\FV@EndListFrame@Lines}
-%% To define a frame with only a left line
-\def\FV@Frame@leftline{%
-  % To define the \FV@FrameFillLine macro (from \FV@BeginListFrame)
-  \ifx\FancyVerbFillColor\relax
-    \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}
+
 \def\FV@BeginListFrame@Single{%
   \lineskip\z@
   \baselineskip\z@
@@ -831,188 +1210,74 @@
       {\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}%
       \kern-\number\@tempdima sp}}%
   \fi
-%% DG/SR modification begin - May. 19, 1998
-%%  \FV@SingleFrameLine
-  \FV@SingleFrameLine{\z@}%
-%% DG/SR modification end
+  \FV@SingleFrameLine
   \penalty\@M
   \FV@SingleFrameSep
   \penalty\@M}
-%% DG/SR modification begin - May. 19, 1998
-\define@key{FV}{label}{%
-  \def\@tempa{#1}%
-  \ifx\@tempa\FV@None
-    \let\FV@LabelBegin\relax
-    \let\FV@LabelEnd\relax
-  \else
-    \FV@Label@i#1\@nil%
-  \fi}
-\def\FV@Label@i{\@ifnextchar[{\FV@Label@ii}{\FV@Label@ii[]}}
-\def\FV@Label@ii[#1]#2\@nil{%
-  \def\@tempa{#1}%
-  \ifx\@tempa\empty
-    \def\FV@LabelBegin{#2}%
-  \else
-    \def\FV@LabelBegin{#1}%
-    \def\FV@LabelPositionBottomLine{\@ne}%
-  \fi
-  \def\FV@LabelEnd{#2}}
-\fvset{label=none}
-\define@key{FV}{labelposition}[none]{%
-  \@ifundefined{FV@LabelPosition@#1}%
-    {\FV@Error{Label position `#1' not defined.}\FV@eha}%
-    {\@nameuse{FV@LabelPosition@#1}}}
-\def\FV@LabelPosition@none{%
-  \let\FV@LabelPositionTopLine\relax%
-  \let\FV@LabelPositionBottomLine\relax}
-\def\FV@LabelPosition@topline{%
-  \def\FV@LabelPositionTopLine{\@ne}%
-  \let\FV@LabelPositionBottomLine\relax}
-\def\FV@LabelPosition@bottomline{%
-  \let\FV@LabelPositionTopLine\relax%
-  \def\FV@LabelPositionBottomLine{\@ne}}
-\def\FV@LabelPosition@all{%
-  \def\FV@LabelPositionTopLine{\@ne}%
-  \def\FV@LabelPositionBottomLine{\@ne}}
-\fvset{labelposition=topline}
-%% DG/SR modification end
-%% DG/SR modification begin - May. 19, 1998
-%% \def\FV@SingleFrameLine{%
-\def\FV@SingleFrameLine#1{%
-%% DG/SR modification end
+
+\def\FV@SingleFrameLine{%
   \hbox to\z@{%
     \kern\leftmargin
-%% DG/SR modification begin - Jun. 22, 1998
-    \ifnum#1=\z@
-      \let\FV@Label\FV@LabelBegin
-    \else
-      \let\FV@Label\FV@LabelEnd
-    \fi
-    \ifx\FV@Label\relax
-%% DG/SR modification end
-      \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
-%% DG/SR modification begin - Jun. 22, 1998
-    \else
-      \ifnum#1=\z@
-        \setbox\z@\hbox{\strut\enspace\FV@LabelBegin\enspace\strut}%
-      \else
-        \setbox\z@\hbox{\strut\enspace\FV@LabelEnd\enspace\strut}%
-      \fi
-      \@tempdimb=\dp\z@
-      \advance\@tempdimb -.5\ht\z@
-      \@tempdimc=\linewidth
-      \advance\@tempdimc -\wd\z@
-      \divide\@tempdimc\tw@
-      \ifnum#1=\z@              % Top line
-        \ifx\FV@LabelPositionTopLine\relax
-          \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
-        \else
-          \FV@FrameLineWithLabel
-        \fi
-      \else                     % Bottom line
-        \ifx\FV@LabelPositionBottomLine\relax
-          \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
-        \else
-          \FV@FrameLineWithLabel
-        \fi
-      \fi
-    \fi
-%% DG/SR modification end
+    \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
     \hss}}
-%% DG/SR modification begin - May. 19, 1998
-\def\FV@FrameLineWithLabel{%
-  \ht\z@\@tempdimb\dp\z@\@tempdimb%
-  \FancyVerbRuleColor{%
-    \vrule \@width\@tempdimc \@height\FV@FrameRule
-    \raise\@tempdimb\box\z@
-    \vrule \@width\@tempdimc \@height\FV@FrameRule}}
-%% DG/SR modification end
+
 \def\FV@BeginListFrame@Lines{%
   \begingroup
     \lineskip\z@skip
-%% DG modification begin - June 18, 1997 (effect of \baselineskip too earlier)
-%%    \baselineskip\z@skip
-%%    \FV@SingleFrameLine
-%% DG/SR modification begin - May. 19, 1998
-%%    \FV@SingleFrameLine
-    \FV@SingleFrameLine{\z@}%
-%% DG/SR modification end
-    \kern-0.5\baselineskip\relax
     \baselineskip\z@skip
-%% DG modification end
+    \FV@SingleFrameLine
     \kern\FV@FrameSep\relax
   \endgroup}%
+
 \def\FV@EndListFrame@Lines{%
   \begingroup
     \baselineskip\z@skip
     \kern\FV@FrameSep\relax
-%% DG/SR modification begin - May. 19, 1998
-%%    \FV@SingleFrameLine
-    \FV@SingleFrameLine{\@ne}%
-%% DG/SR modification end
+    \FV@SingleFrameLine
   \endgroup}
+
 \def\FV@SingleFrameSep{%
   \hbox to \z@{%
     \kern\leftmargin
     \hbox to\linewidth{%
       \FancyVerbRuleColor{%
-%% DG modification begin - June 18, 1997 (\FV@FrameSep missing)
-        \ifx\FancyVerbFillColor\relax
-          \vrule\@width 0pt\@height\FV@FrameSep\relax
-        \fi
-%% DG modification end
         \vrule\@width\FV@FrameRule\relax
         \ifx\FancyVerbFillColor\relax
           \hfil
         \else
           {\FancyVerbFillColor\leaders\hrule\@height\FV@FrameSep\hfil}%
         \fi
-%% DG modification begin - June 18, 1997 (\FV@FrameSep missing)
-        \ifx\FancyVerbFillColor\relax
-          \vrule\@width 0pt\@height\FV@FrameSep\relax
-        \fi
-%% DG modification end
         \vrule\@width\FV@FrameRule\relax}}%
     \hss}}
+
 \def\FV@LeftListFrame@Single{%
   \strut
   {\FancyVerbRuleColor{\vrule \@width\FV@FrameRule}}%
   \FV@FrameFillLine
-%% DG modification begin - June 18, 1997 (to fill color on left side)
-%%  \kern\FV@FrameSep}
-  \ifx\FancyVerbFillColor\relax
-    \kern\FV@FrameSep
-  \else
-    {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}%
-  \fi}
-%% DG modification end
+  \kern\FV@FrameSep}
+
 \def\FV@RightListFrame@Single{%
-%% DG modification begin - June 18, 1997 (to fill color on right side)
-%%  \kern\FV@FrameSep
-  \ifx\FancyVerbFillColor\relax
-    \kern\FV@FrameSep
-  \else
-    {\noexpand\leavevmode\FancyVerbFillColor{\vrule\@width\FV@FrameSep}}%
-  \fi
+  \kern\FV@FrameSep
   {\noexpand\leavevmode\FancyVerbRuleColor{\vrule\@width\FV@FrameRule}}}
-%% DG modification end
+
 \def\FV@EndListFrame@Single{%
   \penalty\@M
   \FV@SingleFrameSep
   \penalty\@M
-%% DG/SR modification begin - May. 19, 1998
-%%  \FV@SingleFrameLine}
-  \FV@SingleFrameLine{\@ne}}
-%% DG/SR modification end
+  \FV@SingleFrameLine}
+
 \define@key{FV}{framerule}{%
   \@tempdima=#1\relax
   \edef\FV@FrameRule{\number\@tempdima sp\relax}}
 \def\KV@FV@framerule@default{\let\FV@FrameRule\fboxrule}
+
 \define@key{FV}{framesep}{%
   \@tempdima=#1\relax
   \edef\FV@FrameSep{\number\@tempdima sp\relax}}
 \def\KV@FV@framesep@default{\let\FV@FrameSep\fboxsep}
+
 \fvset{framerule,framesep}
+
 \define@key{FV}{rulecolor}{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@None
@@ -1020,6 +1285,7 @@
   \else
     \let\FancyVerbRuleColor\@tempa
   \fi}
+
 \define@key{FV}{fillcolor}{%
   \def\@tempa{#1}%
   \ifx\@tempa\FV@None
@@ -1027,17 +1293,25 @@
   \else
     \let\FancyVerbFillColor\@tempa
   \fi}
+
 \fvset{rulecolor=none,fillcolor=none}
+
 \def\FV@Frame@double{%
   \let\FV@FrameBegin\FV@FrameBegin@double
   \let\FV@FrameLine\FV@FrameLine@double
   \let\FV@FrameEnd\FV@FrameEnd@double}
+
 \define@key{FV}{frame}[none]{%
   \@ifundefined{FV@Frame@#1}%
     {\FV@Error{Frame style `#1' not defined.}\FV@eha}%
     {\@nameuse{FV@Frame@#1}}}
+
 \fvset{frame=none}
+
+% Code line numbers:
+
 \newcounter{FancyVerbLine}
+
 \define@key{FV}{firstnumber}[auto]{%
   \def\@tempa{#1}\def\@tempb{auto}%
   \ifx\@tempa\@tempb
@@ -1049,110 +1323,35 @@
     \ifx\@tempa\@tempb
       \let\FV@SetLineNo\relax
     \else
-%% DG/SR modification begin - Jan. 19, 1998
-%%      \def\FV@SetLineNo{\c@FancyVerbLine#1}%
-      \def\FV@SetLineNo{%
-        \c@FancyVerbLine#1
-        \advance\c@FancyVerbLine\m@ne}%
-%% DG/SR modification end
+      \def\FV@SetLineNo{\c@FancyVerbLine#1}%
     \fi
   \fi}
-\define@booleankey{FV}{numberblanklines}%
-  {\let\if@FV@NumberBlankLines\iftrue}
-  {\let\if@FV@NumberBlankLines\iffalse}
-\fvset{numberblanklines=true}
-%% DG/SR modification begin - May. 20, 1998
-%%\def\refstepcounter#1{% Adapted from latex.ltx
-\def\FV@refstepcounter#1{%
-%% DG/SR modification end
-  \stepcounter{#1}%
-  \protected@edef\@currentlabel
-    {\csname p@#1\endcsname\arabic{FancyVerbLine}}}
+  
 \def\FV@StepLineNo{%
   \FV@SetLineNo
-%% DG/SR modification begin - Apr. 28, 1998 and May 20, 1998
-%%  \def\FV@StepLineNo{\refstepcounter{FancyVerbLine}}%
-  \def\FV@StepLineNo{%
-    \if@FV@NumberBlankLines
-      \FV@refstepcounter{FancyVerbLine}
-    \else
-      \ifx\FV@Line\empty
-      \else
-        \FV@refstepcounter{FancyVerbLine}
-      \fi
-    \fi}%
-%% DG/SR modification end
+  \def\FV@StepLineNo{\refstepcounter{FancyVerbLine}}%
   \FV@StepLineNo}
-%% DG/SR modification begin - 1995
-%%\def\theFancyVerbLine{\rm\tiny\arabic{FancyVerbLine}}
+
 \def\theFancyVerbLine{\rmfamily\tiny\arabic{FancyVerbLine}}
-%% DG/SR modification end
+
 \define@key{FV}{numbers}[none]{%
   \@ifundefined{FV@Numbers@#1}%
     {\FV@Error{Numbers style `#1' not defined.}\FV@eha}%
     {\@nameuse{FV@Numbers@#1}}}
-%% DG modification begin - Dec. 20, 1995 and Jan. 28, 1998
-%%\def\FV@Numbers@none{\let\FV@LeftListNumber\relax}
-\def\FV@Numbers@none{%
-\let\FV@LeftListNumber\relax
-\let\FV@RightListNumber\relax}
-\newcount\FV@StepNumber
-\define@key{FV}{stepnumber}{\FV@StepNumber#1}
-\def\KV@FV@stepnumber@default{\FV@StepNumber\@ne}
-\fvset{stepnumber}
-%% DG modification begin - Dec. 20, 1995
-%%\def\FV@Numbers@left{%
-%%  \def\FV@LeftListNumber{\hbox to\z@{%
-%%    \hss\theFancyVerbLine\kern\FV@NumberSep}}}
+
+\def\FV@Numbers@none{\let\FV@LeftListNumber\relax}
 \def\FV@Numbers@left{%
-%% DG/SR modification begin - Apr. 28, 1998
-  \let\FV@RightListNumber\relax
-%% DG/SR modification end
-  \def\FV@LeftListNumber{%
-  \@tempcnta=\FV@CodeLineNo
-  \@tempcntb=\FV@CodeLineNo
-  \divide\@tempcntb\FV@StepNumber
-  \multiply\@tempcntb\FV@StepNumber
-  \ifnum\@tempcnta=\@tempcntb
-%% DG/SR modification begin - Apr. 28, 1998
-%%    \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
-      \if@FV@NumberBlankLines
-        \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
-      \else
-        \ifx\FV@Line\empty
-        \else
-          \hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
-        \fi
-      \fi
-%% DG/SR modification end
-  \fi}}
-\def\FV@Numbers@right{%
-%% DG/SR modification begin - Apr. 28, 1998
-  \let\FV@LeftListNumber\relax
-%% DG/SR modification end
-  \def\FV@RightListNumber{%
-  \@tempcnta=\FV@CodeLineNo
-  \@tempcntb=\FV@CodeLineNo
-  \divide\@tempcntb\FV@StepNumber
-  \multiply\@tempcntb\FV@StepNumber
-  \ifnum\@tempcnta=\@tempcntb
-%% DG/SR modification begin - Apr. 28, 1998
-%%    \hbox to \z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
-      \if@FV@NumberBlankLines
-        \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
-      \else
-        \ifx\FV@Line\empty
-        \else
-          \hbox to\z@{\kern\FV@NumberSep\theFancyVerbLine\hss}%
-        \fi
-      \fi
-%% DG/SR modification end
-  \fi}}
-%% DG modification end
+  \def\FV@LeftListNumber{\hbox to\z@{%
+    \hss\theFancyVerbLine\kern\FV@NumberSep}}}
+
 \define@key{FV}{numbersep}{%
   \@tempdima=#1\relax
   \edef\FV@NumberSep{\number\@tempdima sp\relax}}
+
 \fvset{numbers=none,numbersep=12pt,firstnumber=auto}
+
+%% BVERBATIM:
+
 \def\FV@BVerbatimBegin{%
   \begingroup
     \FV@UseKeyValues
@@ -1161,11 +1360,13 @@
     \FV@FormattingPrep
     \FV@ObeyTabsInit}%
 \def\FV@BVerbatimEnd{\FV@EndVBox\endgroup}
+
 \def\FV@BeginVBox{%
   \leavevmode
   \hbox\ifx\FV@boxwidth\relax\else to\FV@boxwidth\fi\bgroup
   \ifcase\FV@baseline\vbox\or\vtop\or$\vcenter\fi\bgroup}
 \def\FV@EndVBox{\egroup\ifmmode$\fi\hfil\egroup}
+
 \define@key{FV}{boxwidth}{%
   \def\@tempa{#1}\def\@tempb{auto}%
   \ifx\@tempa\@tempb
@@ -1175,28 +1376,34 @@
     \edef\FV@boxwidth{\number\@tempdima sp}%
   \fi}
 \def\KV@FV@boxwidth@default{\let\FV@boxwidth\relax}
+
 \define@key{FV}{baseline}{%
   \if t#1\@empty\let\FV@baseline\@ne\else
     \if c#1\@empty\let\FV@baseline\tw@\else\let\FV@baseline\z@\fi
   \fi}
+
 \fvset{baseline=b,boxwidth}
+
 \def\FV@BProcessLine#1{\hbox{\FancyVerbFormatLine{#1}}}
+
 \def\FVB@BVerbatim{\FV@BVerbatimBegin\FV@Scan}
 \def\FVE@BVerbatim{\FV@BVerbatimEnd}
+
 \DefineVerbatimEnvironment{BVerbatim}{BVerbatim}{}
+
 \def\FV@BUseVerbatim#1{\FV@BVerbatimBegin#1\FV@BVerbatimEnd}
+
 \def\BVerbatimInput{\FV@Command{}{BVerbatimInput}}
 \def\FVC@BVerbatimInput#1{\FV@BUseVerbatim{\FV@Input{#1}}}
+
+%% SAVE VERBATIM:
+
 \def\SaveVerbatim{\FV@Environment{}{SaveVerbatim}}
+
 \def\FVB@SaveVerbatim#1{%
   \@bsphack
   \begingroup
     \FV@UseKeyValues
-%%    \FV@BeginVBox
-%%    \let\FV@ProcessLine\FV@BProcessLine
-%%    \FV@FormattingPrep
-%%    \FV@ObeyTabsInit%
-%%
     \def\SaveVerbatim@Name{#1}%
     \gdef\FV@TheVerbatim{}%
     \def\FV@ProcessLine##1{%
@@ -1207,40 +1414,33 @@
 \def\FVE@SaveVerbatim{%
   \expandafter\global\expandafter\let
   \csname FV@SV@\SaveVerbatim@Name\endcsname\FV@TheVerbatim
-%%  \expandafter\gdef
-%%    \csname FV@SV@\SaveVerbatim@Name\endcsname{\FV@TheVerbatim}
-%%    \FV@EndVBox
-%%  \endgroup}
   \endgroup\@esphack}
+
 \DefineVerbatimEnvironment{SaveVerbatim}{SaveVerbatim}{}
+
 \def\FV@CheckIfSaved#1#2{%
   \@ifundefined{FV@SV@#1}%
   {\FV@Error{No verbatim text has been saved under name `#1'}\FV@eha}%
   {#2{\csname FV@SV@#1\endcsname}}}
+
 \def\UseVerbatim{\FV@Command{}{UseVerbatim}}
 \def\FVC@UseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@UseVerbatim}}
+
 \def\LUseVerbatim{\FV@Command{}{LUseVerbatim}}
 \def\FVC@LUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@LUseVerbatim}}
+
 \def\BUseVerbatim{\FV@Command{}{BUseVerbatim}}
 \def\FVC@BUseVerbatim#1{\FV@CheckIfSaved{#1}{\FV@BUseVerbatim}}
+
+
+% VERBATIM OUT:
+
 \newwrite\FV@OutFile
+
 \def\VerbatimOut{\FV@Environment{}{VerbatimOut}}
-\def\FVB@VerbatimOut#1{%
-  \@bsphack
-  \begingroup
-    \FV@UseKeyValues
-    \FV@DefineWhiteSpace
-    \def\FV@Space{\space}%
-    \FV@DefineTabOut
-    \def\FV@ProcessLine{\immediate\write\FV@OutFile}%
-    \immediate\openout\FV@OutFile #1\relax
-    \let\FV@FontScanPrep\relax
-%% DG/SR modification begin - May. 18, 1998 (to avoid problems with ligatures)
-    \let\@noligs\relax
-%% DG/SR modification end
-    \FV@Scan}
-\def\FVE@VerbatimOut{\immediate\closeout\FV@OutFile\endgroup\@esphack}
+
 \DefineVerbatimEnvironment{VerbatimOut}{VerbatimOut}{}
+
 \def\FV@DefineTabOut{%
   \def\FV@Tab{}%
   \@tempcnta=\FancyVerbTabSize\relax
@@ -1248,7 +1448,20 @@
     \edef\FV@Tab{\FV@Tab\space}%
     \advance\@tempcnta\m@ne
   \repeat}
+
+%% 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 file each time there is a missing verbatim delimiter.
+%
+% If scanning fails (and thus TeX ignores \FV@GetVerb), #1 is defined
+% to be empty, a group is ended, but \FancyVerbAfterSave is not invoked.
+
 \def\SaveVerb{\FV@Command{}{SaveVerb}}
+
 \begingroup
 \catcode`\^^M=\active%
 \gdef\FVC@SaveVerb#1#2{%
@@ -1263,6 +1476,7 @@
     \expandafter\@tempa\string#2{\endgroup\@namedef{FV@SV@#1}{##2}\@tempg}%
     \FancyVerbGetVerb\FV@EOL}%
 \endgroup
+
 \def\FV@EOL{%
   \endgroup
   \FV@Error%
@@ -1271,15 +1485,20 @@
       \string\SaveVerb^^J%
       command, or you broke the literal text across input lines.^^J%
       Hit <return> to procede.}}
+
 \define@key{FV}{aftersave}{\def\FancyVerbAfterSave{#1}}
 \fvset{aftersave=}
+
 \def\FV@UseVerb#1{\mbox{\FV@UseKeyValues\FV@FormattingPrep#1}}
+
 \def\UseVerb{\FV@Command{}{UseVerb}}
 \def\FVC@UseVerb#1{%
   \@ifundefined{FV@SV@#1}%
     {\FV@Error{Short verbatim text never saved to name `#1'}\FV@eha}%
     {\FV@UseVerb{\@nameuse{FV@SV@#1}}}}
+
 \def\Verb{\FV@Command{}{Verb}}
+
 \begingroup
 \catcode`\^^M=\active%
 \gdef\FVC@Verb#1{%
@@ -1293,12 +1512,14 @@
     \expandafter\@tempa\string#1{\mbox{##2}\endgroup}%
     \FancyVerbGetVerb\FV@EOL}%
 \endgroup
+
 \def\DefineShortVerb{\FV@Command{}{DefineShortVerb}}
 \def\FVC@DefineShortVerb#1{%
   \@ifundefined{FV@CC@\string#1}%
     {\FVC@@DefineShortVerb#1}%
     {\FV@Error{`\expandafter\@gobble\string#1' is already a short
       verb character.}\FV@eha}}
+
 \def\FVC@@DefineShortVerb#1{%
   \begingroup
     \lccode`\~=`#1%
@@ -1314,6 +1535,7 @@
   \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do#1}%
   \expandafter\def\expandafter\@sanitize\expandafter{\@sanitize\@makeother#1}%
   \catcode`#1=\active}%
+
 \def\UndefineShortVerb#1{%
   \@ifundefined{FV@CC@\string#1}%
     {\FV@Error{`\expandafter\@gobble\string#1' is not a short
@@ -1321,9 +1543,6 @@
     {\FV@UndefineShortVerb#1}}
 \def\FV@UndefineShortVerb#1{%
   \catcode`#1=\csname FV@CC@\string#1\endcsname
-%% DG/SR modification begin - Jun. 12, 1998
-  \expandafter\let\csname FV@CC@\string#1\endcsname\relax
-%% DG/SR modification end
   \begingroup
     \lccode`\~=`#1%
     \lowercase{\gdef\@tempg{\let~}}%
@@ -1334,7 +1553,12 @@
   \def\@tempa##1\@makeother#1##2\@nil##3\@nil##4\@@nil{%
     ##3\def\@sanitize{##1##2}\fi}%
   \expandafter\@tempa\@sanitize\@nil\iftrue\@nil\do#1\@nil\iffalse\@nil\@@nil}
+
+% Moving verbatim. Need to worry about about using separate identifier
+% for this class of verbatim, and
+
 \def\SaveMVerb{\FV@Command{}{SaveMVerb}}
+
 \begingroup
 \catcode`\^^M=\active%
 \gdef\FVC@SaveMVerb#1#2{%
@@ -1365,7 +1589,9 @@
       \@tempg}%
     \FancyVerbGetVerb\FV@EOL}%
 \endgroup
+
 \def\SaveGVerb{\FV@Command{}{SaveGVerb}}
+
 \begingroup
 \catcode`\^^M=\active%
 \gdef\FVC@SaveGVerb#1#2{%
@@ -1379,8 +1605,11 @@
     \expandafter\@tempa\string#2{\endgroup\global\@namedef{FV@SVG@#1}{##2}}%
     \FancyVerbGetVerb\FV@EOL}%
 \endgroup
+
 \def\UseMVerb{\protect\pUseMVerb}
+
 \def\pUseMVerb{\FV@Command{}{pUseMVerb}}
+
 \def\FVC@pUseMVerb#1{%
   \expandafter\ifx \csname FV@SVM@#1\endcsname\relax
     \expandafter\ifx \csname FV@SVG@#1\endcsname\relax
@@ -1392,7 +1621,9 @@
   \else
     \FV@UseVerb{\@nameuse{FV@SVM@#1}}%
   \fi}
+
 \expandafter\ifx\csname documentclass\endcsname\relax
+
   \def\lrbox#1{%
     \edef\@tempa{%
       \endgroup
@@ -1405,11 +1636,41 @@
       \bgroup
         \ignorespaces}
   \def\endlrbox{\unskip\egroup}
+
 \fi
-%% DG/SR modification begin - Jan. 22, 1998
-%%\@input{fancyvrb.rc}
-\@input{fancyvrb.cfg}
-%% DG/SR modification end
+
+\@input{fancyvrb.rc}
+
 \endinput
-%%
-%% End of file `fancyvrb.sty'.
+\define@key{FV}{noligs}{%
+  \def\FV@ActiveLigs{}%
+  \def\FV@DefineLigs{}%
+  \@tfor\@tempa:=#1\do{%
+    {\lccode`\~=`#1\relax\lowercase{\gdef\@tempg{~}}}%
+    \expandafter\FV@addtonoligs\@tempg}}
+\def\FV@addtonoligs#1{%
+  \expandafter\def\expandafter\FV@ActiveLigs\expandafter{%
+    \FV@ActiveLigs\catcode`#1=\active}%
+  \expandafter\def\expandafter\FV@DefineLigs\expandafter{%
+    \FV@DefineLigs\edef#1{{\string#1}}}}
+
+%\fvset{noligs={>,-}}
+%\fvset{suppressligs=\>}
+%\fvset{suppressligs=\<}
+
+%% END fancyvrb.sty
+
+Error messages to void:
+
+\FV@CheckBadBegin
+\FV@CheckBadEnd
+
+
+
+\def\FV@Error#1#2{%
+  \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
+  \typeout{%
+    ^^J** FancyVerb Error:\space\space
+    Type \space H <return> \space for immediate help. **}%
+  \errmessage{#1^^J}}
+
--- a/ipsj.tex	Thu Dec 05 20:10:27 2013 +0900
+++ b/ipsj.tex	Thu Dec 05 22:44:00 2013 +0900
@@ -1,12 +1,18 @@
 \documentclass[techrep]{ipsjpapers}
 \usepackage[dvipdfmx]{graphicx}
-\usepackage{fancyvrb}
 \usepackage{url}
+
+%\usepackage{amssymb}
+%\usepackage{bbm}
+%\usepackage[greek,english]{babel}
+
 \usepackage{ucs}
 \usepackage[utf8x]{inputenc}
 \usepackage{autofe}
+\usepackage{fancyvrb}
 
-\DeclareUnicodeCharacter{8718}{\rule{5pt}{10pt}}
+\DeclareUnicodeCharacter{8718}{\rule{3pt}{5pt}}
+\DeclareUnicodeCharacter{8909}{$\simeq$}
 
 % \input{dummy.tex} %% Font