Debian Codegraph @

texmf-dist/tex/latex/fancyvrb/fancyvrb-ex.sty

raw
1 %%
2 %% This is file `fancyvrb-ex.sty',
3 %%
4 %% COPYRIGHT 2018,2019,2026 by Herbert Voss <[email protected]>
5 %%
6 %% This package may be distributed under the terms of the LaTeX Project Public
7 %% License, as described in lppl.txt in the base LaTeX distribution.
8 %% Either version 1.3 or, at your option, any later version.
9 %%
10 %% DESCRIPTION:
11 %% fancyvrb.sty is a LaTeX style option, containing flexible
12 %% verbatim environments and commands and extensive documentation.
13 %% it is based on the work of Denis Girou
14 %%
15 \NeedsTeXFormat{LaTeX2e}
16 \def\fileversion{0.02}
17 \def\filedate{2026/04/16}
18 \ProvidesPackage{fancyvrb-ex}[\filedate]
19 \message{Style option: `fancyvrb-ex' v\fileversion \space <\filedate> (tvz)}
20 \csname fancyvrb-ex@loaded\endcsname
21 \expandafter\let\csname fancyvrb-ex@loaded\endcsname\endinput
22 \newif\ifEX@pstricks \EX@pstricksfalse
23 \DeclareOption{pstricks}{\EX@pstrickstrue}
24 \newif\ifEX@color\EX@colorfalse
25 \DeclareOption{color}{\global\EX@colortrue}
26 \ProcessOptions
27 \RequirePackage{fancyvrb} % Standard LaTeX `color' package
28 \RequirePackage{xcolor} % Standard LaTeX `color' package
29 \def\FV@Error#1#2{%
30 \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
31 \errmessage{FancyVerb Error:^^J\space\space #1^^J}}
32
33 \def\FV@eha{Your command was ignored. Type <return> to continue.}
34
35 % The exa part of fancyvrb
36 %
37 \def\Highlight@Attributes{} % Default=nothing
38 \def\NoHighlight@Attributes{} % Default=nothing
39 \ifEX@color
40 \RequirePackage{hcolor} % Color version
41 \else
42 \RequirePackage{hbaw} % black and white version
43 \fi
44 \ifEX@pstricks\RequirePackage{pstricks}\fi
45 %
46 %\fvset{gobble=0}
47 \newif\ifFvrbEx@Grid
48 %
49 \def\Example{%
50 \catcode`\^^M=\active
51 \@ifnextchar[{\catcode`\^^M=5\Example@}{\catcode`\^^M=5\Begin@Example}}
52 %
53 \def\endExample{%
54 \end{VerbatimOut}%
55 \KV@FV@firstline@default% reset the values
56 \KV@FV@lastline@default
57 \Below@Example{\input{\jobname.tmp}}}%
58 %
59 \def\Example@[#1]{\fvset{#1}\Begin@Example}
60 %
61 \def\CenterExample{%
62 \catcode`\^^M=\active
63 \@ifnextchar[{\catcode`\^^M=5\Example@}{\catcode`\^^M=5\Begin@Example}}
64 %
65 \def\endCenterExample{%
66 \end{VerbatimOut}%
67 \KV@FV@firstline@default% reset the values
68 \KV@FV@lastline@default
69 \center
70 \Below@Example{\input{\jobname.tmp}}
71 \endcenter}
72 %
73 \def\SideBySideExample{%
74 \catcode`\^^M=\active
75 \@ifnextchar[{\catcode`\^^M=5\Example@}%
76 {\catcode`\^^M=5\Begin@Example}}
77 \def\endSideBySideExample{%
78 \end{VerbatimOut}%
79 \KV@FV@firstline@default% reset the values
80 \KV@FV@lastline@default
81 \SideBySide@Example{\input{\jobname.tmp}}}
82 \newcommand\Begin@Example{%
83 \parindent=0pt
84 \multiply\topsep by 2
85 \VerbatimEnvironment
86 \begin{VerbatimOut}[codes={\catcode`\^^a3=12\catcode`\^^a7=12\catcode`\^^b5=12%
87 \catcode`\^^b6=12}]{\jobname.tmp}}
88 \newcommand\Below@Example[1]{%
89 \VerbatimInput[gobble=0,commentchar=^^a3,commandchars=^^a7^^b5^^b6,numbersep=3pt]%
90 {\jobname.tmp}
91 \catcode`\^^a3=9\relax
92 \NoHighlight@Attributes % To suppress possible highlighting
93 \ifFvrbEx@Grid\vspace{5pt}\fi
94 #1%
95 \ifFvrbEx@Grid\vspace{5pt}\fi
96 \par}
97 \newcommand{\SideBySide@Example}[1]{%
98 \@tempdimb=\FV@XRightMargin
99 \advance\@tempdimb -5mm
100 \begin{minipage}[c]{\@tempdimb}
101 \fvset{xrightmargin=0pt}
102 \catcode`\^^a3=9\relax%
103 \NoHighlight@Attributes % To suppress possible highlighting
104 #1
105 \end{minipage}%
106 \@tempdimb=\textwidth
107 \advance\@tempdimb -\FV@XRightMargin
108 \advance\@tempdimb 5mm
109 \begin{minipage}[c]{\@tempdimb}
110 \VerbatimInput[gobble=0,commentchar=^^a3,commandchars=^^a7^^b5^^b6,numbersep=3pt,
111 xleftmargin=5mm,xrightmargin=0pt]{\jobname.tmp}
112 \end{minipage}}
113 \ifx\PSTricksLoaded\endinput
114 \newcommand\showgrid{\FvrbEx@Gridtrue}
115 \newpsobject{FvrbExGrid}{psgrid}{subgriddiv=0,griddots=10,gridlabels=7pt}
116 \def\PCenterExample{\@ifnextchar[{\Pst@Example}{\Pst@@Example}}
117 \def\endPCenterExample{%
118 \end{VerbatimOut}%
119 \Below@Example{%
120 \center
121 \expandafter\pspicture\Picture@Size
122 \ifFvrbEx@Grid\FvrbExGrid\fi\relax
123 \input{\jobname.tmp}%
124 \endpspicture
125 \endcenter
126 \smallskip}}
127 \def\PSideBySideExample{\@ifnextchar[{\Pst@Example}{\Pst@@Example}}
128 \def\endPSideBySideExample{%
129 \end{VerbatimOut}%
130 \SideBySide@Example{%
131 \ifFvrbEx@Grid\vspace{5pt}\fi
132 \expandafter\pspicture\Picture@Size
133 \ifFvrbEx@Grid\FvrbExGrid\fi\relax
134 \input{\jobname.tmp}%
135 \endpspicture
136 \ifFvrbEx@Grid\vspace{5pt}\fi
137 \smallskip}}
138 \def\Pst@Example[#1]{\fvset{#1}\Pst@@Example}
139 \def\Pst@@Example#1(#2,#3){%
140 \catcode`\^^M=\active
141 \@ifnextchar({\catcode`\^^M=5\Pst@@@Example(#2,#3)}
142 {\catcode`\^^M=5\Pst@@@Example(0,0)(#2,#3)}}
143 \def\Pst@@@Example(#1,#2)(#3,#4){%
144 \def\Picture@Size{(#1,#2)(#3,#4)}%
145 \Begin@Example}
146 \fi % End \ifx\PSTricksLoaded
147 %%
148 \endinput
149 %%
150 %% End of file `fancyvrb-ex.sty'.