Debian Codegraph @

texmf-dist/doc/plain/metatex/mtpaper/mtpaper.tex

raw
1
2 \input tugboat.sty
3
4 %\input tugboat.dates
5 %\input tb75pages
6 %\pageno=\TBcasa
7
8 % EXTRA CODE
9
10 \ifx\plaindefaults\undefined \let\next=\relax
11 \else \let\next=\plaindefaults \fi \next
12
13 \input metatex
14 \MTline{input delay.mf;}
15
16 \def\MTeX{{\manual META}\-\TeX}
17 \font\smallsf=cmssq8
18 \font\sf=cmss10
19
20 % END EXTRA CODE
21
22
23 \title * {\MTeX} *
24 \author * Ram\'on Casares *
25 \address * Telef\'onica de Espa\~na *
26 \netaddress * [email protected] *
27
28 \article %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
30
31 \head * Abstract *
32
33 {\MTeX} is a set of {\plain} {\TeX} and {\MF} macros that you can use to
34 define both the text and the figures in a single source file. Because
35 {\MTeX} sets up two way communication, from {\TeX} to {\MF} and back
36 from {\MF} to {\TeX}, drawing dimensions can be controlled by {\TeX} and
37 labels can be located by {\MF}. Only standard features of {\TeX} and
38 {\MF} are used, but two runs of {\TeX} and one of {\MF} are needed.
39
40
41 \head * Overview *
42
43 Together, {\TeX} and {\MF} define the page layout to the pixel. This
44 means that nothing more is needed, not even a means of including figures
45 in a {\TeX} document. To prove this is the aim of this paper.
46
47 To split the typesetting process in two parts, one to define and draw
48 the characters and the other to arrange the characters in paragraphs and
49 pages, is surely the best way to reduce the complexity of the
50 typesetting task, provided it needs simplification (see Figure~1). But
51 this method makes it difficult, for example, to integrate labels with
52 graphics in figures, because while {\TeX} is best suited to typeset the
53 labels, {\MF} is the appropriate tool to draw the graphics. And, of
54 course, labels should be located in accordance with the graphics.
55
56 Therefore, the true successor of {\TeX} has to include in a single
57 program both the capabilities of {\TeX} and {\MF}. Then the typesetting
58 engine would include a powerful graphic tool, a grid in which to typeset if
59 required, and it could take into account the shapes of the characters to
60 determine, for example, kernings or italic corrections. The other way
61 around is also possible. It could be seen as a graphic engine with a
62 powerful typesetting tool. From this point of view, the page would be a
63 graphic object that could contain paragraphs of different shapes
64 requested from the typesetting tool.
65
66 \MTeX, although it does not fulfill the requirements of such a
67 successor, can be seen as an early sign of its possibilities. For the
68 moment, {\MTeX} takes advantage of {\MF}'s equation solving capabilities
69 to locate objects, including the labels, which are typeset by {\TeX}. The
70 cost of this nice feature is that two {\TeX} passes are required.
71
72 During the first {\TeX} pass a {\MF} file is written. As it is {\TeX}
73 itself who writes the {\MF} file, any dimension controlled by {\TeX} can
74 be used and incorporated in {\MF}'s calculations. For example, the label
75 sizes, as they will be typeset by {\TeX}, are made known to {\MF}.
76
77 After the first {\TeX} pass, {\MF} draws the graphic figures and
78 writes the label locations in its log file. So it is {\MF}'s
79 responsibility to locate the labels. Note that, depending on the style
80 of {\MF} programming, this can be completely determined from {\TeX}. In
81 other words, you can relate the label location to the location and size
82 of other {\MF} objects, or not.
83
84 When {\TeX} executes its second pass, it takes the graphics
85 from the new font, reads the location of labels from the
86 {\MF} log file, and then everything is complete.
87
88 Because labels are just |\hbox|es typeset by \TeX, every macro currently
89 defined for text automatically applies also to figures. For example, if
90 a macro |\person| is defined to write its argument in a small caps font
91 and save it to an index file, the same happens whenever it is used
92 inside a figure label.
93
94
95 \head * Methods *
96
97 {\MTeX} allows the source file to include, in addition to the customary
98 {\TeX} macros to control the text, other commands to generate
99 figures with {\MF}.
100
101 \subhead * Steps *
102
103 In order to use {\MTeX} the following three steps are to be executed:
104
105 \list[\numbered]
106
107 \item The {\MTeX} file, suppose it is |filename.ext|, is first
108 processed by |TEX|, with the {\plain} format, during which a {\MF} file
109 named |auxiliar.mf| is created. This {\MF} file contains information
110 provided by {\TeX} concerning the size of the labels, so the |MF|
111 program can delete this area from the figure if requested. If the output
112 file |filename.dvi| were typeset now, it would have blanks in place of
113 the figures, but otherwise be the same as the final document.
114
115 \item Then |MF|, with the {\plain} base, is run on |auxiliar.mf|.
116 As a result, information specifying where to typeset the labels is
117 written in the log file, |auxiliar.log|. In addition, the metric file,
118 |auxiliar.tfm|, and the generic format bitmap font, |auxiliar.329gf|,
119 are created. On my system I have to process this |gf| file to get a
120 |pk| file that my drivers can read, so I execute the program |GFtoPK| on
121 it, getting the packed bitmap font |auxiliar.329pk|. Please note three
122 points. i)~The number |329|, referring to the resolution, varies
123 according to the {\MF} mode. ii)~The |tfm| and |pk| files must be in or
124 moved to directories where programs can find them. iii)~{\MTeX} sets the
125 {\MF} mode to |localfont|, thus assuming that |localfont| is assigned
126 the appropriate name.
127
128 \item Lastly, |filename.ext| is again run through |TEX|. During this
129 second run, both the font |auxiliar| containing the figures and the
130 information explaining where to locate the labels are available, so the
131 document is complete.
132
133 \endlist
134
135 The figures fill exactly the same area in both the first and second
136 |TEX| program runs, so indices, tables of contents, and other references
137 that also need two passes to be resolved can take advantage of the two
138 runs needed by {\MTeX}.
139
140 \subhead * Use *
141
142 To use the {\MTeX} macros, they must be imported by writing in the
143 source file: ||\input metatex||
144
145 \noindent This has to be written after |\mag| has been given its final
146 value. When |metatex.tex| is read, {\MTeX} checks whether the file
147 |auxiliar.mf| exists. If it does not exist, then things are set up for
148 the first pass; for example, |auxiliar.mf| is opened for writing. If it
149 does exist, then things are set for the second pass; for example,
150 |auxiliar.log| is opened for reading. This means that if
151 |auxiliar.mf| is not deleted, then step~3, the second |TEX| program
152 pass, is executed directly. This saves time when only the text in file
153 |filename.ext|, but not the figures, were modified.
154
155 \subhead * User macros *
156
157 The {\MTeX} user macros are:
158
159 \list
160
161 \item |\MTbeginchar(wd,ht,dp);| states that a figure sized as given
162 (width |wd|, height |ht|, depth |dp|) will be created. These values
163 should be known both by {\TeX} and by {\MF}, so for example |12pt|,
164 |6cm|, |\the\hsize| or |\the\dimen0|, always without |#|, are allowed.
165 During the {\it first pass}, {\TeX} writes in |auxiliar.mf| the {\MF}
166 macro |beginchar| assigning character codes sequentially, and box
167 |\MTbox| is made empty but sized as specified by the arguments of this
168 macro. During the {\it second pass}, {\TeX} puts the corresponding
169 character of the font |auxiliar| in box |\MTbox|. The size of |\MTbox| is
170 that specified and not affected by the character dimensions.
171
172 \item |\MTendchar;| finishes the figure definition. During the
173 {\it first pass}, {\TeX} writes the {\MF} macro |endchar;| in file
174 |auxiliar.mf|. During the {\it second pass}, box |\MTbox| contains the
175 complete figure, including labels. Something like |\box\MTbox| is
176 used to typeset the figure.
177
178 \item |\MTlabel*(s)cc"Text";| adds a label to the current figure.
179 The parameter between quotes, |Text| in the example, is the label
180 content; it will be put inside an |\hbox| and therefore could be
181 anything that {\TeX} allows inside an |\hbox|. The optional asterisk
182 after |\MTlabel| instructs {\MTeX} to erase the area of the figure
183 already drawn that it is under the label.
184
185 The label will be located at {\MF} point |z.s|, where |s| is the parameter
186 between parentheses. The reference point is further specified by the
187 optional parameter after the right parenthesis, |cc| in the example.
188 This parameter is composed of exactly two letters: the first can be |t|
189 meaning top, |c| meaning center or |b| meaning bottom; and the second
190 letter can be |l| meaning left, |c| meaning center or |r| meaning right.
191 So, for example, |tl| means that the label reference point is its top
192 left corner. The default value for the reference point is |cc|, that is,
193 its center.
194
195 |\MTlabel| should only be used between |\MTbeginchar| and |\MTendchar|.
196 During the {\it first pass}, it writes the following three elements in
197 |auxiliar.mf|: i)~the {\MF} macros which in turn cause |MF| to write the
198 label reference point location to its log file, |auxiliar.log|; ii)~the
199 four label sides, which are by this means made available to the
200 following {\MF} code for the figure, notated as |y.s.t| for the top side,
201 |y.s.b| for the bottom side, |x.s.l| for the left side and |x.s.r| for the right
202 side; and iii)~the code to delete, if requested, the figure area already
203 drawn that is under the rectangle occupied by the label. During the {\it
204 second pass}, it adds the label to the box |\MTbox| in the place that
205 reads from file |auxiliar.log|, making no modification to the dimensions of
206 |\MTbox|, even if the label is typeset outside the box.
207
208 \endlist
209
210 There are three more macros for passing information to \MF, that is, for
211 writing general text in |auxiliar.mf|: |\MT:|, |\MTcode| and |\MTline|.
212 This happens only during the first pass; during the second pass, these
213 macros do nothing.
214
215 \list
216
217 \item |\MT:| writes in file |auxiliar.mf| everything till the end of
218 line. It writes verbatim except for the character |\|, which keeps its
219 normal {\TeX} |\catcode| of |0|. Spaces are {\it not\/} ignored after
220 macros. The sequence |\\| writes a single |\| in file |auxiliar.mf|.
221
222 \item |\MTcode| writes in file |auxiliar.mf| everything until it finds a
223 line equal (including |\catcode|s) to the current value of |\MTendmark|.
224 By default, this is a blank line, thus, |\def\MTendmark{}|. As with
225 |\MT:|, it writes verbatim except for |\|, which still operates as an
226 escape character. The control sequence |\\| writes a single |\| in file
227 |auxiliar.mf|.
228
229 \item |\MTline{text}| writes its parameter to |auxiliar.mf|,
230 |text| in the example. It does not change the |\catcode|s in the
231 argument, so it does not perform verbatim writing. But all {\plain}
232 special characters can be written prefixing them by the escape character
233 |\|. The {\plain} special characters are (not including the first colon
234 nor the final period): |\{}$&#^_~%|. For example, |\#| results in
235 |#|.
236
237 \endlist
238
239 When defining {\TeX} macros that write to |auxiliar.mf|, |\MTline|
240 should generally be used in preference to |\MT:| or |\MTcode|, because
241 the latter two use
242 the end of line in a special way that is not usually available when
243 {\TeX} is reading a macro.
244
245 {\TeX} dimensions can be included using any of these three writing
246 macros. For example, |\the\hsize| will be expanded to {\tt \the\hsize}
247 (for the present article),
248 and written as such to the {\MF} file |auxiliar.mf|. Note that the character
249 |\| keeps its escape |\catcode| in all three writing macros. In the
250 case of |\MTline|, braces |{}| also keep their |\catcode|s and therefore
251 macros with parameters can be used normally.
252
253
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255
256
257 \head * Examples *
258
259 \subhead * Diagram *
260
261 First a typical example of {\MTeX} usage, showing the file formats,
262 programs, and their relationships. The figure width is exactly
263 |\hsize|, but what is more important is that the same code will adapt
264 itself to any value for the measure. Well, of course, not to {\it any\/}
265 width but to any width between, let's say, $8\,$cm and $25\,$cm.
266
267 \figure[\caption{Figure 1: One column diagram}]
268 \input diagram
269 \endfigure
270
271 %\twocolfigure[\caption{Figure 2: Two columns diagram}]
272 % \input diagram
273 %\endfigure
274
275 Figure~1 is the one column version, and Figure~2 (above the appendix) is
276 the two column version, generated by the same source.
277
278
279 %%%%%%%%%%%%%%%%%%%
280
281 \input shadow
282
283 \def\beginshadowpar{\setbox0=\vbox\bgroup \kern3pt
284 \advance\parindent by -3pt \leftskip=3pt\rightskip=3pt }
285 \def\endshadowpar{\par\kern3pt\egroup\framebox0\shadowbox0\box0 }
286
287 % \subhead * Shadowing *
288 \bigskip % \subhead skip
289
290 \beginshadowpar\noindent
291 {\bf Shadowing.} Both {\TeX} and {\MF} are ill suited to creating
292 shadows. In {\TeX}, one straightforward technique is double use of
293 |\leaders|, but in practice this results in huge |dvi| files. In {\MF},
294 drawing lots of tiny points easily exceeds the capacity of the program.
295 The solution is to coordinate the work of both programs.
296 \endshadowpar
297
298 To create a large rectangular shadow we divide it into an array of $n
299 \times m$ smaller rectangles. The smaller rectangles are all identical,
300 so it is enough for {\MF} to draw one shadow character and then for
301 {\TeX} to typeset a solid area repeating it.
302
303 To simplify the tasks of both {\TeX} and {\MF}, the size of the shadow
304 character should be similar to that of normal characters, because neither
305 program was designed to work well with extraordinarily large (or small)
306 characters. So a
307 good approach is to make the shadow character as big as possible but
308 never wider nor higher than 16$\,$pt.
309
310 For {\MTeX}, each figure is a character. This causes problems with {\MF}
311 when the figure is big and the resolution is high, because it cannot
312 draw areas bigger than $4095\times4095$ pixels. This is not usually a
313 problem working at 300$\,$dpi. (It is never a problem with {\MP}, see
314 the following section on {\PS}. Another advantage of using {\PS} is that
315 you get a shadow simply by drawing a grey rule, and none of the above
316 machinations are necessary.)
317
318 %%%%%%%%%%%%%%%%%%%
319
320 \subhead * Keys *
321
322 After the following {\MTeX} macros:
323
324 \verbatim[\numbered\outputtofile{keys.tex}]
325 \MTcode
326 def keybox =
327 pickup pencircle scaled 0.8pt;
328 x1 = x3 = 1pt;
329 x2 = x4 = w - 1pt;
330 x5 = 0; x6 = w;
331 y1 = y2 = -d;
332 y3 = y4 = h;
333 y5 = y6 = (h - d)/2;
334 draw z1 -- z2 .. z6{up} ..
335 z4 -- z3 .. z5{down} .. cycle;
336 z0 = (x1,0);
337 enddef;
338
339 \def\defkey#1#2{\setbox0=\hbox{\sf#2}%
340 \dimen0=\wd0\advance\dimen0 by 2pt
341 \dimen2=\ht0\advance\dimen2 by 1pt
342 \dimen4=\dp0\advance\dimen4 by 1pt
343 \MTbeginchar(\the\dimen0,%
344 \the\dimen2,%
345 \the\dimen4);%
346 \MTline{keybox;}%
347 \MTlabel(0)bl"\sf #2";%
348 \MTendchar;%
349 \expandafter\newbox
350 \csname\string#1box\endcsname
351 \expandafter\setbox
352 \csname\string#1box\endcsname
353 =\vtop{\unvbox\MTbox}%
354 \def#1{\expandafter\copy
355 \csname\string#1box\endcsname}}
356
357 \def\makekey#1{\expandafter\defkey%
358 \csname#1\endcsname{#1}}
359 \endverbatim
360
361 \input keys
362
363 Then, we can declare |\makekey{Alt}|\makekey{Alt} to
364 typeset {\Alt} simply via |\Alt|. It is also possible to
365 declare |\defkey\escape{\tt\char92}|\defkey\escape{\tt\char92} and then
366 |\escape| results in \escape.
367
368 %%%%%%%%%%%%%%%%%%%
369
370 \subhead * Baroque tables *
371
372 Baroque periods are the result of new technical achievements providing
373 unexplored possibilities and hence the urgent need to experiment with them,
374 frequently far away from what discretion might recommend. This explains
375 the time of baroque software that we live in, and increases the value of
376 \MTeX, because it provides the means to easily draw baroque tables. I am not
377 a baroque man, so my baroque table example is not baroque but, and this
378 is the point, it is at least not built with straight lines.
379
380 \MTcode
381 def tablebox =
382 pickup pencircle scaled 1.6pt;
383 x0 = 5pt; y0 = 5pt;
384 draw (0,h) ... (w/2,h+y0) ... (w,h) ... (w+x0,(h-d)/2) ... (w,-d) ...
385 (w/2,-d-y0) ... (0,-d) ... (-x0,(h-d)/2) ... cycle;
386 enddef;
387
388 \def\beginbaroquetable{\setbox0=\vbox\bgroup
389 \halign\bgroup##\hfil&&\quad##\hfil\cr}
390 \def\endbaroquetable{\crcr\egroup\egroup
391 \MTbeginchar(\the\wd0,\the\ht0,\the\dp0);%
392 \MTline{ tablebox;}%
393 \MTendchar;%
394 $$\rlap{\box\MTbox}\box0$$}
395
396 \beginbaroquetable
397 This is not a straight table\cr
398 but it's only an example\cr
399 and therefore not so ample\cr
400 of what's {\MTeX}-able!
401 \endbaroquetable
402
403 %%%%%%%%%%%%%%%%%%%
404
405 \MTcode
406 def leftbrace =
407 pickup penrazor scaled 2pt rotated 30;
408 x3 = 0; x0 = x6 = w; x1 = x5 = w/5; x2 = x4 = w-x1;
409 y0 = 0; y1 = h/8; y2 = h/3; y3 = h/2;
410 y4 + y2 = h; y1 + y5 = h; y6 = h;
411 draw z0 .. z1 .. z2 .. z3;
412 draw z6 .. z5 .. z4 .. z3;
413 enddef;
414
415 \def\beginbracedpar{\setbox0=\vbox\bgroup
416 \leftskip=20pt }
417 \def\endbracedpar{\strut\par\egroup
418 \MTbeginchar(20pt,\the\ht0,0pt);%
419 \MTline{ leftbrace;}%
420 \MTendchar;%
421 \hbox to\hsize{\rlap{\box\MTbox}\box0\hss}}
422
423 %\subhead * Ornate paragraphs *
424 \bigskip % \subhead skip
425
426 \beginbracedpar\noindent
427 {\bf Ornate paragraphs.} Only if you are truly baroque can you get the
428 most from {\MTeX}. If, for example, you like ornate paragraphs, you are
429 in your element. Just put the material in a |\vbox| to get the height
430 and the depth, and pass these dimensions to {\MF} to draw a right sized
431 embellishment. Ah!, but be aware that Computer Modern is a neoclassical
432 font, so it won't mix well with your elaborations.
433 \endbracedpar
434
435 %%%%%%%%%%%%%%%%%%%
436
437 % To fill unused space!
438 \MTcode
439 def tribar(expr alpha) =
440 pickup pencircle scaled 0.8pt;
441 % draw (0,0)--(w,0)--(w,h)--(0,h)--cycle;
442 save u, v; u = w/2; v = 12;
443 z1 = (w/2,h/2) + u*(right rotated alpha);
444 z2 = (w/2,h/2) + u*(right rotated (alpha+120));
445 z3 = (w/2,h/2) + u*(right rotated (alpha-120));
446 z1r = (w/2,h/2) + u*(right rotated (alpha+v));
447 z2r = (w/2,h/2) + u*(right rotated (alpha+120+v));
448 z3r = (w/2,h/2) + u*(right rotated (alpha-120+v));
449 draw z1 .. z1r; draw z2 .. z2r; draw z3 .. z3r;
450 draw z1 .. z3r; draw z2 .. z1r; draw z3 .. z2r;
451 z1m = whatever[z1,z2r]; z1m = whatever[z1r,z3];
452 z2m = whatever[z2,z3r]; z2m = whatever[z2r,z1];
453 z3m = whatever[z3,z1r]; z3m = whatever[z3r,z2];
454 draw z1 .. z2m; draw z2 .. z3m; draw z3 .. z1m;
455 z1ra = z1 reflectedabout (z1r,z1m);
456 z2ra = z2 reflectedabout (z2r,z2m);
457 z3ra = z3 reflectedabout (z3r,z3m);
458 draw z1m .. z1ra; draw z2m .. z2ra; draw z3m .. z3ra;
459 z3x - z1x = whatever*(z3-z1m);
460 z2x - z3x = whatever*(z2-z3m);
461 z1x - z2x = whatever*(z1-z2m);
462 z1ra - z1x = whatever*(z3-z1m);
463 z3ra - z3x = whatever*(z2-z3m);
464 z2ra - z2x = whatever*(z1-z2m);
465 z1y = whatever[z1m,z3]; z1y = whatever[z1x,z2x];
466 z2y = whatever[z2m,z1]; z2y = whatever[z2x,z3x];
467 z3y = whatever[z3m,z2]; z3y = whatever[z3x,z1x];
468 draw z1x .. z3y;
469 draw z2x .. z1y;
470 draw z3x .. z2y;
471 enddef;
472
473 \def\tribar#1#2{% #1=ht, #2=angle
474 \MTbeginchar(#1,#1,0pt);\MTline{tribar(#2);}\MTendchar;\box\MTbox}
475
476 \newcount\angle \angle=-36
477 \newdimen\tribarht \tribarht=75pt
478
479 %\subhead * Exercice *
480 \bigskip % \subhead skip
481
482 \noindent
483 {\bf Exercise.}\footnote*{The real exercise is to fill the rest of the
484 page with tribars. A clue: let {\TeX} to calculate how many are needed,
485 so you can concentrate your efforts in drawing the figure.}
486 Take three equal bars and build as shown.
487 Ask Roger Penrose if you don't find the solution.
488 \vskip1pc
489
490 \loop
491 \vfil
492 \line{\tribar{\the\tribarht}{\the\angle}\hfil \global\advance\angle5
493 \tribar{\the\tribarht}{\the\angle}\hfil \global\advance\angle5
494 \tribar{\the\tribarht}{\the\angle}\global\advance\angle5 }
495 \dimen0=\pagegoal \advance\dimen0 by-\pagetotal
496 \ifdim\dimen0>\tribarht
497 \repeat
498
499
500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501
502
503 \head * {\PS} *
504
505 By taking advantage of {\MP}, we can make {\PS} versions of the
506 {\MTeX} files. Simply execute |mpost &plain auxiliar.mf| instead of
507 {\MF} and, after {\TeX}'s second pass, execute |dvips| ({\MTeX} uses
508 |dvips| specials). This works because |auxiliar.mf| is valid code
509 for both {\MF} and {\MP}, and because, in the second {\TeX} pass,
510 {\MTeX} checks which one was used and adapts itself to the situation.
511
512 And thanks to {\PDF\TeX} and the Con{\TeX}t files |supp-mis.tex| and
513 |supp-pdf.tex|, it is also possible to get \acro{PDF} output. Just
514 execute {\PDF\TeX} twice, instead of {\TeX}, and once {\MP}, instead of
515 {\MF}. (In practice, {\MTeX} uses its own macro file |mtmp2pdf.tex| for
516 this, instead of the Con{\TeX}t files. I extracted all that {\MTeX}
517 needs from the Con{\TeX}t files into |mtmp2pdf.tex|.)
518
519 This works because, if {\MTeX} determines that {\MP} was employed to
520 draw the figures, it then checks which program, {\TeX} or {\PDF\TeX}, is
521 executing. If {\TeX}, then it includes the files produced by {\MP} using
522 the |dvips| specials. If {\PDF\TeX}, it translates from |ps| to |pdf|.
523
524 Therefore, the same {\MTeX} source file generates at will any of the
525 three output formats---|dvi|, |ps|, or |pdf|---just by running the
526 appropriate programs. In the appendix, as an example, there is a
527 \acro{DOS} batch file that shows how to get the |pdf| version of a file
528 |filename.ext|.
529
530
531 \head * Other graphical tools *
532
533 There are other tools to include pictures in a {\TeX} document.
534 {\LaTeX}'s |picture| environment, {\PiCTeX}, and |mfpic|, are three of
535 them. {\MTeX} is similar to |mfpic|, in that both use {\MF} to draw.
536
537 The aim of |mfpic| is to overcome the difficulties of {\LaTeX}'s
538 |picture| environment and of {\PiCTeX}. {\LaTeX}'s |picture| environment
539 uses four pre-cooked special fonts, and its drawings are just
540 compositions of these characters (as well as {\TeX}'s builtin |\hrule|s and
541 |\vrule|s). {\PiCTeX} only uses a tiny point to compose the pictures, so
542 it is more general. But letting {\TeX} to draw the figures setting point
543 after point is painful, as noted above. The |mfpic| solution uses a
544 better tool for drawing: {\MF}.
545
546 With these origins, for |mfpic|, {\MF} is a hidden back-end processor,
547 and |mfpic| imposes only two requirements on its users: to know {\TeX},
548 and to know |mfpic|. On the other hand, {\MTeX}'s approach is
549 minimalist, at the cost of being more demanding with its users. A
550 {\MTeX} user has to know {\TeX}, {\MF}, and {\MTeX}\Dash although this
551 last requirement is small, because {\MTeX} only builds the necessary
552 bridges to use {\TeX} and {\MF} in a cooperative way.
553
554 A feature that shows the different strategies employed in designing
555 |mfpic| and {\MTeX} is label positioning. {\MTeX} labels are located by
556 {\MF}, so {\TeX} has to read the {\MF} log file to learn where to
557 typeset them. For |mfpic|, {\TeX} itself locates the labels,
558 but by doing so |mfpic| has to give up some nice {\MF} characteristics,
559 such as its equation solving capabilities.
560
561 % |mfpic| is to {\LaTeX} as {\MTeX} is to |plain| {\TeX}.
562 In summary, |mfpic|'s aim is to draw pictures in {\TeX} documents in a
563 better way than using {\LaTeX}'s |picture| environment or {\PiCTeX};
564 while {\MTeX}'s intention is to coordinate the work of {\TeX} and
565 {\MF}. In this way, {\MTeX} provides the full raw power of {\TeX} and
566 {\MF}, and it is up to you to harness them.
567
568
569 \head * Final remarks *
570
571 I have been using {\MTeX} for some years. The first version was dated
572 1994, but it has been used only for personal purposes. For this reason,
573 it is not truly a straightforward end-user tool, as for example {\LaTeX} packages
574 should be. It has to be used knowledgeably and with care. And though
575 most tasks can be automated, by chaining {\TeX} and {\MF} errors are
576 even more difficult to pinpoint than in {\TeX} or {\MF} alone.
577
578 Nevertheless, {\MTeX} serves to validate the feasibility of a closer
579 collaboration between {\TeX} and {\MF} and to appraise the interest of
580 such a collaboration. And, of course, if you dare, you can get lots of
581 fun, and at least an equal amount of frustration, using {\MTeX}. Try it!
582
583 The {\MTeX} package is available from {\CTAN} in
584 \acro{CTAN}|:/macros/plain/contrib/metatex|.
585
586 Happy {\MTeX}ing!
587
588
589 \makesignature
590
591
592 \newpage
593
594
595 \onecol % Annex in one column, can't switch to \twocol on the same page
596 % with current plain tugboat macros.
597
598 \figure[\caption{Figure 2: Two-column diagram}]
599 \input diagram
600 \endfigure
601
602 \head * Appendix: Pseudo-batch example *
603
604 This is an example based on \acro{DOS} batch files that can be adapted for
605 other operating systems. It processes the file |filename.ext|, generating
606 |filename.pdf|. We will comment each line of pseudo-code.
607
608 \list[\numbered]
609 \item We go to the directory where our working files are.
610 ||cd c:\dir\subdir\mydir||
611 \item We set environment variables (if necessary). In this case we are
612 using a |web2c| system, so it is enough to set one. In |web2c|, by
613 default, all programs look for files in the current dir, ``|.|'', and
614 that is enough for us.
615 ||set TEXMFCNF=c:\tex\texmf.local\web2c;c:\tex\texmf\web2c;d:\texmf\web2c||
616 \item We tell the operating system where to find the programs.
617 ||path=$path$;c:\tex\bin\dos||
618 \item After the settings, we force the first {\TeX} pass.
619 ||if exist auxiliar.mf del auxiliar.mf||
620 \item Then, we execute the first {\TeX} pass (in this case, it is {\PDF\TeX}).
621 ||pdftex &plain filename.ext||
622 \item If {\MTeX} was not used, and no |auxiliar.mf| was written, then we
623 are done.
624 ||if not exist auxiliar.mf goto end||
625 \item Otherwise we run {\MP} with its |&plain| memory (format),
626 also known as |&mpost|.
627 ||mpost &plain auxiliar.mf||
628 \item Finally, we execute the second {\TeX} pass.
629 ||pdftex &plain filename.ext||
630 \item We now have the complete |filename.pdf| file.
631 ||:end||
632
633 \endlist
634
635 \MTline{end.} % METATeX changes \bye
636 \endarticle
637
638
639 % To check labels (ink intensive example!)
640 \MTbeginchar(5cm,5cm,0cm);
641 \MT: fill (0,0)--(w,0)--(w,h)--(0,h)--cycle;
642 \MT: z0 = (w/2,h/2);
643 \MT: z1 = (w/2,3h/4); z11 = z1;
644 \MT: z2 = (w/2,h/4);
645 \MT: z3 = (0,h/2);
646 \MT: z4 = (0,h/4);
647 \MTlabel*(0)"Center";
648 \MTlabel*(1)tl".";
649 \MTlabel*(11)br".";
650 \MTlabel*(2)":";
651 \MTlabel(3)"Out";
652 \MTlabel*(4)"Intruder";
653 \MTendchar;
654 $$\box\MTbox$$