%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % VRBSUBFILE.STY % % Copyright (c) 1993 by Norman Walsh, All Rights Reserved. % Copy freely as per the GNU Copyleft. % % Requires: % The New Font Selection Scheme (NFSS) % VERBATIM.STY by Rainer Schoepf % VRBINPUT.STY by Bernd Raichle. % % VRBSUBFILE allows you to perform verbatim input of subsections of % a file. I wrote it in anticipation of documenting some shell scripts % and I want to be able to incorporate a few lines of shell script % in verbatim mode then write a few lines or paragraphs of documentation % then incorporate a few more lines of shell script, etc. % % Optionally, verbatim lines are numbered. % % Comments and suggestions always welcome. % Norman Walsh % Graduate Computer Science Department % University of Massachusetts % Amherst, MA 01003 % % User interface: % VerbatimSubfile[#1]#2#3#4 % Input lines #2 to #3 of file #4. If present, #1 indicates which lines % should be numbered. For example, if #1 is 5, lines 5, 10, 15, etc. % will be numbered. By default, lines are not numbered at all. % % VerbatimSubfileFont[#1]#2 % Use font #2 for verbatim input lines and, if present, use font #1 for % line numbers. By default, #2 is \tt and #1 is \rm\tiny. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\fileversion{v1.0} \def\filedate{93/03/01} \typeout{Style-Option: `vrbsubfile' \fileversion \space <\filedate> (ndw)} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \newcounter{Verb@LineNo} % current line number \newcounter{Verb@LineMod} % modulo to print on \newcounter{Verb@LineLoop} % loop count in line number (1..Mod) \newcounter{Verb@LineStart} % first line to print \newcounter{Verb@LineCount} % number of lines to print \newcounter{Verb@PrintFlag} % print this line? % %%%% Default verbatim font and verbatim line number font \def\Verb@sfFont{\tt} \def\Verb@sfLineNumFont{\rm\tiny} % %%%% Macros to change fonts \def\Verb@setbothfonts[#1]#2{% \def\Verb@sfFont{#2}% \def\Verb@sfLineNumFont{#1}% } \def\Verb@setverbfont#1{% \def\Verb@sfFont{#1}% } \def\VerbatimSubfileFont{\@ifnextchar[{\Verb@setbothfonts}{\Verb@setverbfont}} % %%%% Internal macro that does the work... \def\Verb@subfile#1{\begingroup% \def\verbatim@font{\Verb@sfFont\selectfont} \setcounter{Verb@LineNo}{0}% \setcounter{Verb@LineLoop}{0}% \parskip=0pt \def\verbatim@processline{% \addtocounter{Verb@LineNo}{1}% \addtocounter{Verb@LineLoop}{1}% \setcounter{Verb@PrintFlag}{1}% \ifnum\theVerb@LineStart>0% we haven't reached the first line yet... \setcounter{Verb@PrintFlag}{0}% \addtocounter{Verb@LineStart}{-1}% \else% \ifnum\theVerb@LineCount=0% we're out of the "printable" region \setcounter{Verb@PrintFlag}{0}% \else% \addtocounter{Verb@LineCount}{-1}% decrease the line count \fi% \fi% % debugging... %\typeout{Start: \theVerb@LineStart, Count: \theVerb@LineCount, % Print: \theVerb@PrintFlag, Loop: \theVerb@LineLoop, % Mod: \theVerb@LineMod}% \ifnum\theVerb@PrintFlag=1% \leavevmode% \ifnum\theVerb@LineLoop=\theVerb@LineMod% \llap{{\Verb@sfLineNumFont\selectfont \theVerb@LineNo}% \ \hskip\@totalleftmargin}% \setcounter{Verb@LineLoop}{0}% \else% \llap{\phantom{\Verb@sfLineNumFont\selectfont 0}\ % \hskip\@totalleftmargin}% \fi% \the\verbatim@line\par% \else% \ifnum\theVerb@LineLoop=\theVerb@LineMod% \setcounter{Verb@LineLoop}{0}% \fi% \fi}% \verbatiminput{#1}\endgroup}% % %%%% Macros to request verbatim subfiles \def\Verb@subfilePlain#1#2#3{% \setcounter{Verb@LineMod}{-1} \setcounter{Verb@LineStart}{#1} \setcounter{Verb@LineCount}{#2} \addtocounter{Verb@LineCount}{-\theVerb@LineStart} \addtocounter{Verb@LineCount}{1} \addtocounter{Verb@LineStart}{-1} \Verb@subfile{#3} } \def\Verb@subfileNumbered[#1]#2#3#4{% \setcounter{Verb@LineMod}{#1} \setcounter{Verb@LineStart}{#2} \setcounter{Verb@LineCount}{#3} \addtocounter{Verb@LineCount}{-\theVerb@LineStart} \addtocounter{Verb@LineCount}{1} \addtocounter{Verb@LineStart}{-1} \Verb@subfile{#4} } \def\VerbatimSubfile{\@ifnextchar[{\Verb@subfileNumbered}{\Verb@subfilePlain}} % %%%% EOF