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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
[INHERIT('UTILITYOPS','ARGOPS','BASICFILEOPS',
'TREEANDLISTOPS','FLAGOPS'), environment('latexops')]
MODULE LATEXOPS;
TYPE
countparametertype = (numericcounter, lowercasechars, uppercasechars );
parameterchangestates = (nochange, altered, assigned);
pagestyletype = (empty, plain, headings, myheadings);
liststatetype = (nostate, itemize, enumerate);
VAR
LOG : [EXTERNAL] TEXT;
pagestyle : [EXTERNAL] pagestyletype;
datestring : [EXTERNAL] pckstr;
title, subtitle : [EXTERNAL] argarray;
fill : [EXTERNAL] boolean;
centering : [EXTERNAL] boolean;
flushright : [EXTERNAL] boolean;
minipageactive : [EXTERNAL] boolean;
inmarginpar : [EXTERNAL] boolean;
infootnote : [EXTERNAL] boolean;
underlineactive : [EXTERNAL] enhancmentstates;
boldactive : [EXTERNAL] enhancmentstates;
listnestlevel : [EXTERNAL] integer;
PROCEDURE startlatex( var outfile : text; outputfont : integer ; outputstyle: pckstr );
const
minfont = 10;
maxfont = 12;
var
pt : integer;
begin
pt := outputfont;
if (pt < minfont) or (pt > maxfont) then
pt := minfont;
writeln(outfile,'%');
if pt = 10 then
writeln(outfile,'\documentstyle{',outputstyle,'}')
else
writeln(outfile,'\documentstyle[',pt:2,'pt]{',outputstyle,'}');
writeln(outfile,'%');
writeln(outfile,'% (put preamble statements here) ');
writeln(outfile,'%');
writeln(outfile,'\begin{document}');
writeln(outfile,'%')
end;
[GLOBAL] PROCEDURE closeanyopenbrackets( var outfile : text );
var
i : integer;
begin
if not fill then
writeln(outfile,'} % - end of obeylines and obeyspaces group');
if centering then
writeln(outfile,'\end{centering}');
if flushright then
writeln(outfile,'\end{flushright}');
if minipageactive then
writeln(outfile,'\end{minipage}');
if inmarginpar then
writeln(outfile,'} % - end of margin par ');
if infootnote then
writeln(outfile,'} % - end of footnote');
if inliteral then
writeln(outfile,'\end{verbatim}');
for i := 1 to listnestlevel do
writeln(outfile,'\end{itemize} % - RNOTOTEX forced list close');
stopunderline( outfile );
stopbold( outfile )
end;
[GLOBAL] PROCEDURE endlatex( var outfile : text );
begin
closeanyopenbrackets( outfile );
writeln(outfile,'%');
writeln(outfile,'% (put postamble statements here) ');
writeln(outfile,'%');
writeln(outfile,'\end{document}')
end;
[GLOBAL] PROCEDURE adjustpagestyle( var f : text; newstyle : pagestyletype);
begin
pagestyle := newstyle;
case pagestyle of
empty : writeln(f,'\pagestyle{empty}');
plain : writeln(f,'\pagestyle{plain}');
headings : writeln(f,'\pagestyle{headings}');
myheadings : begin
writeln(f,'\pagestyle{myheadings}');
write(f,'\markright{');
writeargarray(f, title);
writeargarray(f, subtitle);
write(f, datestring );
writeln(f,'}')
end
end;
case pagestyle of
empty : writeln(log,'\pagestyle{empty}');
plain : writeln(log,'\pagestyle{plain}');
headings : writeln(log,'\pagestyle{headings}');
myheadings : begin
writeln(log,'\pagestyle{myheadings}');
write(log,'\markright{');
writeargarray(log, title);
writeargarray(log, subtitle);
write(log, datestring );
writeln(log,'}')
end
end
end;
[GLOBAL] PROCEDURE writecharwidth( var f : text; nchars : integer);
const
widthofcharincm = 0.254; { 10 chars per inch, 2.54 cm per inch }
maxwidth = 20.0;
minwidth = -20.0;
var
cm : real;
begin
cm := nchars * widthofcharincm;
if cm > maxwidth then
begin
writeln(log,'[too many chars to skip, ',nchars,' = ',cm:10:2,'cm]');
cm := 1.0
end;
if cm < minwidth then
begin
writeln(log,'[too many chars to skip ',nchars,' = ',cm:10:2,'cm]');
cm := -1.0
end;
write(f, cm:6:2, 'cm ');
write(log, cm:6:2,'cm ')
end;
[GLOBAL] PROCEDURE writecharheight( var f : text; nlines : integer );
const
heightoftextincm = 0.425; { 6 lines per inch, 2.54 cm per inch }
maxheight = 25.0;
minheight = -25.0;
var
cm : real;
begin
cm := nlines * heightoftextincm;
if cm > maxheight then
begin
writeln(log,'[too many lines to skip, ',nlines,' = ',cm:10:2,'cm]');
cm := 1.0
end;
if cm < minheight then
begin
writeln(log,'[too many lines to skip ',nlines,' = ',cm:10:2,'cm]');
cm := -1.0
end;
write(f, cm:6:2,'cm ');
write(log, cm:6:2,'cm ')
end;
[GLOBAL] PROCEDURE adjustlength( var outfile : text; modified : parameterchangestates;
lengthvalue : integer; adjustmentvalue : integer; charwidth : boolean;
latexname : pckstr );
begin
case modified of
nochange : nullstatement;
altered : begin
write(outfile,'\addtolength{',latexname,'}{');
if charwidth then
writecharwidth(outfile, adjustmentvalue)
else
writecharheight(outfile, adjustmentvalue);
writeln(outfile,'}')
end;
assigned : begin
write(outfile,'\setlength{',latexname,'}{');
if charwidth then
writecharwidth(outfile, lengthvalue)
else
writecharheight(outfile, lengthvalue);
writeln(outfile,'}')
end
end;
case modified of
nochange : noconversion;
altered : begin
write(log,'\addtolength{',latexname,'}{');
if charwidth then
writecharwidth(log, adjustmentvalue)
else
writecharheight(log, adjustmentvalue);
writeln(log,'}')
end;
assigned : begin
write(log,'\setlength{',latexname,'}{');
if charwidth then
writecharwidth(log, lengthvalue)
else
writecharheight(log, lengthvalue);
writeln(log,'}')
end
end
end;
[GLOBAL] PROCEDURE adjustcounter( var outfile : text; modified : parameterchangestates;
countervalue : integer; adjustmentvalue : integer; latexname : pckstr );
begin
case modified of
nochange : nullstatement;
altered : writeln(outfile,'\addtocounter{',latexname,'}{',adjustmentvalue,'}');
assigned : writeln(outfile,'\setcounter{',latexname,'}{',countervalue,'}')
end;
case modified of
nochange : noconversion;
altered : writeln(log,'\addtocounter{',latexname,'}{',adjustmentvalue,'}');
assigned : writeln(log,'\setcounter{',latexname,'}{',countervalue,'}')
end
end;
[GLOBAL] PROCEDURE adjuststyle(var outfile : text; s : styletype;
latexname : pckstr );
begin
case s of
undetermined : nullstatement;
decimal : writeln(outfile,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
octal : writeln(outfile,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
hexidecimal : writeln(outfile,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
romanupper : writeln(outfile,'\renewcommand{\the',latexname,'}{\Roman{',latexname,'}}');
romanlower : writeln(outfile,'\renewcommand{\the',latexname,'}{\roman{',latexname,'}}');
romanmixed : writeln(outfile,'\renewcommand{\the',latexname,'}{\roman{',latexname,'}}');
letterupper : writeln(outfile,'\renewcommand{\the',latexname,'}{\Alpha{',latexname,'}}');
letterlower : writeln(outfile,'\renewcommand{\the',latexname,'}{\alpha{',latexname,'}}');
lettermixed : writeln(outfile,'\renewcommand{\the',latexname,'}{\alpha{',latexname,'}}');
nostyle : nullstatement
end;
case s of
undetermined : noconversion;
decimal : writeln(log,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
octal : writeln(log,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
hexidecimal : writeln(log,'\renewcommand{\the',latexname,'}{\arabic{',latexname,'}}');
romanupper : writeln(log,'\renewcommand{\the',latexname,'}{\Roman{',latexname,'}}');
romanlower : writeln(log,'\renewcommand{\the',latexname,'}{\roman{',latexname,'}}');
romanmixed : writeln(log,'\renewcommand{\the',latexname,'}{\roman{',latexname,'}}');
letterupper : writeln(log,'\renewcommand{\the',latexname,'}{\Alpha{',latexname,'}}');
letterlower : writeln(log,'\renewcommand{\the',latexname,'}{\alpha{',latexname,'}}');
lettermixed : writeln(log,'\renewcommand{\the',latexname,'}{\alpha{',latexname,'}}');
nostyle : noconversion
end
end;
END.
|