31.08.2013 Views

Complete issue 30:3 as one pdf - TUG

Complete issue 30:3 as one pdf - TUG

Complete issue 30:3 as one pdf - TUG

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TEX Education EUROTEX 2009 E21<br />

setlinejoin, setlinecap, or the use of closepaths for<br />

contours, willhelp youout.<br />

Flowchart<br />

Anexampleoftheuseof gkppicmacrosisthefollowing<br />

diagramforthe loop.<br />

The code I borrowed from BLUe’s pic.dat, adapted for<br />

theocc<strong>as</strong>ionwithinserting\bluecand\bluel.Notnice,<br />

so anotherre<strong>as</strong>on fordoing it allinMetaPost.<br />

\def\blueflowchartlooppic%<br />

{\bgroup\unitlength=3ex%3.8ex<br />

\xoffset{-.5}\yoffset{-.3}%<br />

\xdim{5}\ydim{7.5}%<br />

\beginpicture<br />

%\ifmarkorigin\put(0,0)\markorigin\fi<br />

\put(0,0){\line(1,0){2}}%<br />

\put(0,0){\line(0,1){6}}%<br />

\put(0,6){\bluec\vector(1,0){2}}%<br />

\put(2,6.5){\bluec\vector(0,-1){1.5}}%<br />

\put(1,4){\framebox(2,1){\bluec pre}}%<br />

\put(2,4){\bluec\vector(0,-1){.5}}%<br />

%\put(2,3){\rhombus(2,1)1{tst}}%<br />

\put(1,3){\bluec\line(2,1){1}} %lu<br />

\put(1,3){\bluec\line(2,-1){1}} %ll<br />

\put(3,3){\bluec\line(-2,1){1}} %ru<br />

\put(3,3){\bluec\line(-2,-1){1}} %rl<br />

\put(2,3){\makebox(0,0){\bluec tst}}%<br />

%<br />

\put(2,2.5){\line(0,-1){0.5}}%<br />

\put(1,1){\framebox(2,1){\bluec post}}%<br />

\put(2,1){\line(0,-1){1}}%<br />

%<br />

\put(3,3){\line(1,0){1}}%<br />

\put(4,3){\vector(0,-1){3}}%<br />

\put(4,2.5){\kern2pt{\bluec else}}%<br />

\endpicture\egroup%<br />

}% end blueflowchartlooppic<br />

Before the invoke I dened \bluel <strong>as</strong> well <strong>as</strong> \bluec<br />

and used \bluec in the denition and \bluel before the<br />

invoke. Notso nice, but imposed by PDF.<br />

Disadvantages of the gkppic macros and L ATEX<br />

picture environment is that coloring is tricky when<br />

using \<strong>pdf</strong>(Any)TeX: elements of a font are colored by<br />

supplying k to \<strong>pdf</strong>literal and lines or lls are colored<br />

by supplying K to \<strong>pdf</strong>literal. Moreover, <strong>one</strong> h<strong>as</strong> to<br />

put the pictures drawn by the wind macros in a box of<br />

appropriate size, sort of Bounding Box, to ensure space.<br />

Anuisance.<br />

\def\bluec{\<strong>pdf</strong>literal{1 0 0 0 k}}<br />

%versus<br />

\def\bluel{\<strong>pdf</strong>literal{1 0 0 0 K}}<br />

When we use the multi-step processing line via PS we<br />

don’t have that disadvantage. Below atest example.<br />

pretext<br />

\special{ps: 0 0 1 setrgbcolor}%blue<br />

abc<br />

\hrule<br />

def<br />

\special{ps: 0 0 0 setrgbcolor}%black<br />

posttext<br />

\bye<br />

Processthe.dviviadvipsandviewthe.ps,toverifythe<br />

result. In TEXnicCenter I have added the Output Prole<br />

eTEX→PS→PDF. Convenient.<br />

Note the explicit switching back to black, because the<br />

TEX scope rule is not obeyed, of course. Another way to<br />

preventthattherestwillappearinblue,istoinsertgsave<br />

inthe rst and grestoreinthe second \special.<br />

My MP code for the owchart which made use of<br />

Hobby’s boxes.mp.<br />

input boxes.mp;<br />

prologues:=3;<br />

%outputtemplate:="%j-%3c.eps";<br />

beginfig(0)<br />

boxit.boxa (btex \hbox to 60pt%<br />

{\strut\hss pre\hss}etex);<br />

boxit.boxb (btex \hbox to 60pt%<br />

{\strut\hss tst\hss}etex);<br />

boxit.boxc (btex \hbox to 60pt%<br />

{\strut\hss post\hss}etex);<br />

boxa.c=(100,180);<br />

boxb.c=(100,140);<br />

boxc.c=(100,100);<br />

boxa.dx=boxb.dx=boxc.dx=5;<br />

boxa.dy=boxb.dy=boxc.dy=5;<br />

drawoptions(withcolor blue);<br />

drawboxed (boxa, boxc);<br />

%draw contents of b and the diamond shape<br />

draw pic.boxb;<br />

draw boxb.w--boxb.n--boxb.e--boxb.s--cycle;<br />

%The arrows<br />

drawarrow boxa.s--boxb.n;<br />

drawarrow boxb.s--boxc.n;<br />

z1-boxb.e=z2-boxc.e=(20,0);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!