Mercurial > cortex
view thesis/mitthesis/lgrind.sty @ 421:c2c28c3e27c4
get mit thesis template file.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 21 Mar 2014 00:08:49 -0400 |
parents | |
children |
line wrap: on
line source
1 %%2 %% This is file `lgrind.sty',3 %% generated with the docstrip utility.4 %%5 %% The original source files were:6 %%7 %% lgrind.dtx (with options: `package')8 %%9 %% LGrind is used to format source code of different programming10 %% languages for LaTeX.11 %%12 %% LGrind is a minor adaptation of Jerry Leichter's tgrind for LaTeX,13 %% which was a notable improvement upon Van Jacobsen's tgrind for14 %% plain TeX, which was adapted from vgrind, a troff prettyprinter.15 %%16 %% Based on Van Jacobson's ``tgrindmac'', a macro package for TeX.17 %% Modified, 1987 by Jerry Leichter. Put '@' in all internal names.18 %% Modified, 1991 by George Reilly. Changed name from tgrind to lgrind.19 %% Modified, 1995 by Michael Piefel. Made it work with \LaTeXe.20 \NeedsTeXFormat{LaTeX2e}[1995/06/01]21 \ProvidesPackage{lgrind}22 [1997/01/30 v3.4 LGrind environment and supporting stuff]23 \newcount\lc@unt24 \newcount\ln@xt25 \newcount\LGnuminterval26 \LGnuminterval=1027 \DeclareOption{nolineno}{\LGnuminterval=50000}28 \DeclareOption{lineno5}{\LGnuminterval=5}29 \newif\ifLGleftnum30 \DeclareOption{leftnum}{\LGleftnumtrue}31 \newskip\LGindent32 \LGindent=1.6667\parindent33 \DeclareOption{noindent}{\LGindent=0pt}34 \newif\ifLGnorules35 \DeclareOption{norules}{\LGnorulestrue}36 \newlength{\LGsloppy}37 \setlength{\LGsloppy}{7.2pt}38 \DeclareOption{fussy}{\LGsloppy=0pt}39 \newcommand{\DefaultProc}{\@gobble}40 \newcommand{\DefaultProcCont}{\@gobble}41 \DeclareOption{procnames}{42 \renewcommand{\DefaultProc}[1]{\renewcommand{\Procname}{#1}%43 \global\setbox\procbox=\hbox{\PNsize #1}}44 \renewcommand{\DefaultProcCont}[1]{\renewcommand\Procname{#1}45 \global\setbox\procbox=\hbox{\PNsize\dots #1}}}46 \newbox\procbox47 \newcommand{\Procname}{}48 \ProcessOptions49 \def\BGfont{\sffamily}50 \def\CMfont{\rmfamily\itshape}51 \def\NOfont{\sffamily}52 \def\KWfont{\rmfamily\bfseries}53 \def\STfont{\ttfamily}54 \def\VRfont{\rmfamily}55 \def\PNsize{\BGfont\small}56 \def\LGsize{\small}57 \def\LGfsize{\footnotesize}58 \newif\ifLGinline59 \newif\ifLGd@fault60 \def\LGbegin{\ifLGinline$\hbox\else$$\vbox\fi\bgroup\LGd@faulttrue}61 \def\LGend{\ifLGd@fault\egroup\ifLGinline$\else$$\fi\LGd@faultfalse\fi}62 \newif\ifc@mment63 \newif\ifstr@ng64 \newif\ifright@65 \newbox\ls@far66 \newbox\tb@x67 \newdimen\TBw@d68 \newdimen\@ts69 {\catcode`\_=\active \gdef\@setunder{\let_=\sp@ce}}70 \newcommand{\lgrindheader}{}71 \newcommand{\lgrindfilename}{}\newcommand{\lgrindfilesize}{}72 \newcommand{\lgrindmodyear}{}\newcommand{\lgrindmodmonth}{}73 \newcommand{\lgrindmodday}{}\newcommand{\lgrindmodtime}{}74 \newenvironment{lgrind}[1][1]{%75 \def\Line##1{\L{\LB{##1}}}%76 \newcommand{\Head}[1]{\gdef\lgrindhead{##1}}%77 \newcommand{\File}[6]{\gdef\lgrindfilename{##1}\message{(LGround: ##1)}%78 \gdef\lgrindmodyear{##2}\gdef\lgrindmodmonth{##3}%79 \gdef\lgrindmodday{##4}\gdef\lgrindmodtime{##5}%80 \gdef\lgrindfilesize{##6}}%81 \let\Proc=\DefaultProc%82 \let\ProcCont=\DefaultProcCont%83 \hfuzz=\LGsloppy84 \def\NewPage{\filbreak\bigskip}%85 \ifLGinline86 \def\L##1{\setbox\ls@far\null{\CF\strut##1}\ignorespaces}%87 \else88 \let\r@ghtlno\relax\let\l@ftlno\relax89 \ifnum\LGnuminterval>\z@90 \ifLGleftnum91 \def\l@ftlno{\ifvoid\procbox\ifnum\lc@unt>\ln@xt92 \global\advance\ln@xt by\LGnuminterval93 \llap{{\normalfont\scriptsize\the\lc@unt\quad}}\fi94 \else\llap{\box\procbox\quad}\fi}%95 \else96 \def\r@ghtlno{\ifvoid\procbox\ifnum\lc@unt>\ln@xt97 \global\advance\ln@xt by\LGnuminterval98 \rlap{{\normalfont\scriptsize\enspace\the\lc@unt}}\fi99 \else\rlap{\enspace\box\procbox}\fi}%100 \fi101 \fi102 \def\L##1{\@@par\setbox\ls@far=\null\strut103 \global\advance\lc@unt by1%104 \hbox to \hsize{\hskip\LGindent\l@ftlno ##1\egroup%105 \hfil\r@ghtlno}%106 \ignorespaces}%107 \fi108 \lc@unt=#1\advance\lc@unt by-1%109 \ln@xt=\LGnuminterval\advance\ln@xt by-1%110 \loop\ifnum\lc@unt>\ln@xt\advance\ln@xt by\LGnuminterval\repeat%111 \def\LB{\hbox\bgroup\bgroup\box\ls@far\CF\let\next=}%112 \def\Tab##1{\egroup\setbox\tb@x=\lastbox\TBw@d=\wd\tb@x%113 \advance\TBw@d by 1\@ts\ifdim\TBw@d>##1\@ts114 \setbox\ls@far=\hbox{\box\ls@far \box\tb@x \sp@ce}\else115 \setbox\ls@far=\hbox to ##1\@ts{\box\ls@far \box\tb@x \hfil}\fi\LB}%116 \ifLGinline\def\sp@ce{\hskip .3333em}%117 \else \setbox\tb@x=\hbox{\texttt{0}}%118 \@ts=0.8\wd\tb@x \def\sp@ce{\hskip 1\@ts}\fi119 \catcode`\_=\active \@setunder120 \def\CF{\ifc@mment\CMfont\else\ifstr@ng\STfont\fi\fi}121 \def\N##1{{\NOfont ##1}\global\futurelet\next\ic@r}%122 \def\K##1{{\KWfont ##1}\global\futurelet\next\ic@r}%123 \def\V##1{{\VRfont ##1}\global\futurelet\next\ic@r}%124 \def\ic@r{\let\@tempa\/\ifx.\next\let\@tempa\relax%125 \else\ifx,\next\let\@tempa\relax\fi\fi\@tempa}%126 \def\C{\egroup\bgroup\CMfont \global\c@mmenttrue \global\right@false}%127 \def\CE{\egroup\bgroup \global\c@mmentfalse}%128 \def\S{\egroup\bgroup\STfont \global\str@ngtrue}%129 \def\SE{\egroup\bgroup \global\str@ngfalse}%130 \def\,{\relax \ifmmode\mskip\thinmuskip \else\thinspace \fi}%131 \def\!{\relax \ifmmode\mskip-\thinmuskip \else\negthinspace \fi}%132 \def\CH##1##2##3{\relax\ifmmode ##1\relax133 \else\ifstr@ng ##2\relax\else$##3$\fi\fi }%134 \def\{{\CH\lbrace {\char'173}\lbrace }%135 \def\}{\CH\rbrace {\char'175}\rbrace }%136 \def\1{\CH///}% % /137 \def\2{\CH\backslash {\char'134}\backslash }% % \138 \def\|{\CH|{\char'174}|}%139 \def\<{\CH<<<}%140 \def\>{\CH>>>}%141 \def\*{\CH***}\relax %\relax for DOCSTY142 \def\-{\CH---}%143 \def\_{\ifstr@ng {\char'137}\else144 \leavevmode \kern.06em \vbox{\hrule width.35em}%145 \ifdim\fontdimen\@ne\font=\z@ \kern.06em \fi\fi }%146 \def\&{\textsf{\char'046}}%147 \def\#{{\STfont\char'043}}%148 \def\%{{\char'045}}%149 \def\~{{\char'176}}%150 \def\3{\ifc@mment\ifright@ ''\global\right@false%151 \else``\global\right@true \fi152 \else{\texttt{\char'042}}\fi}%153 \def\4{\ifc@mment'\else {\texttt{\char'015}}\fi}%154 \def\5{{\texttt{\char'136}}}%155 \def\${{\ifmmode\slshape\else\ifdim\fontdimen\@ne\font>\z@\slshape\fi\fi156 \char'044}}% %No $ in \it, use \sl157 \parindent\z@\parskip\z@ plus 1pt\hsize\linewidth%158 \bgroup\BGfont159 }160 {\egroup\@@par} % end of environment lgrind161 \def\lgrinde{\ifLGinline\else\LGsize\fi\begin{lgrind}}162 \def\endlgrinde{\end{lgrind}}163 \def\lagrind{\@ifstar{\@slagrind}{\@lagrind}}165 \def\@lagrind{\@ifnextchar[{\@@lagrind}{\@@lagrind[t]}}166 \def\@slagrind{\@ifnextchar[{\@@slagrind}{\@@slagrind[t]}}167 \def\@@lagrind[#1]#2#3#4{%168 \begin{figure}[#1]169 \ifLGnorules\else\hrule\fi170 \vskip .5\baselineskip171 \begin{minipage}\columnwidth\LGsize\LGindent\z@172 \begin{lgrind}173 \input #2\relax174 \end{lgrind}175 \end{minipage}176 \vskip .5\baselineskip plus .5\baselineskip177 \ifLGnorules\else\hrule\fi\vskip .5\baselineskip178 \begingroup179 \setbox\z@=\hbox{#4}%180 \ifdim\wd\z@>\z@181 \caption{#3}%182 \label{#4}%183 \else184 \captcont{#3}%185 \fi186 \endgroup187 \vskip 2pt188 \end{figure}189 }190 \def\@@slagrind[#1]#2#3#4{%191 \begin{figure*}[#1]192 \ifLGnorules\else\hrule\fi193 \vskip .5\baselineskip194 \begin{minipage}\linewidth\LGsize\LGindent\z@195 \begin{lgrind}196 \input #2\relax197 \end{lgrind}198 \end{minipage}199 \vskip .5\baselineskip plus .5\baselineskip200 \ifLGnorules\else\hrule\fi\vskip .5\baselineskip201 \begingroup202 \setbox\z@=\hbox{#4}%203 \ifdim\wd\z@>\z@204 \caption{#3}%205 \label{#4}%206 \else207 \captcont{#3}%208 \fi209 \endgroup210 \vskip 2pt211 \end{figure*}212 }213 \def\lgrindfile#1{%214 \par\addvspace{0.1in}215 \ifLGnorules\else\hrule\fi216 \vskip .5\baselineskip217 \begingroup\LGfsize\LGindent\z@218 \begin{lgrind}219 \input #1\relax220 \end{lgrind}221 \endgroup222 \vskip .5\baselineskip223 \ifLGnorules\else\hrule\fi224 \addvspace{0.1in}225 }226 \endinput227 %%228 %% End of file `lgrind.sty'.