~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to notes/papers/iird/polycode.fmt

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%if False
2
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
 
% polycode.fmt
4
 
%
5
 
% better code environment for poly style in lhs2TeX
6
 
%
7
 
% Permission is granted to include this file (or parts of this file) 
8
 
% literally into other documents, regardless of the conditions or 
9
 
% license applying to these documents.
10
 
%
11
 
% Andres Loeh, February 2006, ver 1.9
12
 
%
13
 
% TODO: use \[ \] in arrayhs (fleqn problem)
14
 
%       think about penalties and better pagebreaks
15
 
%         by using \allowdisplaybreaks
16
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
 
%endif
18
 
%if not lhs2tex_polycode_fmt_read
19
 
%let lhs2tex_polycode_fmt_read = True
20
 
%include lhs2TeX.fmt
21
 
%
22
 
%if style /= newcode
23
 
%
24
 
%if False
25
 
% The follwing subst replaces the bad default from lhs2TeX.fmt.
26
 
% The idea is to just provide the basic structure in the subst, and
27
 
% let the rest be handled by a LaTeX environment.
28
 
%endif
29
 
%
30
 
%subst code a = "\begin{hscode}\SaveRestoreHook'n" a "\ColumnHook'n\end{hscode}\resethooks'n"
31
 
%
32
 
%
33
 
% This package provides two environments suitable to take the place
34
 
% of hscode, called "plainhscode" and "arrayhscode". 
35
 
%
36
 
% The plain environment surrounds each code block by vertical space,
37
 
% and it uses \abovedisplayskip and \belowdisplayskip to get spacing
38
 
% similar to formulas. Note that if these dimensions are changed,
39
 
% the spacing around displayed math formulas changes as well.
40
 
% All code is indented using \leftskip.
41
 
%
42
 
% Changed 19.08.2004 to reflect changes in colorcode. Should work with
43
 
% CodeGroup.sty.
44
 
%
45
 
\ReadOnlyOnce{polycode.fmt}%
46
 
\makeatletter
47
 
 
48
 
\newcommand{\hsnewpar}[1]%
49
 
  {{\parskip=0pt\parindent=0pt\par\vskip #1\noindent}}
50
 
 
51
 
% can be used, for instance, to redefine the code size, by setting the
52
 
% command to \small or something alike
53
 
\newcommand{\hscodestyle}{}
54
 
 
55
 
% The command \sethscode can be used to switch the code formatting
56
 
% behaviour by mapping the hscode environment in the subst directive
57
 
% to a new LaTeX environment.
58
 
 
59
 
\newcommand{\sethscode}[1]%
60
 
  {\expandafter\let\expandafter\hscode\csname #1\endcsname
61
 
   \expandafter\let\expandafter\endhscode\csname end#1\endcsname}
62
 
 
63
 
% "compatibility" mode restores the non-polycode.fmt layout.
64
 
 
65
 
\newenvironment{compathscode}%
66
 
  {\par\noindent
67
 
   \advance\leftskip\mathindent
68
 
   \hscodestyle
69
 
   \let\\=\@@normalcr
70
 
   \(\pboxed}%
71
 
  {\endpboxed\)%
72
 
   \par\noindent
73
 
   \ignorespacesafterend}
74
 
 
75
 
\newcommand{\compaths}{\sethscode{compathscode}}
76
 
 
77
 
% "plain" mode is the proposed default.
78
 
 
79
 
\newenvironment{plainhscode}%
80
 
  {\hsnewpar\abovedisplayskip
81
 
   \advance\leftskip\mathindent
82
 
   \hscodestyle
83
 
   \let\\=\@@normalcr
84
 
   \(\pboxed}%
85
 
  {\endpboxed\)%
86
 
   \hsnewpar\belowdisplayskip
87
 
   \ignorespacesafterend}
88
 
 
89
 
% Here, we make plainhscode the default environment.
90
 
 
91
 
\newcommand{\plainhs}{\sethscode{plainhscode}}
92
 
\plainhs
93
 
 
94
 
% The arrayhscode is like plain, but makes use of polytable's
95
 
% parray environment which disallows page breaks in code blocks.
96
 
 
97
 
\newenvironment{arrayhscode}%
98
 
  {\hsnewpar\abovedisplayskip
99
 
   \advance\leftskip\mathindent
100
 
   \hscodestyle
101
 
   \let\\=\@@normalcr
102
 
   \(\parray}%
103
 
  {\endparray\)%
104
 
   \hsnewpar\belowdisplayskip
105
 
   \ignorespacesafterend}
106
 
 
107
 
\newcommand{\arrayhs}{\sethscode{arrayhscode}}
108
 
 
109
 
% The mathhscode environment also makes use of polytable's parray 
110
 
% environment. It is supposed to be used only inside math mode 
111
 
% (I used it to typeset the type rules in my thesis).
112
 
 
113
 
\newenvironment{mathhscode}%
114
 
  {\parray}{\endparray}
115
 
 
116
 
\newcommand{\mathhs}{\sethscode{mathhscode}}
117
 
 
118
 
% texths is similar to mathhs, but works in text mode.
119
 
 
120
 
\newenvironment{texthscode}%
121
 
  {\(\parray}{\endparray\)}
122
 
 
123
 
\newcommand{\texths}{\sethscode{texthscode}}
124
 
 
125
 
% The framed environment places code in a framed box.
126
 
 
127
 
\def\codeframewidth{\arrayrulewidth}
128
 
\RequirePackage{calc}
129
 
 
130
 
\newenvironment{framedhscode}%
131
 
  {\parskip=\abovedisplayskip\par\noindent
132
 
   \hscodestyle
133
 
   \arrayrulewidth=\codeframewidth
134
 
   \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%
135
 
   \hline\framedhslinecorrect\\{-1.5ex}%
136
 
   \let\endoflinesave=\\
137
 
   \let\\=\@@normalcr
138
 
   \(\pboxed}%
139
 
  {\endpboxed\)%
140
 
   \framedhslinecorrect\endoflinesave{.5ex}\hline
141
 
   \endtabular
142
 
   \parskip=\belowdisplayskip\par\noindent
143
 
   \ignorespacesafterend}
144
 
 
145
 
\newcommand{\framedhslinecorrect}[2]%
146
 
  {#1[#2]}
147
 
 
148
 
\newcommand{\framedhs}{\sethscode{framedhscode}}
149
 
 
150
 
% The inlinehscode environment is an experimental environment
151
 
% that can be used to typeset displayed code inline.
152
 
 
153
 
\newenvironment{inlinehscode}%
154
 
  {\(\def\column##1##2{}%
155
 
   \let\>\undefined\let\<\undefined\let\\\undefined
156
 
   \newcommand\>[1][]{}\newcommand\<[1][]{}\newcommand\\[1][]{}%
157
 
   \def\fromto##1##2##3{##3}%
158
 
   \def\nextline{}}{\) }%
159
 
 
160
 
\newcommand{\inlinehs}{\sethscode{inlinehscode}}
161
 
 
162
 
% The joincode environment is a separate environment that
163
 
% can be used to surround and thereby connect multiple code
164
 
% blocks.
165
 
 
166
 
\newenvironment{joincode}%
167
 
  {\let\orighscode=\hscode
168
 
   \let\origendhscode=\endhscode
169
 
   \def\endhscode{\def\hscode{\endgroup\def\@@currenvir{hscode}\\}\begingroup}
170
 
   %\let\SaveRestoreHook=\empty
171
 
   %\let\ColumnHook=\empty
172
 
   %\let\resethooks=\empty
173
 
   \orighscode\def\hscode{\endgroup\def\@@currenvir{hscode}}}%
174
 
  {\origendhscode
175
 
   \global\let\hscode=\orighscode
176
 
   \global\let\endhscode=\origendhscode}%
177
 
 
178
 
\makeatother
179
 
\EndFmtInput
180
 
%
181
 
%endif
182
 
%endif