Complete issue 30:3 as one pdf - TUG
Complete issue 30:3 as one pdf - TUG
Complete issue 30:3 as one pdf - TUG
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
TEX Education EUROTEX 2009 E19<br />
\def\inwardspiral{{\offinterlineskip<br />
\loop\E{\the\k}\advance\k-1<br />
\S{\the\k}\advance\k-1<br />
\W{\the\k}\advance\k-1<br />
\N{\the\k}\advance\k-1<br />
\ifnum\k>4 \repeat}}<br />
Contest<br />
I needed for the graphics inclusion in this paper, and in<br />
the slides,aminimal markupmacro \jpg.<br />
DuringmypresentationIlaunchedaminimalmarkup<br />
problem. I wanted to replace the following markup with<br />
optional width... height...<br />
$$\<strong>pdf</strong>ximage height..width...<br />
{filename.jpg}<br />
\<strong>pdf</strong>refximage\<strong>pdf</strong>l<strong>as</strong>tximage$$<br />
by either the minimal markup<br />
\jpgD filename<br />
or<br />
\jpgD width... filename<br />
or<br />
\jpgD height... filename<br />
or<br />
\jpgD height... width... filename<br />
Nosquarebrackets,nocurlybraces,andevennoexplicit<br />
le extension, becauseit isalready inthe macro name.<br />
Ichallenged the audience to write such amacro.<br />
There would be two winners <strong>one</strong> appointed by me and<br />
<strong>one</strong>by the audience. 18<br />
And... the winner is... Péter Szabó, by me and by the<br />
audience, withthe followingsolution<br />
\def\jpgfilename#1 {%<br />
\egroup %end \setbox0\vbox<br />
$$\<strong>pdf</strong>ximage%<br />
\ifdim\wd0=0pt\else width\wd0\fi<br />
\ifdim\ht0=0pt\else height\ht0\fi<br />
{#1.jpg}%<br />
\<strong>pdf</strong>refximage\<strong>pdf</strong>l<strong>as</strong>tximage$$<br />
\endgroup}<br />
\def\jpgD{%<br />
\begingroup<br />
\setbox0\vbox\bgroup<br />
\hsize0pt \parindent0pt<br />
\everypar{\jpgfilename}%<br />
\hrule height0pt }<br />
Elegant, to <strong>as</strong>sociate the optional parameter with a<br />
\hrule and me<strong>as</strong>ure it by putting it in a box. Elegant<br />
it is.<br />
But...<br />
I must confess, it took me some time to understand it. A<br />
M<strong>as</strong>terCl<strong>as</strong>swouldhavebeenbenecialforme,tolearn<br />
to understandthese kindsofmacros more quickly .<br />
The near winner w<strong>as</strong> Bernd Raichle with a thorough,<br />
straight-forward solution, not avoiding the pitfall, and<br />
whichisabittoo long to includeinthisnote.<br />
But...<br />
it shows a superb, elaborate parsing technique looking<br />
for width.. height...andthentakeappropriateaction.<br />
Post conference Phil Taylor came up with a near, but<br />
intriguingsolutionandImyselfalsoboiledup<strong>one</strong>.Both<br />
are supplied in the Appendix I, because much can be<br />
learnedfromthem.Bothneglectthe(unintended)pitfall<br />
toconcentrateontheparsingoftheoptionalparameters.<br />
PhilandIjustp<strong>as</strong>sontheoptionalparameters,ifany,to<br />
\<strong>pdf</strong>ximage.<br />
2D Graphics<br />
Line drawings with incremental diculties are included<br />
anddiscussed, such <strong>as</strong><br />
straight linedrawings by the windmacros andby<br />
gkppicinplainTEX, and PS, such <strong>as</strong>fractalsand<br />
owcharts<br />
graphics withcurved lines by PS and MP, such <strong>as</strong><br />
graphics composed ofobliquelines (andspurious<br />
envelopes),circles,andgeneralcurves, to be drawn<br />
by splines.<br />
Binary tree<br />
I consider my binary tree macro <strong>as</strong> very beautiful,<br />
because it can be programmed so nicely in TEX or PS,<br />
and h<strong>as</strong> such interesting applications. I consider it much<br />
in the spirit of Knuth’s Turing award lecture Computer<br />
Programming <strong>as</strong>anArt.<br />
\def\bintree{\E{\the\kk}%<br />
\ifnum\kk=2 \eertnib\fi<br />
\divide\kk2 {\N{\the\kk}\bintree}%<br />
\S{\the\kk}\bintree}%<br />
\def\eertnib##1\bintree{\fi}%terminator<br />
This mean and lean macro from the p<strong>as</strong>t can be adapted<br />
to yourneeds.<br />
The above \bintree I used for a Turtle graphics,<br />
non-\alignment, solution of the TEXbook exercise 22.14,<br />
which reects the binary structure. En-p<strong>as</strong>sant, NTG’s<br />
VIPsreplace the original namesgiveninthe TEXbook.