Debian Codegraph @

texmf-dist/doc/latex/fancyvrb/fancyvrb-doc.tex

raw
1 %! HV lualatex
2 %! HV biber
3 %! HV lualatex
4 %! HV lualatex
5
6 \listfiles
7 \documentclass[twoside]{article}
8 \usepackage[TT={Scale=MatchLowercase,FakeStretch=0.88}]{lucida-otf}
9 \setmonofont[Scale=MatchLowercase,FakeStretch=0.85]{DejaVu Sans Mono}
10
11 \usepackage{biblatex}
12 \addbibresource[location=remote]{https://www.ctan.org/tex-archive/biblio/ctan-bibdata/ctan.bib}
13
14
15 \newif\ifChangeBar \ChangeBarfalse
16 \usepackage{fancyvrb}
17 \usepackage{fancyvrb-ex}
18 \usepackage{fancyhdr}
19
20 \pagestyle{fancy}
21
22 \fancyhead[RE,LO]{}
23 \fancyhead[RO]{\leftmark}
24
25 \usepackage{xurl}
26
27 \usepackage[colorlinks,linktocpage]{hyperref}
28 \parskip=3pt plus 1pt minus 1pt
29 %
30
31 \newcommand\FBoxPackage{`\textsf{fancybox}'}
32 \newcommand\FVrbPackage{`\textsf{fancyvrb}'}
33 \newcommand\cs[1]{\texttt{\textbackslash#1}}
34 %
35 % From ltugboat.cls
36 %
37 % Typeset the name of an environment
38 \providecommand\env[1]{\textsf{#1}}
39 \providecommand\clsname[1]{\textsf{#1}}
40 \providecommand\pkgname[1]{\textsf{#1}}
41 \providecommand\optname[1]{\textsf{#1}}
42 \providecommand\progname[1]{\textsf{#1}}
43 %
44 % A list of options for a package/class
45 \newenvironment{optlist}{\begin{description}%
46 \renewcommand\makelabel[1]{%
47 \descriptionlabel{\mdseries\optname{##1}}}%
48 \itemsep0.25\itemsep}%
49 {\end{description}}
50 %
51 % Utility macros
52 %
53 % Special dashes
54
55 \makeatletter
56 \def\thinskip{\hskip 0.16667em\relax}
57 \def\endash{--}
58 \def\emdash{\endash-}
59 \def\d@sh#1#2{\unskip#1\thinskip#2\thinskip\ignorespaces}
60 \def\dash{\d@sh\nobreak\endash}
61 \def\Dash{\d@sh\nobreak\emdash}
62 \makeatother
63 \newif\ifPostScriptFonts \PostScriptFontstrue
64 %
65 \setlength{\columnseprule}{0.6pt}
66 %
67 \newif\ifmulticols
68 %\IfFileExists{multicol.sty}{\multicolstrue}{}
69 \newif\ifpstricks
70 \pstrickstrue
71 %
72 \title{The `\textsf{fancyvrb}' package\\Fancy Verbatims in \LaTeX}
73 \author{Timothy Van Zandt\\Princeton University\\Princeton -- USA\\[5mm]
74 % {\footnotesize \url{[email protected]}}\\[5mm]
75 {Packaging and documentation by}\\
76 {\footnotesize Denis Girou (CNRS/IDRIS -- France),}\\[-2mm]
77 {\footnotesize Sebastian Rahtz\dagger\ (Elsevier -- GB)}\\[-2mm]
78 {\footnotesize and}\\[-2mm]
79 {\footnotesize Herbert Voß\ (FU Berlin -- DE)}
80 }
81 \date{\today}
82
83 \fvset{frame=single,xrightmargin=0cm,numbers=left,numbersep=3pt,commentchar=Z}
84
85 \begin{document}
86 \maketitle
87 %
88 \begin{abstract}
89 This package provides very sophisticated facilities for reading and
90 writing verbatim \TeX{} code. Users can perform common tasks like changing
91 font family and size, numbering lines, framing code examples, colouring
92 text and conditionally processing text.
93 \end{abstract}
94
95 \begin{center}
96 Report bugs to \url{[email protected]}
97 \end{center}
98
99 \vfill
100 Thanks to
101 Claudio Beccari,
102 Karl Berry,
103 Jean-François Burnol,
104 Philippe Esperet, %\url{[email protected]},
105 Michael Friendly, %\url{[email protected]},
106 Mario Hassler, %\url{[email protected]},
107 Ohad Kammar, % \url{[email protected]},
108 Mikhail Kolodin, %\url{[email protected]},
109 Andreas Matthias,
110 Frank Mittelbach,
111 Rolf Niepraschk, %\url{[email protected]},
112 Will Robertson,
113 Ulrich M. Schwarz,
114 Thomas Siegel, % \url{[email protected]},
115 Clemens Steinke,
116 Vladimir Volovich,
117 and
118 Yukai Chou
119 %\url{[email protected]}.
120 \clearpage
121 \tableofcontents
122 \clearpage
123 %\part{\texttt{fancyvrb} package by Timothy Van Zandt}
124
125
126 \part{Package \texttt{fancyvrb}}
127
128
129 \section{Introduction}
130 %
131 \FVrbPackage{} is the development of the \emph{verbatim} macros of the
132 \FBoxPackage{} package, Section 11 of \cite{ctan-fancybox}. It offers six kinds
133 of extended functionality, compared to the standard \LaTeX{}
134 \textsf{verbatim} environment:
135
136 \begin{enumerate}
137 \item verbatim commands can be used in footnotes,
138 \item several verbatim commands are enhanced,
139 \item a variety of verbatim environments are provided, with many
140 parameters to change the way the contents are printed; it is also possible
141 to define new customized verbatim environments,
142 \item a way is provided to save and restore verbatim text and environments,
143 \item there are macros to write and read files in verbatim mode, with the
144 usual versatility,
145 \item you can build \emph{example} environments (showing both result and
146 verbatim text), with the same versatility as normal verbatim.
147 \end{enumerate}
148
149 The package works by scanning a line at a time from an environment or a
150 file. This allows it to pre-process each line, rejecting it, removing
151 spaces, numbering it, etc, before going on to execute the body of the line
152 with the appropriate catcodes set.
153
154 \section{Verbatim material in footnotes}
155
156 After a \cs{VerbatimFootnotes} macro declaration (to use after the
157 preamble), it is possible to put verbatim commands and environments
158 (the \LaTeX{} or \FVrbPackage{} ones) in footnotes, unlike in standard
159 \LaTeX:
160
161 \begin{Example}
162 \VerbatimFootnotes
163 We can put verbatim\footnote{\verb+_Yes!_+} text in footnotes.
164 \end{Example}
165
166 \section{Improved verbatim commands}
167 %
168 The \cs{DefineShortVerb} macro allows us to define a special character as
169 an abbreviation to enclose verbatim text and the \cs{UndefineShortVerb}
170 macro suppresses the special meaning of the specified character (the same
171 functionalities are provided in the \LaTeX{} `\textsf{shortvrb}' package):
172
173 \fvset{xrightmargin=4.8cm}
174
175 \begin{SideBySideExample}
176 \DefineShortVerb{\|}
177 We can simply write \Verb+_verbatim_+
178 material using a single |_delimiter_|
179 \UndefineShortVerb{\|}
180 \DefineShortVerb{\+}
181 And we can +_change_+ the character.
182 \end{SideBySideExample}
183
184 To make matters more versatile, we can nominate \emph{escape} characters
185 in verbatim text (using the \cs{Verb} macro or with a `shortverb' character
186 defined), to perform formatting or similar tasks, using the
187 \texttt{commandchars} parameter as shown for environments in paragraph
188 \ref{sec:commandchars}.
189
190 \section{Verbatim environments}
191
192 Several verbatim environments are available, each with a lot of
193 parameters to customize them. In the following examples we use the
194 \texttt{Verbatim} environment, which is the equivalent of the standard
195 \texttt{verbatim}. The parameters can be set globally using the \cs{fvset}
196 macro or in an optional argument after the start of the
197 environment\footnote{For clarification in this paper, note that we
198 generally indent each verbatim line with two
199 spaces.}$^,$\footnote{This mechanism uses the
200 `\textbf{keyval}' package from the standard \LaTeX{} graphics
201 distribution, written by David \textsc{Carlisle}.}.
202
203 \begin{SideBySideExample}
204 \begin{Verbatim}
205 First verbatim line.
206 Second verbatim line.
207 \end{Verbatim}
208 \end{SideBySideExample}
209
210 \subsection{Customization of verbatim environments}
211
212 The appearance of verbatim environments can be changed in many and
213 varied ways; here we list the keys that can be set.
214
215 \subsubsection{Comments}
216
217 \begin{optlist}
218 \item[commentchar (character)]: character to define comments in the
219 verbatim code, so that lines starting with this character will not be
220 printed (\emph{Default: empty}).
221 \end{optlist}
222
223 \begin{SideBySideExample}
224 \begin{Verbatim}[commentchar=!]
225 A comment
226 Verbatim line.
227 ! A comment that you will not see
228 \end{Verbatim}
229 \end{SideBySideExample}
230
231 Take care to a special effect if the comment character is not the first
232 non blank one: it is because this character is in fact managed as the \TeX{}
233 comment one, that is to say that it gobble the newline character too. So, in
234 this case, the current line will be joined with the next one and, more, the
235 last one will be lost if it contain a comment, as \FVrbPackage{} print a
236 line only after finding it end character, which will never occured in this
237 case...
238
239 \begin{SideBySideExample}
240 \begin{Verbatim}[commentchar=\%]
241 First line. % First line
242 Second.
243 Third line. % Third line lost...
244 \end{Verbatim}
245 \end{SideBySideExample}
246
247 \subsubsection{Initial characters to suppress}
248
249 \begin{optlist}
250 \item[gobble (integer)]: number of characters to suppress at the beginning
251 of each line (up to a maximum of 9), mainly useful when environments are
252 indented
253 (\emph{Default: empty} \Dash no character suppressed).
254 \end{optlist}
255
256 \begin{SideBySideExample}
257 \begin{Verbatim}
258 Verbatim line.
259 \end{Verbatim}
260
261 \begin{Verbatim}[gobble=2]
262 Verbatim line.
263 \end{Verbatim}
264
265 \begin{Verbatim}[gobble=8]
266 Verbatim line.
267 \end{Verbatim}
268 \end{SideBySideExample}
269
270 \subsubsection{Customization of formatting}
271
272 \begin{optlist}
273 \item[formatcom (command)]: command to execute before printing verbatim
274 text
275 (\emph{Default: empty}).
276 \item[formatcom* (command)]: add definition to an existing one
277 \end{optlist}
278
279 \begin{SideBySideExample}
280 \begin{Verbatim}[formatcom=\color{red}]
281 First verbatim line.
282 Second verbatim line.
283 \end{Verbatim}
284 \end{SideBySideExample}
285
286 \begin{SideBySideExample}
287 \fvset{formatcom=\color{red}}
288 \begin{Verbatim}[formatcom*=\itshape]
289 First verbatim line.
290 Second verbatim line.
291 \end{Verbatim}
292 \end{SideBySideExample}
293
294 \subsubsection{Changing individual line formatting}
295
296 The macro \cs{FancyVerbFormatLine} defines the way each line is formatted.
297 Its default value is \verb+\def\FancyVerbFormatLine#1{#1}+, but we can
298 redefine it at our convenience (\texttt{FancyVerbLine} is the name of the
299 line counter):
300
301 {\fvset{fontsize=\small}
302 \begin{SideBySideExample}
303 Z\fvset{fontsize=\normalsize}
304 \renewcommand{\FancyVerbFormatLine}[1]{%
305 \makebox[0cm][l]{$\Rightarrow$}#1}
306 \begin{Verbatim}
307 First verbatim line.
308 Second verbatim line.
309 Third verbatim line.
310 \end{Verbatim}
311 \end{SideBySideExample}
312
313 \begin{SideBySideExample}
314 \renewcommand{\FancyVerbFormatLine}[1]{%
315 \ifodd\value{FancyVerbLine}%
316 \MakeUppercase{#1}\else#1\fi}
317 \begin{Verbatim}
318 First verbatim line.
319 Second verbatim line.
320 Third verbatim line.
321 \end{Verbatim}
322 \end{SideBySideExample}
323 }
324
325 \subsubsection{Fonts}
326
327 \begin{optlist}
328 \item[fontfamily (family name)]: font family to use.
329 \texttt{tt}, \texttt{courier} and \texttt{helvetica} are pre-defined
330 (\emph{Default:~tt}).
331 \end{optlist}
332
333 \ifPostScriptFonts We can guess that PostScript fonts are available
334
335 \begin{SideBySideExample}
336 \begin{Verbatim}[fontfamily=helvetica]
337 Verbatim line.
338 \end{Verbatim}
339 \end{SideBySideExample}
340
341 \else
342 \begin{quote}
343 \textbf{\large Warning!} PostScript fonts seems not available on your
344 platform (we are looking for the file \texttt{times.sty}, so we will
345 not show the examplaes using such PostScript fonts.
346 \end{quote}
347 \fi
348
349 \begin{optlist}
350 \item[fontsize (font size)]: size of the font to use
351 (\emph{Default: auto} \Dash the same as the current font). If you use the
352 `\textsf{relsize}' package too, you can require a change of the size
353 proportional to the current one (for instance:
354 \verb+fontsize=\relsize{-2}+).
355 \end{optlist}
356
357 \ifPostScriptFonts We can guess that PostScript fonts are available
358
359 \begin{SideBySideExample}
360 \begin{Verbatim}[fontsize=\small]
361 Verbatim line.
362 \end{Verbatim}
363
364 \begin{Verbatim}[fontfamily=courier,
365 fontsize=\large]
366 Verbatim line.
367 \end{Verbatim}
368 \end{SideBySideExample}
369
370 \else
371 \begin{SideBySideExample}
372 \begin{Verbatim}[fontsize=\small]
373 Verbatim line.
374 \end{Verbatim}
375 \end{SideBySideExample}
376 \fi
377
378 \begin{optlist}
379 \item[fontshape (font shape)]: font shape to use
380 (\emph{Default: auto} \Dash the same as the current font).
381 \end{optlist}
382
383 \ifPostScriptFonts We can guess that PostScript fonts are available
384
385 \begin{SideBySideExample}
386 \begin{Verbatim}[fontfamily=courier,
387 fontshape=it]
388 Verbatim line.
389 \end{Verbatim}
390 \end{SideBySideExample}
391
392 \else
393
394 \begin{SideBySideExample}
395 \begin{Verbatim}[fontshape=it]
396 Verbatim line.
397 \end{Verbatim}
398 \end{SideBySideExample}
399 \fi
400
401 \begin{optlist}
402 \item[fontseries (series name)]: \LaTeX{} font `series' to use
403 (\emph{Default: auto} \Dash the same as the current font).
404 \end{optlist}
405
406 \ifPostScriptFonts We can guess that PostScript fonts are available
407
408 \begin{SideBySideExample}
409 \begin{Verbatim}[fontfamily=courier,
410 fontseries=b]
411 Verbatim line.
412 \end{Verbatim}
413 \end{SideBySideExample}
414
415 \else
416 \begin{SideBySideExample}
417 \begin{Verbatim}[fontseries=b]
418 Verbatim line.
419 \end{Verbatim}
420 \end{SideBySideExample}
421 \fi
422
423 \subsubsection{Types and characteristics of frames}
424
425 \begin{optlist}
426 \item[frame
427 (none$\mid$leftline$\mid$topline$\mid$bottomline$\mid$lines$\mid$single)]:
428 type of frame around the verbatim environment
429 (\emph{Default: none} \Dash no frame). With \textsf{leftline} and
430 \textsf{single} modes, a space of a length given by the \LaTeX{}
431 \cs{fboxsep} macro is added between the left vertical line and the text.
432 \end{optlist}
433
434 Problem at the top of a page...
435
436 \begin{SideBySideExample}
437 \begin{Verbatim}[frame=leftline]
438 Verbatim line.
439 \end{Verbatim}
440
441 \begin{Verbatim}[frame=topline]
442 Verbatim line.
443 \end{Verbatim}
444
445 \begin{Verbatim}[frame=bottomline]
446 Verbatim line.
447 \end{Verbatim}
448
449 \begin{Verbatim}[frame=lines]
450 Verbatim line.
451 \end{Verbatim}
452
453 \begin{Verbatim}[frame=single]
454 Verbatim line.
455 \end{Verbatim}
456 \end{SideBySideExample}
457
458 \begin{optlist}
459 \item[framerule (dimension)]: width of the rule of the frame
460 (\emph{Default: 0.4pt if framing specified}).
461 \end{optlist}
462
463 \begin{SideBySideExample}
464 \begin{Verbatim}[frame=single,
465 framerule=1mm]
466 Verbatim line.
467 \end{Verbatim}
468 \end{SideBySideExample}
469
470 \begin{optlist}
471 \item[framesep (dimension)]: width of the gap between the frame and
472 the text (\emph{Default: \cs{fboxsep}}).
473 \end{optlist}
474
475 \begin{SideBySideExample}
476 \begin{Verbatim}[frame=single,
477 framesep=5mm]
478 Verbatim line.
479 \end{Verbatim}
480 \end{SideBySideExample}
481
482 \begin{optlist}
483 \item[rulecolor (color command)]: color of the frame rule, expressed
484 in the standard \LaTeX{} way
485 (\emph{Default: black}).
486 \end{optlist}
487
488 \begin{SideBySideExample}
489 \begin{Verbatim}[frame=single,
490 rulecolor=\color{red}]
491 Verbatim line.
492 \end{Verbatim}
493 \end{SideBySideExample}
494
495 \begin{optlist}
496 \item[fillcolor (color command)]: color used to fill the space
497 between the frame and the text (its thickness is given by
498 \texttt{framesep})
499 (\emph{Default: none} \Dash no color).
500 \end{optlist}
501
502 \begin{SideBySideExample}
503 \begin{Verbatim}[frame=single,
504 framerule=1mm,framesep=3mm,
505 rulecolor=\color{red},
506 fillcolor=\color{yellow}]
507 Verbatim line.
508 \end{Verbatim}
509 \end{SideBySideExample}
510
511 \subsubsection{Label for the environment}
512
513 \begingroup
514 \newcommand\Vitem{\SaveVerb[aftersave={\item[\UseVerb{Vitem}]}]{Vitem}}
515 \DefineShortVerb{\|}
516
517 \begin{optlist}
518 \Vitem|label ({[string]string})|: label(s) to print on top, bottom or
519 both frame lines of the environment to describe it content
520 (\emph{Default: empty} \Dash no label).
521 If the label(s) contains special characters, as a comma or an equal sign,
522 it must be put inside a group. If only one string is given, it will be
523 used for both top and bottom lines (if the two are printed), but if an
524 optional first label is given too, this one will be used for the top line
525 and the second one for the bottom line. Note also that, if another value
526 than \textsf{topline}, \textsf{bottomline}, \textsf{lines} or
527 \textsf{single} is used for the \textsf{frame} parameter, the label(s)
528 will not be printed.
529 \end{optlist}
530 \endgroup
531
532 Problem at the top of a page...
533
534 \begin{SideBySideExample}
535 \fvset{gobble=2}
536 \begin{Verbatim}[frame=single,
537 label=My text]
538 First verbatim line.
539 Second verbatim line.
540 \end{Verbatim}
541
542 \begin{Verbatim}[frame=topline,
543 framesep=4mm,
544 label=\fbox{\Large\emph{The code}}]
545 First verbatim line.
546 Second verbatim line.
547 \end{Verbatim}
548 \end{SideBySideExample}
549
550 \begin{optlist}
551 \item[labelposition (none$\mid$topline$\mid$bottomline$\mid$all)]:
552 position where to print the label if one is defined, which must be
553 coherent with the kind of frame chosen
554 (\emph{Default: none if the label is empty, topline if one label is
555 defined and all if two are defined}).
556 Of course, some incompatible options (like
557 \textsf{frame=topline,labelposition=bottomline}) will not print the
558 label.
559 \end{optlist}
560
561 Problem at the top of a page...
562
563 \begin{SideBySideExample}
564 \fvset{gobble=2}
565 \begin{Verbatim}[frame=single,
566 framesep=2mm,
567 label=Text,labelposition=all]
568 First verbatim line.
569 Second verbatim line.
570 \end{Verbatim}
571
572 \begin{Verbatim}[frame=lines,
573 label=Text,labelposition=topline]
574 First verbatim line.
575 Second verbatim line.
576 \end{Verbatim}
577 \end{SideBySideExample}
578
579 \begin{SideBySideExample}
580 \begin{Verbatim}[frame=bottomline,
581 framesep=3mm,
582 label=\textit{Code included},
583 labelposition=bottomline]
584 First verbatim line.
585 Second verbatim line.
586 \end{Verbatim}
587
588 \begin{Verbatim}[frame=lines,
589 framesep=3mm,
590 label={[Beginning of code]End of code}]
591 First verbatim line.
592 Second verbatim line.
593 \end{Verbatim}
594 \end{SideBySideExample}
595
596 \subsubsection{Line numbering}
597
598 \begin{optlist}
599 \item[numbers (none$\mid$left$\mid$right)]: numbering of the verbatim lines
600 (\emph{Default: none} \Dash no numbering). If requested, this numbering is
601 done \emph{outside} the verbatim environment.
602 \end{optlist}
603
604 \begin{SideBySideExample}
605 \begin{Verbatim}[gobble=2,numbers=left]
606 First verbatim line.
607 Second verbatim line.
608 \end{Verbatim}
609
610 \begin{Verbatim}[gobble=2,
611 numbers=right,numbersep=0pt]
612 First verbatim line.
613 Second verbatim line.
614 \end{Verbatim}
615 \end{SideBySideExample}
616
617 \begin{optlist}
618 \item[numbersep (dimension)]: gap between numbers and verbatim lines
619 (\emph{Default: 12pt}).
620 \end{optlist}
621
622 \begin{SideBySideExample}
623 \begin{Verbatim}[gobble=2,
624 numbers=left,numbersep=2pt]
625 First verbatim line.
626 Second verbatim line.
627 \end{Verbatim}
628 \end{SideBySideExample}
629
630 \begin{optlist}
631 \item[firstnumber (auto$\mid$last$\mid$integer)]: number of the first line
632 (\emph{Default: auto} \Dash numbering starts from 1). \textsf{last} means
633 that the numbering is continued from the previous verbatim environment. If
634 an integer is given, its value will be used to start the numbering.
635 \end{optlist}
636
637 \begin{SideBySideExample}
638 \fvset{gobble=2,
639 numbers=left,numbersep=3pt}
640 \begin{Verbatim}
641 Verbatim line.
642 \end{Verbatim}
643
644 \begin{Verbatim}[firstnumber=last]
645 Verbatim line.
646 \end{Verbatim}
647
648 \begin{Verbatim}[firstnumber=100]
649 Verbatim line.
650 \end{Verbatim}
651 \end{SideBySideExample}
652
653 \begin{optlist}
654 \item[stepnumber (integer)]: interval at which line numbers are printed
655 (\emph{Default:~1} \Dash all lines are numbered).
656 \end{optlist}
657
658 \begin{SideBySideExample}
659 \begin{Verbatim}[gobble=2,numbers=left,
660 numbersep=3pt,stepnumber=2]
661 First verbatim line.
662 Second verbatim line.
663 Third verbatim line.
664 \end{Verbatim}
665 \end{SideBySideExample}
666
667 The macro \cs{theFancyVerbLine} defines the typesetting style of the
668 numbering, and the counter used is \texttt{FancyVerbLine}:
669
670 \begin{SideBySideExample}
671 \renewcommand{\theFancyVerbLine}{%
672 \textcolor{red}{\small
673 8.\alph{FancyVerbLine}}}
674 \begin{Verbatim}[gobble=2,
675 numbers=left,numbersep=2pt]
676 First verbatim line.
677 Second verbatim line.
678 Third verbatim line.
679 \end{Verbatim}
680 \end{SideBySideExample}
681
682 \ifChangeBar\begin{changebar}\fi
683 \begin{optlist}
684 \item[numberblanklines (boolean)]: to number or not the empty lines
685 (really empty or containing blank characters only)
686 (\emph{Default: true} \Dash all lines are numbered).
687 \end{optlist}
688
689 \begin{SideBySideExample}
690 \begin{Verbatim}[gobble=2,numbers=left,
691 numbersep=3pt,
692 numberblanklines=false]
693 First verbatim line.
694
695
696 Second verbatim line.
697 \end{Verbatim}
698 \end{SideBySideExample}
699 \ifChangeBar\end{changebar}\fi
700 %
701 \subsubsection{Selection of lines to print}
702
703 \begin{optlist}
704 \item[firstline (integer)]: first line to print
705 (\emph{Default: empty} \Dash all lines from the first are printed).
706 \item[lastline (integer)]: last line to print
707 (\emph{Default: empty} \Dash all lines until the last one are printed).
708 \end{optlist}
709
710
711 \begin{SideBySideExample}
712 \begin{Verbatim}[gobble=2,firstline,lastline,
713 numbers=left,numbersep=2pt]
714 First verbatim line.
715 Second verbatim line.
716 Third verbatim line.
717 \end{Verbatim}
718 \end{SideBySideExample}
719
720
721
722 \begin{SideBySideExample}
723 \begin{Verbatim}[gobble=2,firstline=2,
724 numbers=left,numbersep=2pt]
725 First verbatim line.
726 Second verbatim line.
727 Third verbatim line.
728 \end{Verbatim}
729 \end{SideBySideExample}
730
731
732 \begin{SideBySideExample}
733 \begin{Verbatim}[gobble=2,lastline=1,
734 numbers=left,numbersep=2pt]
735 First verbatim line.
736 Second verbatim line.
737 Third verbatim line.
738 \end{Verbatim}
739 \end{SideBySideExample}
740
741 Instead of specifying a firstline at which to start printing a range
742 of lines, you can define a start string; the start of the range is
743 the first line that exactly equals the string. (The comparison is made
744 before any characters are gobbled off the front of the line.) Similarly for a stop
745 string. You can mix line-numbers and strings, e.g.\ start at
746 firstline, and end at a stop string. Specifying the strings is a
747 bit klunky. Initially you must define the strings with
748 \cs{newcommand*} as in:
749
750 \begin{SideBySideExample}[gobble=2]
751 \newcommand*\FancyVerbStartString{FROM}
752 \newcommand*\FancyVerbStopString{TO}
753 \begin{Verbatim}
754 First verbatim line.
755 FROM
756 Second verbatim line.
757 TO
758 Third verbatim line.
759 \end{Verbatim}
760 \end{SideBySideExample}
761
762 \noindent To redefine the strings, you must use \cs{renewcommand*}.
763
764 With the setting \texttt{lastline=} or \texttt{lastline=0} nothing will be printed.
765
766 \begin{SideBySideExample}[gobble=2]
767 foo
768 \begin{Verbatim}[frame=none,lastline=]
769 First verbatim line.
770 Second verbatim line.
771 Third verbatim line.
772 \end{Verbatim}
773 bar
774 \end{SideBySideExample}
775
776 \subsubsection{Spaces and tab characters}
777
778 \begin{optlist}
779 \item[showspaces (boolean)]: print a special character representing each
780 space
781 (\emph{Default: false} \Dash spaces not shown).
782 \end{optlist}
783
784 \begin{SideBySideExample}[gobble=0]
785 \begin{Verbatim}[showspaces,showtabs]
786 Verbatim line .
787 \end{Verbatim}
788 \end{SideBySideExample}
789
790 In practice, all verbatim environments, \Verb|\VerbatimInput|, and \Verb/\Verb/ have a~\texttt{*} variant, which
791 sets \texttt{showspaces=true}:
792
793 \begin{SideBySideExample}[gobble=0]
794 \begin{Verbatim*}
795 Verbatim line .
796 \end{Verbatim*}
797 \end{SideBySideExample}
798
799 \begin{SideBySideExample}[gobble=0]
800 \begin{filecontents}
801 [noheader,force]{foo.txt}
802 foo bar baz
803 \end{filecontents}
804 \Verb|Verbatim with tab .|
805 \Verb*|Verbatim with tab .|
806
807 \VerbatimInput*{foo.txt}
808 \end{SideBySideExample}
809
810 There are also some parameters to determine the way tab characters are
811 interpreted (using tabs is in fact a rather old-fashioned style of coding):
812
813 \begin{optlist}
814 \item[showtabs (boolean)]: explicitly show tab characters
815 (\emph{Default: false} \Dash tab characters not shown).
816 \end{optlist}
817
818 \begin{optlist}
819 \item[obeytabs (boolean)]: position characters according to the tabs
820 (\emph{Default: false} \Dash tab characters are added to the current
821 position).
822 \end{optlist}
823
824 \begin{optlist}
825 \item[tabsize (integer)]: number of spaces given by a tab character
826 (\emph{Default:~8}).
827 \end{optlist}
828
829 \noindent
830 \colorbox{black!15}{\parbox{\linewidth}{%
831 Pay attention that the behaviour of the environment/command from
832 the \LaTeX\ kernel is different. In \LaTeX\ Tabs are printed as visible
833 space, but with \texttt{fancyvrb} as spaces or with \texttt{showtabs}
834 as visible Tab.}}
835
836 \iffalse
837 \begin{SideBySideExample}[gobble=0]
838 \begin{Verbatim*}
839 Verbatim line foo
840 \end{Verbatim*}
841 \end{SideBySideExample}
842
843
844 \begin{SideBySideExample}[gobble=0]
845 \begin{verbatim*}
846 verbatim line foo
847 \end{verbatim*}
848 \end{SideBySideExample}
849
850
851 \begin{SideBySideExample}[gobble=0]
852 \Verb*|Verb line foo|\par
853 \verb*|verb line foo|
854 \end{SideBySideExample}
855 \fi
856
857 \subsubsection{Space between lines}
858
859 \begin{optlist}
860 \item[baselinestretch (auto$\mid$dimension)]: value to give to the usual
861 `baselinestretch' \LaTeX{} parameter
862 (\emph{Default: auto} \Dash its current value just before the verbatim
863 command).
864 \end{optlist}
865
866 \begin{SideBySideExample}
867 \begin{Verbatim}[baselinestretch=2]
868 First verbatim line.
869 Second verbatim line.
870 \end{Verbatim}
871 \end{SideBySideExample}
872
873
874 \subsubsection{Vertical space before and after}
875
876 \begin{optlist}
877 \item[vspace (dimension)]: value to give to the usual
878 vertical list space .
879 (\emph{Default: \cs{topsep}} \Dash its current value just before the verbatim
880 command).
881 \end{optlist}
882
883 \begin{SideBySideExample}
884 A line before Verbatim
885 \begin{Verbatim}[frame=lines,label=foo]
886 First verbatim line.
887 Second verbatim line.
888 \end{Verbatim}
889 A line after Verbatim
890 \end{SideBySideExample}
891
892 \begin{SideBySideExample}
893 A line before Verbatim
894 \begin{Verbatim}[frame=lines,label=foo,
895 vspace=0pt]
896 First verbatim line.
897 Second verbatim line.
898 \end{Verbatim}
899 A line after Verbatim
900 \end{SideBySideExample}
901
902
903
904
905 \subsubsection{Escape characters for inserting commands}
906
907 \begin{optlist}
908 \item[commandchars (three characters)]: characters which define the
909 character which starts a macro and marks the beginning and end of a group;
910 thus lets us introduce \emph{escape} sequences in verbatim code. Of
911 course, it is better to choose special characters which are not used in
912 the verbatim text! (\emph{Default: empty}).
913 \label{sec:commandchars}
914 \end{optlist}
915
916 \begin{SideBySideExample}
917 \begin{Verbatim}[commandchars=\\\{\}]
918 \textit{This is a comment}
919 First verbatim line.
920 \fbox{Second} verbatim line.
921 \textcolor{red}{Third} verbatim line.
922 \end{Verbatim}
923
924 \begin{Verbatim}[commandchars=+\[\]]
925 +textit[\textbf{Verbatim} line].
926 \end{Verbatim}
927 \end{SideBySideExample}
928
929
930 Escaping of ] is needed to prevent ]] at the end which is not allowed. ALternatively
931 you can write \verb|commandchars={+[]}| or \verb|commandchars=+{[}{]}|. Escaping is needed
932 for all active characters. Pay attention that you do not use characters which are used
933 in the code of \texttt{fancyvrb} itself, e.g. \verb|<>|
934
935
936
937
938 \ifChangeBar\begin{changebar}\fi
939 Using this way, it is also possible to put labels to be able, later, to
940 make reference to some lines of the verbatim environments:
941
942 \begin{SideBySideExample}
943 \begin{Verbatim}[commandchars=\\\{\},
944 numbers=left,numbersep=2pt]
945 First verbatim line.
946 Second line.\label{vrb:Important}
947 Third verbatim line.
948 \end{Verbatim}
949
950 As I previously shown
951 line~\ref{vrb:Important}, it is...
952 \end{SideBySideExample}
953 \ifChangeBar\end{changebar}\fi
954
955
956 \subsubsection{Margins}
957
958 \begin{optlist}
959 \item[xleftmargin (dimension)]: indentation to add at the start of each
960 line
961 (\emph{Default:~0pt} \Dash no left margin).
962 \end{optlist}
963
964 \begin{SideBySideExample}
965 \begin{Verbatim}[frame=single,
966 xleftmargin=5mm]
967 Verbatim line.
968 \end{Verbatim}
969 \end{SideBySideExample}
970
971 \begin{optlist}
972 \item[xrightmargin (dimension)]: right margin to add after each line
973 (\emph{Default:~0pt} \Dash no right margin).
974 \end{optlist}
975
976 \begin{SideBySideExample}
977 \begin{Verbatim}[frame=single,
978 xrightmargin=1cm]
979 Verbatim line.
980 \end{Verbatim}
981 \end{SideBySideExample}
982
983 \begin{optlist}
984 \item[resetmargins (boolean)]: reset the left margin, which is useful if
985 we are inside other indented environments (\emph{Default: false} \Dash no
986 reset of the margin).
987 \end{optlist}
988
989 {%
990 \DefineVerbatimEnvironment{Verbatim}{Verbatim}{gobble=0,numbers=none}
991 \begin{SideBySideExample}
992 \begin{itemize}
993 \item First item
994 \begin{Verbatim}[frame=single]
995 Verbatim line.
996 \end{Verbatim}
997 \item Second item
998 \begin{Verbatim}[frame=single,
999 resetmargins=true]
1000 Verbatim line.
1001 \end{Verbatim}
1002 \end{itemize}
1003 \end{SideBySideExample}
1004 }
1005
1006 \subsubsection{Overfull box messages}
1007
1008 \begin{optlist}
1009 \item[hfuzz (dimension)]: value to give to the \TeX{} \cs{hfuzz} dimension
1010 for text to format. This can be used to avoid seeing some unimportant
1011 \emph{Overfull box} messages (\emph{Default:~2pt}).
1012 \end{optlist}
1013
1014 \subsubsection{Page breaks}
1015
1016 \begin{optlist}
1017 \item[samepage (boolean)]: in very special circumstances, we may want to
1018 make sure that a verbatim environment is not broken, even if it does not
1019 fit on the current page. To avoid a page break, we can set the
1020 \texttt{samepage} parameter to \emph{true} (\emph{Default: false}).
1021 \end{optlist}
1022
1023 \subsubsection{Catcode characters}
1024
1025 \begin{optlist}
1026 \item[codes (macro)]: to specify \emph{catcode} changes (\emph{Default:
1027 empty}).
1028 \item[codes* (macro)]: add to an existing definition.
1029 \end{optlist}
1030
1031 For instance, this allows us to include formatted mathematics in verbatim
1032 text:
1033
1034 {\fvset{fontsize=\small}%
1035 \begin{SideBySideExample}
1036 \begin{Verbatim}[commandchars=\\\{\},
1037 codes={\catcode`$=3\catcode`^=7}]
1038 x=1/sqrt(z**2) ! $\frac{1}{\sqrt{z^2}}$
1039 \end{Verbatim}
1040 \end{SideBySideExample}
1041 } %$
1042
1043
1044 With \verb|codes*| we can add code to an already existing definition of \Verb|codes|:
1045
1046 {\fvset{fontsize=\small}%
1047 \begin{SideBySideExample}
1048 \fvset{codes={\catcode`$=3\catcode`^=7}}
1049 \begin{Verbatim}[commandchars=\\\{\},
1050 % _add_ to codes
1051 codes*={\color{blue}}]
1052 x=1/sqrt(z**2) ! $\frac{1}{\sqrt{z^2}}$
1053 \end{Verbatim}
1054 \end{SideBySideExample}
1055 } %$
1056
1057
1058
1059
1060
1061
1062 \subsubsection{Active characters}
1063
1064 \begin{optlist}
1065 \item[defineactive (macro)]: to define the effect of \emph{active}
1066 characters
1067 (\emph{Default: empty}).
1068 \item[defineactive* (macro)]: add the definition to an existing one.
1069 \end{optlist}
1070
1071 This allows us to do some devious tricks: see the example in Section
1072 \ref{sec:VerbatimInclude} on page~\pageref{sec:VerbatimInclude}.
1073
1074
1075 \subsubsection{Reference label}
1076
1077 \begin{optlist}
1078 \item[reflabel (<label>)]: A label for use of \verb|\pageref|.
1079 \end{optlist}
1080
1081 \begin{SideBySideExample}
1082 \begin{Verbatim}[reflabel=verb0]
1083 First verbatim line.
1084 Second verbatim line.
1085 \end{Verbatim}
1086 See the verbatim on
1087 page~\pageref{verb0}.
1088 \end{SideBySideExample}
1089
1090
1091
1092
1093 \subsection{Different kinds of verbatim environments}
1094
1095 \subsubsection{Verbatim environment}
1096
1097 This is the `normal' verbatim environment which we have been using up to
1098 now.
1099
1100 \subsubsection{BVerbatim environment}
1101
1102 This environment puts the verbatim material in a \TeX{} box. Some
1103 parameters do not work inside this environment (notably the framing ones),
1104 but two new ones are available:
1105
1106 \begin{optlist}
1107 \item[boxwidth (auto$\mid$dimension)]: size of the box used
1108 (\emph{Default: auto} \Dash the width of the longest line is used).
1109 \end{optlist}
1110
1111 \begin{optlist}
1112 \item[baseline (b$\mid$c$\mid$t)]: position of the baseline (on the
1113 \texttt{baseline}, the \texttt{center} or the \texttt{top} of the box)
1114 (\emph{Default: b}).
1115 \end{optlist}
1116
1117 \begin{SideBySideExample}
1118 \fvset{gobble=2}
1119 \begin{BVerbatim}
1120 First
1121 Second
1122 \end{BVerbatim}
1123 \begin{BVerbatim}[baseline=c]
1124 First
1125 Second
1126 \end{BVerbatim}
1127 \end{SideBySideExample}
1128
1129 \begin{SideBySideExample}
1130 \begin{BVerbatim}[boxwidth=2cm]
1131 First
1132 Second
1133 \end{BVerbatim}
1134 \begin{BVerbatim}[boxwidth=2cm,
1135 baseline=t]
1136 First
1137 Second
1138 \end{BVerbatim}
1139 \end{SideBySideExample}
1140
1141 \subsubsection{LVerbatim environment}
1142
1143 This environment puts verbatim material into \LaTeX{} `LR' mode (the
1144 so-called \emph{left-to-right} mode, which in fact is the same thing that
1145 \TeX{} itself calls \emph{restricted horizontal mode}).
1146
1147 \subsubsection{Personalized environments}
1148
1149 \ifChangeBar\begin{changebar}\fi
1150 \VerbatimFootnotes
1151 It is easy to define personal customized environments. You can redefine
1152 the existing ones using the \cs{RecustomVerbatimEnvironment} macro or create
1153 your own ones, using the \cs{DefineVerbatimEnvironment} macro\footnote{%
1154 \ifChangeBar\begin{changebar}\fi
1155 For verbatim commands, the \cs{CustomVerbatimCommand} and
1156 \cs{RecustomVerbatimCommand} macros also exist; for instance:
1157
1158 \noindent
1159 \verb+\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{frame=lines}+
1160 \ifChangeBar\end{changebar}\fi}.
1161 In each case, you specify the name of the new environment, the type of
1162 environment on which it is based, and a set of initial option values. The
1163 options can be overridden with an optional argument in the normal way:
1164
1165 \begin{SideBySideExample}
1166 \RecustomVerbatimEnvironment
1167 {Verbatim}{Verbatim}
1168 {gobble=2,frame=single}
1169 \begin{Verbatim}
1170 First verbatim line.
1171 Second verbatim line.
1172 \end{Verbatim}
1173 \end{SideBySideExample}
1174 \ifChangeBar\end{changebar}\fi
1175
1176 \begin{SideBySideExample}
1177 \DefineVerbatimEnvironment%
1178 {MyVerbatim}{Verbatim}
1179 {gobble=2,numbers=left,numbersep=2mm,
1180 frame=lines,framerule=0.8mm}
1181 \begin{MyVerbatim}
1182 First verbatim line.
1183 Second verbatim line.
1184 \end{MyVerbatim}
1185
1186 \begin{MyVerbatim}[numbers=none,
1187 framerule=1pt]
1188 First verbatim line.
1189 Second verbatim line.
1190 \end{MyVerbatim}
1191 \end{SideBySideExample}
1192
1193 \section{Saving and restoring verbatim text and environments}
1194
1195 The \cs{SaveVerb} and \cs{UseVerb} macros allow us to save and restore
1196 verbatim material. \cs{UseVerb} itself is robust:
1197
1198 % \DefineShortVerb{\|}
1199 % \SaveVerb{Verb}|_verbatim_|
1200 \begin{SideBySideExample}
1201 \DefineShortVerb{\|}
1202 \SaveVerb{Verb}|_verbatim_|
1203 I have saved \UseVerb{Verb} and reuse
1204 it later as many times as I want
1205 \subsection*{Using \UseVerb{Verb}}
1206 \UseVerb{Verb}.
1207 \end{SideBySideExample}
1208
1209 This also provides a solution to putting verbatim text inside \LaTeX{}
1210 commands which do not normally permit it: % (used package \texttt{marginnote}):
1211
1212 {\fvset{frame=single,xrightmargin=0cm}
1213 \begin{Example}
1214 \DefineShortVerb{\|}\SaveVerb{Verb}|_OK^| \marginpar{\UseVerb{Verb}}
1215 \end{Example}
1216 }
1217
1218 There is a useful ability to use verbatim text as the item text in a
1219 description list (something not normally permitted in \LaTeX), using the
1220 \texttt{aftersave} parameter:
1221
1222 \begin{optlist}
1223 \item[aftersave (macro)]: macro to dynamically save some verbatim material
1224 (\emph{Default: empty}).
1225 \end{optlist}
1226
1227 \begin{SideBySideExample}
1228 \newcommand{\Vitem}{%
1229 \SaveVerb[aftersave={%
1230 \item[\UseVerb{Vitem}]}]{Vitem}}
1231 \DefineShortVerb{\|}
1232 \begin{description}
1233 \Vitem|\MyCommand|: my command
1234 \end{description}
1235 \end{SideBySideExample}
1236
1237 In the same way, we can use and restore (in normal, boxed and LR mode,
1238 using \cs{UseVerbatim}, \cs{BUseVerbatim} and \cs{LUseVerbatim} respectively)
1239 entire verbatim environments:
1240
1241 \begin{SideBySideExample}
1242 Z\fvset{gobble=0,numbers=none}
1243 \begin{SaveVerbatim}{VerbEnv}
1244 Verbatim line.
1245 \end{SaveVerbatim}
1246 \UseVerbatim{VerbEnv}
1247 and \UseVerbatim{VerbEnv}
1248 \end{SideBySideExample}
1249
1250 \begin{SideBySideExample}
1251 Z\fvset{gobble=0,numbers=none}
1252 \begin{SaveVerbatim}[gobble=5]{VerbEnv}
1253 First
1254 Second
1255 \end{SaveVerbatim}
1256
1257 \fbox{\BUseVerbatim{VerbEnv}}
1258 and \BUseVerbatim{VerbEnv}.
1259
1260 \LUseVerbatim{VerbEnv} and
1261 \LUseVerbatim{VerbEnv}
1262 \end{SideBySideExample}
1263
1264
1265 \begin{SideBySideExample}
1266 \begin{SaveVerbatim}{FOO}
1267 However, if I define a
1268 reusable Verbatim by
1269 SaveVerbatim,
1270 linenumbers works.
1271 \end{SaveVerbatim}
1272
1273 \begin{Verbatim}[numbers=left]
1274 This works.
1275 I use Verbatim directly.
1276 \end{Verbatim}
1277
1278 \UseVerbatim[numbers=left]{FOO}
1279 \end{SideBySideExample}
1280
1281
1282 \clearpage
1283
1284 \section{Writing and reading verbatim files}
1285 \label{sec:VerbatimInclude}
1286
1287 The command \cs{VerbatimInput} (the variants \cs{BVerbatimInput} and
1288 \cs{LVerbatimInput} also exist) allows inclusion of the contents of a file
1289 with verbatim formatting. Of course, the various parameters which we have
1290 described for customizing can still be used:
1291
1292 %The file we will use for \VerbatimInput
1293
1294 \typeout{*************************************}
1295 \typeout{* Created files: hello.f90, file.txt}
1296 \typeout{* See fancyhdr.dvi for an explanation}
1297 \typeout{*************************************}
1298
1299 \begin{VerbatimOut}{hello.f90}
1300 ! A "hello" program
1301
1302 program hello
1303 print *,"Hello world"
1304 end program hello
1305 \end{VerbatimOut}
1306
1307 \begin{SideBySideExample}
1308 Z\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{gobble=4}
1309 \fvset{fontsize=\small}
1310 \VerbatimInput{hello.f90}
1311
1312 \fvset{frame=single,numbers=left,
1313 numbersep=3pt}
1314 \VerbatimInput{hello.f90}
1315
1316 \VerbatimInput[firstline=3,
1317 rulecolor=\color{green}]
1318 {hello.f90}
1319
1320 \VerbatimInput[frame=lines,
1321 fontshape=sl,fontsize=\footnotesize]
1322 {hello.f90}
1323 \end{SideBySideExample}
1324
1325 We can make use of the `defineactive' parameter to set the comment lines
1326 in the program text in a different style:
1327
1328 \begin{SideBySideExample}
1329 Z\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{gobble=4}
1330 \def\ExclamationPoint{\char33}
1331 \catcode`!=\active
1332 \VerbatimInput%
1333 [defineactive=%
1334 \def!{\color{cyan}\itshape
1335 \ExclamationPoint}]
1336 {hello.f90}
1337 \end{SideBySideExample}
1338
1339 It is important to note that if the contents of the file does not fit on
1340 the page, it will be automatically broken across pages as needed (unless the
1341 \texttt{samepage} parameter has been set to \texttt{true}).
1342
1343 There is also a \verb+VerbatimOut+ environment to write verbatim text to an
1344 output file, in the same way:
1345
1346 \begin{SideBySideExample}
1347 \begin{VerbatimOut}{file.txt}
1348 I write that.
1349 And that too.
1350 \end{VerbatimOut}
1351
1352 \VerbatimInput[frame=single,
1353 numbers=left,numbersep=6pt]{file.txt}
1354 \end{SideBySideExample}
1355
1356 \ifChangeBar\begin{changebar}\fi
1357 \section{Automatic pretty printing}
1358
1359 Obviously, automatic \emph{pretty printing} is outside the scope of this
1360 package. Nevertheless, this is specially interesting for verbatim
1361 inclusion of programming code files or fragments. In the \LaTeX{} world
1362 (not speaking of the \emph{literate programming} way), there are software
1363 for some special languages, as the `\textsf{C++2LaTeX}' package from Norbert
1364 \textsc{Kiesel}, but mainly two generic ones, which use completely different
1365 modes (an external preprocessor written in C and a \TeX{} based solution):
1366 the `\textsf{LGrind}'~\cite{ctan-lgrind} system, currently maintened by Michael
1367 \textsc{Piefel}, and the `\textsf{listings}'~\cite{ctan-listings} package from
1368 Carsten \textsc{Heinz}.
1369
1370 Future versions of \FVrbPackage{} and `\textsf{listings}' packages are
1371 planned to cooperate, which will offer great advantages to both users of the
1372 two actual packages, and will allow \FVrbPackage{} users to have automatic
1373 pretty printing of programming codes.
1374
1375 \section{Known problems}
1376
1377 \begin{itemize}
1378 \item Vladimir \textsc{Volovich} \verb+<[email protected]>+ reported that the
1379 special character \verb+\th+, available with T1 encoding, can't be
1380 included as verbatim with \FVrbPackage. It can be true for other special
1381 characters too.
1382 \end{itemize}
1383
1384 \iffalse
1385
1386 \section{Thanks}
1387
1388 For interesting comments and suggestions, we would like to thank specially
1389 (alphabetic order): Philippe \textsc{Esperet}
1390 \url{[email protected]}, Michael \textsc{Friendly}
1391 \url{[email protected]}, Rolf \textsc{Niepraschk}
1392 \url{[email protected]} and for bug reports Mario \textsc{Hassler}
1393 \relax\unskip\break
1394 \url{[email protected]}, Mikhail \textsc{Kolodin}
1395 \relax\unskip\break
1396 \url{[email protected]}, Andreas Matthias, Ulrich M. Schwarz, and Vladimir \textsc{Volovich}
1397 \verb+<[email protected]>+.
1398
1399
1400 \fi
1401 \section{Conclusion}
1402
1403 There are a few other possibilities that we have not described here.
1404 Note specially that it is possible to define a customization file
1405 (\texttt{fancyvrb.cfg}) loaded at the end of the package, to store
1406 definitions of your customized commands and environments and to redefine
1407 the attributes of existing ones.
1408
1409
1410 \clearpage
1411
1412
1413 \part{Package \texttt{fancyvrb-ex}}
1414 This package defines some example environments which can write input code
1415 and output side by side or on top of each other. They are all used for this documentation of \texttt{fancyvrb}.
1416
1417 \section{\texttt{Example} environment}
1418
1419 \begin{Verbatim}[gobble=2]
1420 \begin{Example}
1421 First verbatim line.
1422 Second verbatim line.
1423 Third verbatim line.
1424 \end{Example}
1425 \end{Verbatim}
1426
1427 \begin{Example}
1428 First verbatim line.
1429 Second verbatim line.
1430 Third verbatim line.
1431 \end{Example}
1432
1433 \begin{Verbatim}[gobble=2]
1434 \begin{Example}[frame=lines,framerule=1mm,
1435 numbers=left]
1436 First verbatim line.
1437 Second verbatim line.
1438 Third verbatim line.
1439 \end{Example}
1440 \end{Verbatim}
1441
1442 \begin{Example}[frame=lines,framerule=1mm,numbers=left]
1443 First verbatim line.
1444 Second verbatim line.
1445 Third verbatim line.
1446 \end{Example}
1447
1448 \newpage
1449
1450 \section{\texttt{CenterExample} environment}
1451
1452 \begin{Verbatim}[gobble=2]
1453 \begin{CenterExample}[frame=single,
1454 numbers=right]
1455 First verbatim line.
1456 Second verbatim line.
1457 Third verbatim line.
1458 \end{CenterExample}
1459 \end{Verbatim}
1460
1461 \begin{CenterExample}[frame=single,numbers=right]
1462 First verbatim line.
1463 Second verbatim line.
1464 Third verbatim line.
1465 \end{CenterExample}
1466
1467
1468 \section{\texttt{SideBySideExample} environment}
1469
1470 \begin{Verbatim}[gobble=2]
1471 \begin{SideBySideExample}[xrightmargin=5cm,
1472 frame=lines, numbers=left]
1473 First verbatim line.
1474 Second verbatim line.
1475 Third verbatim line.
1476 \end{SideBySideExample}
1477 \end{Verbatim}
1478
1479 \begin{SideBySideExample}[xrightmargin=5cm,frame=single,numbers=left]
1480 First verbatim line.
1481 Second verbatim line.
1482 Third verbatim line.
1483 \end{SideBySideExample}
1484
1485
1486
1487 \iffalse
1488
1489
1490
1491 \section{\texttt{PCenterExample} environment}
1492
1493 \begin{Verbatim}
1494 \fvset{frame=lines,framerule=0.5mm,numbers=left}
1495
1496 \begin{PCenterExample}(-0.5,-0.5)(0.5,0.5)
1497 \setlength{\unitlength}{1cm}
1498 \put(0,0){\circle{1}}
1499 \end{PCenterExample}
1500
1501 \showgrid
1502 \begin{PCenterExample}(-1,-1)(1,1)
1503 \setlength{\unitlength}{1cm}
1504 \put(0,0){\circle{1}}
1505 \end{PCenterExample}
1506 \end{Verbatim}
1507
1508 {\fvset{frame=lines,framerule=0.5mm,numbers=left}
1509 \begin{PCenterExample}(-0.5,-0.5)(0.5,0.5)
1510 \setlength{\unitlength}{1cm}
1511 \put(0,0){\circle{1}}
1512 \end{PCenterExample}
1513 \showgrid
1514 \begin{PCenterExample}(-1,-1)(1,1)
1515 \setlength{\unitlength}{1cm}
1516 \put(0,0){\circle{1}}
1517 \end{PCenterExample}
1518 }
1519
1520
1521 \section{\texttt{PSideBySideExample} environment}
1522
1523 \begin{Verbatim}[gobble=2]
1524 \fvset{frame=single,xrightmargin=5cm}
1525 \begin{PSideBySideExample}(-2,-1)(2,1)
1526 \psellipse*[linecolor=yellow](2,1)
1527 \end{PSideBySideExample}
1528 \showgrid
1529 \begin{PSideBySideExample}(-2,-1)(2,1)
1530 \psellipse[linestyle=dashed](2,1)
1531 \end{PSideBySideExample}
1532 \end{Verbatim}
1533
1534 {\fvset{frame=single,xrightmargin=5cm}
1535 \begin{PSideBySideExample}(-2,-1)(2,1)
1536 \psellipse*[linecolor=yellow](2,1)
1537 \end{PSideBySideExample}
1538
1539 \showgrid
1540 \begin{PSideBySideExample}(-2,-1)(2,1)
1541 \psellipse[linestyle=dashed](2,1)
1542 \end{PSideBySideExample}
1543 }
1544
1545 \begin{Verbatim}[gobble=2]
1546 \fvset{frame=single,xrightmargin=5cm}
1547 \begin{PSideBySideExample}(-2,-1)(2,1)
1548 \psellipse[linestyle=dashed](2,1)
1549 \end{PSideBySideExample}
1550 \begin{PSideBySideExample}[numbers=right](-2,-1)(2,1)
1551 \psellipse[linestyle=dotted](2,1)
1552 \end{PSideBySideExample}
1553 \end{Verbatim}
1554
1555 {\fvset{frame=single,xrightmargin=5cm}
1556 \begin{PSideBySideExample}(-2,-1)(2,1)
1557 \psellipse[linestyle=dashed](2,1)
1558 \end{PSideBySideExample}
1559
1560 \begin{PSideBySideExample}[numbers=right](-2,-1)(2,1)
1561 \psellipse[linestyle=dotted](2,1)
1562 \end{PSideBySideExample}
1563 }
1564
1565
1566 \fi
1567
1568 \nocite{ctan-fancyvrb}
1569
1570 \printbibliography
1571
1572
1573 \end{document}