File: polycode.fmt

package info (click to toggle)
frown 0.6.1-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,956 kB
  • sloc: haskell: 35,132; makefile: 228; csh: 35; yacc: 23
file content (74 lines) | stat: -rw-r--r-- 2,408 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%if False
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% polycode.fmt
%
% better code environment for poly style in lhs2TeX
%
% Andres Loeh, August 2004, ver 1.0
%
% TODO: split in fmt and sty
%       use \[ \] in arrayhs (fleqn problem)
%       think about penalties and better pagebreaks
%         by using \allowdisplaybreaks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%endif

%if False
% The follwing subst replaces the bad default from lhs2TeX.fmt.
% The idea is to just provide the basic structure in the subst, and
% let the rest be handled by a LaTeX environment.
%endif

%subst code a = "\begin{arrayhscode}\SaveRestoreHook'n" a "\ColumnHook'n\end{arrayhscode}\resethooks'n"


% This package provides two environments suitable to take the place
% of hscode, called "plainhscode" and "arrayhscode". 

% The plain environment surrounds each code block by vertical space,
% and it uses \abovedisplayskip and \belowdisplayskip to get spacing
% similar to formulas. Note that if these dimensions are changed,
% the spacing around displayed math formulas changes as well.
% All code is indented using \leftskip.

\newenvironment{plainhscode}%
  {\parskip=\abovedisplayskip\par\noindent
   \advance\leftskip\mathindent
   \(\pboxed}%
  {\endpboxed\)%
   \parskip=\belowdisplayskip\par\noindent}

% The command \sethscode can be used to switch the code formatting
% behaviour by mapping the hscode environment in the subst directive
% to a new LaTeX environment.

\newcommand{\sethscode}[1]%
  {\expandafter\let\expandafter\hscode\csname #1\endcsname
   \expandafter\let\expandafter\endhscode\csname end#1\endcsname}

% Here, we make plainhscode the default environment.

\newcommand{\plainhs}{\sethscode{plainhscode}}
\plainhs

% The arrayhscode is like plain, but makes use of polytable's
% parray environment which disallows page breaks in code blocks.

\newenvironment{arrayhscode}%
  {\parskip=\abovedisplayskip\par\noindent
   \advance\leftskip\mathindent
   \(\parray}%
  {\endparray\)%
   \parskip=\belowdisplayskip\par\noindent}

\newcommand{\arrayhs}{\sethscode{arrayhscode}}

% The mathhscode environment also makes use of polytable's parray 
% environment. It is supposed to be used only inside math mode 
% (I used it to typeset the type rules in my thesis).

\newenvironment{mathhscode}%
  {\parray}{\endparray}

\newcommand{\mathhs}{\sethscode{mathhscode}}