remove empty dir
[ghc-hetmet.git] / docs / ext-core / code.sty
1
2 % I have enclosed code.sty, which achieves 99% of what you want without
3 % the need for a separate preprocessor. At the start of your document
4 % you write "\makeatactive". From then on, inline code is written as @\x
5 % -> x_1 & y@. The only difference with what you are used to, is that
6 % instead of
7
8 % @
9 %   foo :: Int -> Int
10 %   foo = \n -> n+1
11 % @
12
13 % you have to write
14
15 % \begin{code}
16 %   foo :: Int -> Int
17 %   foo = \n -> n+1
18 % \end{code}
19
20 % and that you cannot use @ in \section{} and \caption{}. For the paper that occured twice, in which case I had to replace @...@ b y \texttt{...}.
21
22
23 % code.sty  --- nice verbatim mode for code
24
25 \def\icode{%
26     \relax\ifmmode\hbox\else\leavevmode\null\fi
27     \bgroup
28     %\begingroup
29     \@noligs
30     \verbatim@font
31     \verb@eol@error
32     \let\do\@makeother \dospecials
33     \@vobeyspaces
34     \frenchspacing
35     \@icode}
36 \def\@icode#1{%
37     \catcode`#1\active
38     \lccode`\~`#1%
39     \lowercase{\let~\icode@egroup}}
40 \def\icode@egroup{%
41     %\endgroup}
42     \egroup}
43
44 % The \makeatactive command:
45 % makes @ active, in such a way that @...@ behaves as \icode@...@:
46 {
47 \catcode`@=\active
48 \gdef\makeatactive{
49      \catcode`@=\active \def@{\icode@}
50      % Since @ becomes active, it has to be taken care of in verbatim-modes:
51      \let\olddospecials\dospecials \def\dospecials{\do\@\olddospecials}}
52 }
53 % \gdef\makeatother{\g@remfrom@specials{\@}\@makeother\@}
54 \gdef\makeatother{\@makeother\@}
55
56 \newcommand\codetabwidth{42pt}
57 {\catcode`\^^I=\active%
58 \gdef\@vobeytab{\catcode`\^^I\active\let^^I\@xobeytab}}
59 \def\@xobeytab{\leavevmode\penalty10000\hskip\codetabwidth}
60
61 \begingroup \catcode `|=0 \catcode `[= 1
62 \catcode`]=2 \catcode `\{=12 \catcode `\}=12
63 \catcode`\\=12 |gdef|@xcode#1\end{code}[#1|end[code]]
64 |endgroup
65 \def\@code{\trivlist \item\relax
66   \if@minipage\else\vskip\parskip\fi
67   \leftskip\@totalleftmargin\rightskip\z@skip
68   \parindent\z@\parfillskip\@flushglue\parskip\z@skip
69   \@@par
70   \@tempswafalse
71   \def\par{%
72     \if@tempswa
73       \leavevmode \null \@@par\penalty\interlinepenalty
74     \else
75       \@tempswatrue
76       \ifhmode\@@par\penalty\interlinepenalty\fi
77     \fi}%
78   \obeylines \verbatim@font \@noligs
79   \let\do\@makeother \dospecials
80   \everypar \expandafter{\the\everypar \unpenalty}%
81 }
82 \def\code{\@code \frenchspacing\@vobeytab\@vobeyspaces \@xcode}
83 \def\endcode{\if@newlist \leavevmode\fi\endtrivlist}