2 % Some utilities for formatting (extended) lambda calculus and
6 \startuseMPgraphic{HLine}
8 % Create a rectangle of the full size
9 a := origin -- (\MPvar{width}, 0mm);
11 b := a randomized (\overlaywidth / 50) ;
13 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
17 % Draw a line with the given options. Accepts only the 'width' option. Be
18 % careful that these are metapost options, so use \the\textwidth instead of
19 % textwidth, and a metapost expression for arithmethic (e.g. 0.5 *
20 % \the\textwidth instead of 0.5\textwidth).
22 {\setupMPvariables[HLine][#1]%
25 \startuseMPgraphic{HDLine}
27 % Create a rectangle of the full size
28 a := origin -- (\MPvar{width}, 0mm);
30 b := a randomized (\overlaywidth / 100) ;
32 drawoptions (withpen pencircle scaled .75mm withcolor black dashed evenly) ;
36 % Draw a line with the given options. Accepts only the 'width' option. Be
37 % careful that these are metapost options, so use \the\textwidth instead of
38 % textwidth, and a metapost expression for arithmethic (e.g. 0.5 *
39 % \the\textwidth instead of 0.5\textwidth).
41 {\setupMPvariables[HDLine][#1]%
42 \useMPgraphic{HDLine}}
44 \startuseMPgraphic{box}
46 % Create a rectangle of the full size
47 a := unitsquare xyscaled(\overlaywidth,\overlayheight);
49 b := a randomized (min(\overlayheight, \overlaywidth) / 25) ;
51 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
55 \defineoverlay[box][\useMPgraphic{box}]
57 % Define \{start,stop}boxed with a nice metapost box around it.
58 \defineframedtext[boxed][width=fit,background=box,frame=off]
60 % Install the lambda calculus pretty-printer, as defined in pret-lam.lua.
61 \installprettytype [LAM] [LAM]
62 % Define \startlambda \stoplambda
63 \definetyping[lambda][option=LAM,style=sans,before=\startboxed,after=\stopboxed,strip=auto]
64 % Define \startunboxedlambda \stopunboxedlambda
65 \definetyping[unboxedlambda][option=LAM,style=sans,strip=auto]
67 % Define \lam{} (since \lambda is taken)
68 \definetype[lam][option=LAM,style=sans]
70 % Install the transformation pretty-printer, as defined in pret-trans.lua.
71 \installprettytype [TRANS] [TRANS]
72 % Define \starttrans \stoptrans
73 \definetyping[trans][option=TRANS,style=normal,before=\startboxed,after=\stopboxed,strip=auto]
75 % Install the haskell pretty-printer, as defined in pret-haskell.lua.
76 \installprettytype [HASKELL] [HASKELL]
77 % Define \starthaskell \stophaskell
78 \definetyping[haskell][option=HASKELL,before=\startboxed,after=\stopboxed,strip=auto]
80 \definetype[hs][option=HASKELL,style=mono]
82 % Define \startvhdl \stopvhdl
83 \definetyping[vhdl][numbering=line,before={\startboxed},after={\stopboxed}]
85 % Type the given buffer with the lambda typing style.
86 % e.g., \typebufferlam{buffname}
87 \define[1]\typebufferlam{
88 % We can't use \startlambda here defined by definetyping[lambda] above when
89 % typing buffers, so instead we'll redfine the options here.
90 \setuptyping[option=LAM,style=sans,before=,after=,strip=auto]
94 % Reset the typing options
95 \setuptyping[option=none,style=\tttf,strip=auto]
98 % Type the given buffer with the haskell typing style.
99 % e.g., \typebufferhs{buffname}
100 \define[1]\typebufferhs{
101 % We can't use \startlambda here defined by definetyping[lambda] above when
102 % typing buffers, so instead we'll redfine the options here.
103 \setuptyping[option=HASKELL,style=mono,strip=auto]
107 % Reset the typing options
108 \setuptyping[option=none,style=\tttf,strip=auto]
111 % Type the given buffer with the vhdl typing style.
112 % e.g., \typebuffervhdl{buffname}
113 \define[1]\typebuffervhdl{
114 % We can't use \startvhdl here defined by definetyping[vhdl] above when
115 % typing buffers, so instead we'll redefine the options here.
116 \setuptyping[style=mono,strip=auto,numbering=line]
120 % Reset the typing options
121 \setuptyping[option=none,style=\tttf,strip=auto]
124 % Display a useMPgraphic in a pretty box
125 \define[1]\boxedgraphic{
131 \setupcaption[figure][location=top] % Put captions on top
132 % Define an "example" float. Don't add box around it, since an example will
133 % commonly contain two boxed items (Before / after, code / picture).
134 % Make an example use the same numbering as a figure.
135 \definefloat[example][examples][figure]
136 \setupcaption[example][location=top] % Put captions on top
137 % Define a definition float that shares its numbering and setting with
139 \definefloat[definition][definitions][figure]
140 \setupcaption[example][location=top] % Put captions on top
141 % Make sure the labels really say Definition and Example instead of
142 % Figure. This seems to be a bug in ConTeXt (\redodefinefloat in
143 % strc-flt.mkiv has \presetlabeltext[#1=\Word{#3}~]% which should
144 % reference #1 instead of #3).
145 \setuplabeltext[en][definition=Definition]
146 \setuplabeltext[en][example=Example]
148 % Margin magic taken from
149 % http://www.pragma-ade.com/general/manuals/details.pdf By setting negative
150 % margin distances, we put our float inside the outer margin. I think we set
151 % both left and right margin distance, because we don't know what will be the
152 % outer margin (and it will probably only use the distance of the margin it's
153 % actually aligning against).
154 % The default= option corresponds to the first option to \placefloat.
155 % outer puts it in the outer margin, none means no caption, high means
156 % no spacing at the top (placing it high wrt the text) and low means no
157 % spacing at the bottom.
158 \setupfloat[intermezzo][leftmargindistance=-\leftmarginwidth, rightmargindistance=-\rightmarginwidth, default={outer,none,low,high}]
160 % Let floats float next to titles, instead of inserting whitespace so a
161 % section head comes after a float.
162 \setupheads[aligntitle=float]
164 % A variant of \startquotation that puts a citation directly after the
166 \long\def\startcitedquotation[#1]#2\stopcitedquotation
169 \symbol[leftquotation]%
170 #2\removeunwantedspaces
171 \symbol[rightquotation]%
176 % vim: set sw=2 sts=2 expandtab: