%\def\TexFiles{}
\def\ext{Changeable}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Compile this file with TeX and review the document.         %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\hfill                                                 5 Dec. 93
\bigskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
%  Code of examples and exercises from                  %
%                                                       %
%     TeX and LaTeX: Drawing and Literate Programming   %
%                                                       %
%                            gurari@cis.ohio-state.edu  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
\immediate\write16{<<< tex Examples.tex <<<<<<<<<<<}
\immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                                                                %%
                                                                %%
\input ProTex.sty  %%%%%%%%%%%%%%%%%%%%


\expandafter\def\csname :warn\endcsname#1{}
\Code\top{}{\immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
\immediate\write16{<<<<< \op \name.\ext}
\immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}

% \com
}

       \ifx \TexFiles\empty        %%%%%%%%%%%%%%%%%%%%%%%%
\def\tex{tex}

\def\DEFEND{\% LaTeX requires a {\tt\string\Defend} here \%}

\Code\Open{}{\files
\startInput
}

\Code\Close{}{
\endInput
\\bye}
       \else      %%%%%%%%%%%%%%%%%%%%%%%%
\def\tex{latex}

\Code\DEFEND{{\it LaTeX requires a {\tt\string\Defend} 
  here}}{\% LaTeX requires a \string\Defend here \%\string\Defend}

\Code\Open{}{\\documentstyle{book}
\files
\\begin{document}
\startInput}

\Code\Close{}{
\endInput
\\end{document}}
       \fi        %%%%%%%%%%%%%%%%%%%%%%%%

\Code\fileD{}{
\\input DraTex.sty }

\Code\fileAD{}{
\\input DraTex.sty
\\input AlDraTex.sty }

\Code\fileP{}{
\\input ProTex.sty }

\Code\startInput{}{\\Draw}
\Code\endInput{}{\\EndDraw}

\AlProTex{\ext,<<<>>>,[],list,|,ShowFile,NoShow}  %%%%%%%%%%%%%%%%%%%%

\let\SC=\ShowCode                                               
\Code\execute{}<<<
>>>

\catcode`\^^M=13  \catcode`\#=12 %
\def\<<<{%
   \edef\temp{%
      \noexpand\AppendCode\noexpand\execute<<<
      \op\space\space \name.\ext\space\space\space   # \com 
      xdvi\space\space \name.dvi
      >>>}\ShowOff\temp\ShowOn%
   \def\ShowCode{%
      \expandafter\OutputCode\csname\name\endcsname \def\top
      {} \global\let\ShowCode=\SC  \ShowCode}%
   \expandafter\Code\csname\name\endcsname{}<<<
   \top}%
\catcode`\^^M=5   \catcode`\#=6

\def\newpage{\def\newpage{\par\vfill\break}}        
\newcount\1  \newcount\2  \newcount\3

\def\ForTex{tex}

\def\Ex#1#2#3{                \edef\op{#1}
   \edef\For{for \ifx \op\ForTex \else La\fi TeX}
   \def\com{#2}
   \def\name{#3}      \hrule
   \medskip\noindent$\underline{\hbox{#1\quad\name.\ext}}$
       \qquad{\it #2\/} {\rm(\For)}\medskip}

\def\Exr#1#2#3{\setbox0=\hbox{\global\1#1  \global\2#2  \global\3#3}
    \Ex{\tex}{Exercise \the\1.\the\2.\the\3}{exr#1#2#3}}

\def\Lib#1{\newpage\hrule
   \noindent\hfil{\bf \strut#1}\hrule}

\hbadness=10000     \vbadness=10000  \hfuzz=99in \vfuzz=99in
                                                                %%
                                                                %%
                                                                %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\noindent NOTES

(a) If you want to get TeX files instead of LaTeX files, remove `\%'
from the first line of file `{\tt Examples.tex}'.%%% first line of this file


(b) If you want different extensions in the files' names, 
change the definition of {\tt\string\ext} in the second line 
of file `{\tt Examples.tex}'.%%% second line of this  file

(c) Files carrying names that start with `exr' have been retrieved
from exercises. Many of these files are incomplete, and they expect
that the reader will provide the missing code. (La)TeX will prompt you
with `?' on incomplete files. In such cases, type `x' followed by
RETURN.

\bigskip  \Lib{DraTeX}   \def\files{\fileD}

\Ex{tex}{First example in section 6.2}{sec62a}

\<<<
\input DraTex.sty
\Draw
   \LineAt(0.1,  0,-18,-10)
   \LineAt(-18,-10,- 6, 26)
   \LineAt(- 6, 26, 18,- 4)
   \LineAt( 18,- 4, 12,-40)
   \LineAt( 18,- 4, 24,-40)
   \LineAt( 18,- 4, 58,- 4)
   \LineAt( 58,- 4, 52,-40) 
   \LineAt(58,-4,64,-40) \LineAt(58,-4,66,4)
\EndDraw
\bye >>>

\Ex{latex}{First example in section 6.2}{sec62b}

\<<<
\documentstyle{report}
  \input DraTex.sty
\begin{document}
\Draw
   \LineAt(0.1,  0,-18,-10)
   \LineAt(-18,-10,- 6, 26)
   \LineAt(- 6, 26, 18,- 4)
   \LineAt( 18,- 4, 12,-40)
   \LineAt( 18,- 4, 24,-40)
   \LineAt( 18,- 4, 58,- 4)
   \LineAt( 58,- 4, 52,-40) 
   \LineAt(58,-4,64,-40) \LineAt( 58,-4,66,4)
\EndDraw
\end{document}>>>


\Ex{latex}{First example in section 6.2---second version}{sec62c}

\<<<
\documentstyle[DraTex]{report}
\begin{document}
\Draw
   \LineAt(0.1,  0,-18,-10)
   \LineAt(-18,-10,- 6, 26)
   \LineAt(- 6, 26, 18,- 4)
   \LineAt( 18,- 4, 12,-40)
   \LineAt( 18,- 4, 24,-40)
   \LineAt( 18,- 4, 58,- 4)
   \LineAt( 58,- 4, 52,-40) 
   \LineAt(58,-4,64,-40) \LineAt(58,-4,66,4)
\EndDraw
\end{document}>>>



\Exr672

\<<<
|Open 
   \MarkLoc(a)    \Move(50,0)  
   \MarkLoc(A)    \Move(50,0)    
   \MarkLoc(b)    \Move(-30,30) 
   \MarkLoc(B)    \Move(-30,30)
   \MarkLoc(c)    \Move(-20,-30) 
   \MarkLoc(C)    
   \Curve(A,b,b,B) 
   \Curve(B,c,c,C) 
   \Curve(C,a,a,A)
|Close>>>


  \Ex{tex}{First example in section 6.1}{sec61}

\<<<
\input DraTex.sty 

We can draw clocks of
different styles and sizes.

\Draw 
  \Move(0,20)     \Line(0,-50) \Line(50,0)
  \PenSize(1.5pt) \Line(0,50)  \Line(-50,0)
  \Move(5,-25)    \Text(--9--)
  \Move(20,-18)   \Text(--6--)
  \Move(20,18)    \Text(--3--)
  \Move(-20,18)   \Text(--12--)
  \Move(0,-18)    {\RotateTo(60) \LineF(19)}
  \RotateTo(210)  \LineF(14)
\EndDraw

We can draw people of 
different shapes and looks.

\Draw(0.6pt,0.6pt)
  \DrawOvalArc(30,45)(0,180) 
  \DrawOvalArc(30,12)(180,360) 
  \DrawOvalArc(60,25)(140,400)
  \Move(0,5)
  \DrawOvalArc(30,60)(225,315)
  \DrawOvalArc(20,52)(260,280)
  \Move(-10,-37) {\Text(--$\cdotp$--)}  \Text(--o--)
  \Move(20,0)    {\Text(--$\cdotp$--)}  \Text(--o--)
\EndDraw

And we can produce many other
types of drawings.       \bye>>>



\Ex{latex}{First example in section 6.1}{sec61a}

\<<<
\documentstyle{report}
\input DraTex.sty 
\begin{document}

We can draw clocks of
different styles and sizes.

\Draw 
  \Move(0,20)     \Line(0,-50) \Line(50,0)
  \PenSize(1.5pt) \Line(0,50)  \Line(-50,0)
  \Move(5,-25)    \Text(--9--)
  \Move(20,-18)   \Text(--6--)
  \Move(20,18)    \Text(--3--)
  \Move(-20,18)   \Text(--12--)
  \Move(0,-18)    {\RotateTo(60) \LineF(19)}
  \RotateTo(210)  \LineF(14)
\EndDraw

We can draw people of 
different shapes and looks.

\Draw(0.6pt,0.6pt)
  \DrawOvalArc(30,45)(0,180) 
  \DrawOvalArc(30,12)(180,360) 
  \DrawOvalArc(60,25)(140,400)
  \Move(0,5)
  \DrawOvalArc(30,60)(225,315)
  \DrawOvalArc(20,52)(260,280)
  \Move(-10,-37) {\Text(--$\cdotp$--)}  \Text(--o--)
  \Move(20,0)    {\Text(--$\cdotp$--)}  \Text(--o--)
\EndDraw

And we can produce many other
types of drawings.       \end{document}>>>

\Ex{latex}{First example in section 6.1---second version}{sec61b}

\<<<
\documentstyle[DraTex]{report}
\begin{document}

We can draw clocks of
different styles and sizes.

\Draw 
  \Move(0,20)     \Line(0,-50) \Line(50,0)
  \PenSize(1.5pt) \Line(0,50)  \Line(-50,0)
  \Move(5,-25)    \Text(--9--)
  \Move(20,-18)   \Text(--6--)
  \Move(20,18)    \Text(--3--)
  \Move(-20,18)   \Text(--12--)
  \Move(0,-18)    {\RotateTo(60) \LineF(19)}
  \RotateTo(210)  \LineF(14)
\EndDraw

We can draw people of 
different shapes and looks.

\Draw(0.6pt,0.6pt)
  \DrawOvalArc(30,45)(0,180) 
  \DrawOvalArc(30,12)(180,360) 
  \DrawOvalArc(60,25)(140,400)
  \Move(0,5)
  \DrawOvalArc(30,60)(225,315)
  \DrawOvalArc(20,52)(260,280)
  \Move(-10,-37) {\Text(--$\cdotp$--)}  \Text(--o--)
  \Move(20,0)    {\Text(--$\cdotp$--)}  \Text(--o--)
\EndDraw

And we can produce many other
types of drawings.       \end{document}>>>


\Exr732

\<<<
|Open
\font\ARROWS=line10\space scaled\magstep5
\font\CIRCLES=lcircle10\space scaled\magstep5
%   \newfont{\ARROWS}{line10\space scaled\magstep5}
%   \newfont{\CIRCLES}{lcircle10\space scaled\magstep5}

                             \Text(--\CIRCLES \char 10--)
\Text(--\CIRCLES \char 11--) \Text(--\ARROWS \char 55--)  
\Text(--\CIRCLES \char 110--)\EntryExit(-1,0,-1,0)
\Text(--\CIRCLES \char 114--)|Close>>>

\Exr741

\<<<
|Open
\Ragged(8)
\Line(10,-10) \Line(10,20)
\LineTo(0,0) 
|Close>>>


\Ex{\tex}{First example in section 8.1}{sec81}

\<<<
|Open
\ThreeDim(-150,-60,-600)
   \Line(60,0,0)   \Line(0,0,60)
   \Line(-60,0,0)  \Line(0,0,-60)
   \LineTo(0,60,0) \Line(60,0,0)
   \Line(0,-60,0)  
   \LineAt(0,60,0,0,60,60)
   \Line(0,-60,0)  
\EndThreeDim |Close>>>


\Ex{\tex}{Example of USA map in section 9.3}{usa}

\<<<
|Open(0.9pt,0.9pt)
\Table\USA{       % California
   -60,-35 & -77,-30 & -80,
   -20 & -90,-15 & -100,40 &
   % Oregon
   -100,50 & -90,80 &
   % Wash
    -90,95 & -78,90 & -75,95 &
   % Minn
    100,70 & 85,60 &
   % Wisc-Mich
    95,60 & 105,65 & 102,63 & 110,60 & 125,60 & 110,55 & 110,30 &
    115,25 & 120,30 & 115,40 & 115,50 & 120,55 & 130,55 & 140,40 &
    135,25 &
   % Ohio-NY-Vt
    145,25 & 155,30 & 160,45 & 175,45 & 175,55 & 180,60 & 195,65 &
   % Maine
    200,75 & 200,85 & 205,90 & 210,90 & 215,80 & 220,75 & 205,60 & 205,50 &
   % Mass--NY
    210,43 & 208,47 & 215,43 & 190,30 & 202,35 &
   % NJ--Va
    197,25 & 190,18 & 185,20 & 190,15 & 190,5 & 182,18 & 182,0 & 185,0 &
   % NC
    190,-8 & 185,-4 & 183,-6 & 186,-6 & 182,-15 & 
    190,-18 & 190,-10 & 192,-10 &
    195,-18 &
   % Ga-Fl
    165,-40 & 160,-50 & 175,-80 & 175,-90 & 170,-100 & 165,-100 &
    155,-80 & 155,-65 & 145,-60 & 140,-62 & 136,-62 & 120,-60 &
   % Alaba--La
    102,-63 & 107,-67 & 107,-72 & 110,-75 & 90,-65 &
    78,-65 &
   % Texas
    62,-78 & 57,-78 & 50,-82 & 53,-92 & 48,-90 & 25,-65 & 15,-65 & 
    15,-68 & -10,-50 &
   % New Mexico
    -40,-50 &
   % Back to California
   -60,-35 }
{ \USA(0,0){\MoveTo} \USA(1,99){\LineTo} } \Text(--USA--) 
\Scale(0.5,0.5) \USA(46,46){\MoveTo} \USA(47,92){\LineTo}
\MoveTo(-30,0) \MarkLoc(a) \USA(0,0){\Move} \MarkLoc(b) 
\USA(0,46){{\LineToLoc(b)} \MarkLoc(b) \MoveToLoc(a) \Move} 
|Close>>>


\Exr{10}1{1a}
\<<<
|Open
\Text(--Government~%
              Bonds (\%)--)  
\Table\B{Britain,9.59 &
 Canada,7.98 &  Japan,5.46 &
 U.S.,  6.84 &  Mexico,14.9} 
\B(0,4){\PutBar} 
|Close >>>

\Exr{10}1{1b}
\<<<
|Open
\chick(0,75)  \Scale(-1,1) 
\chick(0,140) 
|Close >>>

\Exr{10}1{1c}
\<<<
|Open
\Table\x{ 30,40
  & 15,60 & 27,15 & 35,35 
  & 50,45 & 25,70 & 20,20 
  & 25,75 }   \x(0,99){\Tr}  
|Close >>>

\Exr{10}1{1d}
\<<<
|Open
\sqr(-24,0) 
\sqr(0,32) 
\sqr(24,-32)
|Close >>>

\Exr{10}1{1e}
\<<<
|Open
\engine(90)  \MoveTo(50,0)  
\engine(180) \MoveTo(100,0) 
\engine(-30) 
|Close >>>

\Exr{10}1{1f}
\<<<
|Open
\MarkLoc(A) 
\spring(110) \Rotate(70) 
\spring(60)  \MarkLoc(B)
\DSeg\RotateTo(B,A)  
\LSeg\spring(B,A)  
|Close >>>

\Exr{10}21
\<<<
|Open
\new(BODY) \<BODY>(20)
\LineF(20) \Rotate(55) \LineF(16) 
\new(hand) \<BODY>(140) \LineF(35)  
\new(hand) \<BODY>(90) \LineF(7)  
\new(head) \<BODY>(-60) \LineF(19)  
\new(left-leg) \<BODY>(210) \LineF(12) 
\Rotate(30) \LineF(14) \new(right-leg)
\Do(1,11){\I+15; \<head>(\Val\I) 
\LineF(11)} 
|Close >>>


\Exr{10}22

\<<<
|Open
\def\DefineSymbol#1{%
   \Indirect\Define<#1>}

\def\DrawText(--#1--){%
     \let\xNextSym=\xDrawSym  \xNextSym#1{}}

\def\xDrawSym#1{\def\temp{#1}%
     \ifx \temp\empty  \let \xNextSym=\relax
     \else \Indirect<#1>\fi   \xNextSym }

\DefineSymbol A{{ \Line(21,60)
   \Line(21,-60)  \Move(-7,20)
   \Line(-28,0) } \Move(52,0)  }
\DefineSymbol B{{ \DrawText(--P--)
   \Move(-25,18)
   \DrawOvalArc(15,18)(-90,90)
   \Move(0,-18)   \Line(-25,0)}
   \Move(50,0) }    \DefineSymbol P
{{      \Line(0,60)    \Line(25,0)
     \Move(0,-12) \DrawOvalArc(15,12)(-90,90)
     \Move(0,-12)  \Line(-25,0) }      \Move(50,0)  }
 \DefineSymbol C{{     \Move(20,30) 
     \DrawOvalArc(20,30)(45,315) }    \Move(46.6,0)  }
 \DefineSymbol D{{    \Line(0,60)    \Line(20,0)
     \Move(0 ,-30) \DrawOvalArc(20,30)(-90,90) \Move(0,-30)
     \Line(-20,0) }   \Move(50,0)  }
 \DefineSymbol E{{  \DrawText(--F--)  \Move(-50,0)
     \Line(40,0) }  \Move(50,0)      }
 \DefineSymbol F{{   \Line(0,60)   \Line(40,0)
     \Move(-40,-30) \Line(30,0)  }  \Move(50,0)     }
 \DefineSymbol G{{ \DrawText(--C--)
    \Move(-10,30) {\Line(-20,0)} \Line(0,-30)   } 
    \Move(46.6,0)     }
 \DefineSymbol H{{ \Line(0,60)  \Move(40,0) 
    \Line(0,-60)  \Move(0,30)  \Line(-40,0)   }  \Move(50,0)     }
 \DefineSymbol I{{ \Line(0,60)  }  \Move(10,0)     }
 \DefineSymbol J{{ \Move(20,17) \DrawOvalArc(20,17)(180,360)
    \Move(20,0) \Line(0,43)   }  \Move(50,0)     }
 \DefineSymbol K{{ \Line(0,60)  \Move(0,-35)
    \Line(40,35) \Move(-32,-28) \Line(32,-32) }  \Move(50,0)     }
 \DefineSymbol L{{ { \Line(0,60) } \Line(40,0)  }  \Move(50,0)     }
 \DefineSymbol M{{ \Line(0,60)  \Line(25,-60)
    \Line(25,60) \Line(0,-60)   }  \Move(60,0)     }
 \DefineSymbol N{{ \Line(0,60) \Line(40,-60)  
    \Line(0,60)  }  \Move(50,0)     }
 \DefineSymbol O{{ \Move(22,30)  \DrawOval(22,30)   }  \Move(54,0)     }
 \DefineSymbol P{{      \Line(0,60)    \Line(25,0)
     \Move(0,-12) \DrawOvalArc(15,12)(-90,90)
     \Move(0,-12)  \Line(-25,0) }      \Move(50,0)  }
 \DefineSymbol Q{{ \DrawText(--O--)  \Move(-10,-5)
     \Line(-15,15)   }  \Move(55,0)     }
 \DefineSymbol R{{ \DrawText(--P--) \Move(-10,0)
     \Line(-15,36)   }  \Move(50,0)     }
 \DefineSymbol S{{  \Move(20,18) \DrawOvalArc(20,18)(-140,90)
     \Move(0,30)  \DrawOvalArc(20,12)(40,270)  }  \Move(50,0)     }
 \DefineSymbol T{{ \Move(22,0) \Line(0,60)  \Move(-22,0)
     \Line(44,0)   }  \Move(54,0)     }
 \DefineSymbol U{{ \Move(20,15)  \DrawOvalArc(20,15)(180,360)
     \Move(-20,0) \Line(0,45) \Move(40,0) \Line(0,-45)   }
     \Move(50,0)     }
 \DefineSymbol V{{ \Move(0,60) \Line(22,-60)
     \Line(22,60)   }  \Move(54,0)     }
 \DefineSymbol W{{  \Move(0,60) \Line(15,-60)
     \Line(15,60)  \Line(15,-60) \Line(15,60)  }  \Move(70,0)     }
 \DefineSymbol X{{ \Line(40,60)  \Move(-40,0)
     \Line(40,-60)   }  \Move(50,0)     }
 \DefineSymbol y{{ \Move(20,0) \Line(0,34) { \Line(-20,26)}
     \Line(20,26)   }  \Move(50,0)     }
 \DefineSymbol Z{{ \Move(0,60)  \Line(40,0) \Line(-40,-60)
     \Line(40,0)   }  \Move(50,0)     }
 \DefineSymbol 0{{ \Move(25,30) \DrawOval(25,30)   }  \Move(60,0)     }
 \DefineSymbol 1{{ \Line(0,60)   }  \Move(10,0)     }
 \DefineSymbol 2{{ \MarkLoc(a) \Move(0,10)
    \MarkLoc(a')  \Move(40,30)  \MarkLoc(b)
    \Move(0,-10)  \MarkLoc(b')  \Curve(a,a',b',b)
    \Move(-20,10) \DrawOvalArc(20,20)(0,180)
    \Move(-20,-40) \Line(40,0)   }  \Move(50,0)     }
 \DefineSymbol 3{{ \MarkLoc(a')  \Move(0,10)  \MarkLoc(a)
    \Move(20,-10) \MarkLoc(b) \Move(-10,0) \MarkLoc(b')
    \Curve(a,a',b',b)  \Move(22,0) \MarkLoc(b')
    \Move(8,8)  \MarkLoc(a')  \Move(0,10) \MarkLoc(a)
    \Curve(a,a',b',b)  \Move(0,10)  \MarkLoc(a')
    \Move(-8,8) \MarkLoc(b') \Move(-10,0)
    \MarkLoc(b) \Curve(a,a',b',b) \Move(-5,0)
    \MarkLoc(b') \Move(-5,-3) \MarkLoc(a')
    \Move(0,-2)  \MarkLoc(a)  \Curve(a,a',b',b)
    \Line(30,29) \Line(-40,0)   }  \Move(50,0)     }
\DefineSymbol 4{{      \Move(35,0)  \Line(0,60)
     \Line(-35,-35)     \Line(45,0)}    \Move(55,0)  }
 \DefineSymbol 5{{ \Move(15,20) \DrawOvalArc(19,20)(-140,140)
    \Move(-15,10) \Line(0,30) \Line(30,0)   }  \Move(44,0)     }
 \DefineSymbol 6{{ \Move(22,30)  \DrawOvalArc(22,30)(70,270)
    \Move(0,-10) \DrawOvalArc(22,15)(0,174)
    \DrawOvalArc(22,20)(270,360)  }  \Move(54,0)     }
 \DefineSymbol 7{{ \Move(0,60) \Line(40,0)
    \MarkLoc(a) \Move(-20,-60) \MarkLoc(b)
    \DSeg\RotateTo(b,a) \Rotate(20) \MoveF(10) \MarkLoc(b')
    \MoveToLoc(a)
    \DSeg\RotateTo(a,b) \Rotate(-20) \MoveF(10) \MarkLoc(a')
    \Curve(a,a',b',b)  }  \Move(50,0) 