Go to the first, previous, next, last section, table of contents.


2. Using the TeXdraw Commands

The main TeXdraw macros (commands) are defined in the file `texdraw.tex'. These macros may be used directly in TeX. The file `texdraw.sty' provides an interface for use with LaTeX2e. The following sections describe the basic commands for TeXdraw.

2.1 Accessing TeXdraw

The form of the user command to run the TeX program depends on which version of TeX is being used, and which other macro packages are preloaded as format files. Typically, installations have at least two versions of TeX -- plain TeX which includes basic typesetting macros (usually invoked as `tex') and LaTeX2e which includes the LaTeX2e typesetting macros (usually invoked as `latex'). An older version of LaTeX, version 2.09, may also be available. The TeXdraw macros can be used with plain TeX and with either version of LaTeX.

For use with plain TeX, the user must read in the TeXdraw macros from the file `texdraw.tex'.

\input texdraw            % Read in the TeXdraw macros
 ...
\btexdraw
  ...                     % TeXdraw commands to generate a drawing
\etexdraw

For use with LaTeX version 2.09, the user reads in the TeXdraw macros from the file `texdraw.tex' and optionally defines the \begin{texdraw} / \end{texdraw} environment.

\documentstyle[11pt]{article}  % Article style with the 11pt size options
...
\input texdraw            % Read in the TeXdraw macros
\newenvironment{texdraw}{\leavevmode\btexdraw}{\etexdraw}
 ...
\begin{texdraw}
  ...                     % TeXdraw commands to generate a drawing
\end{texdraw}
...
\end{document}

For use with LaTeX2e, the user must load the texdraw package (file `texdraw.sty'). This package file defines the \begin{texdraw} / \end{texdraw} environment, brings in the standard graphics package and reads in the file `texdraw.tex' containing the definitions of the TeXdraw macros.

\documentclass[11pt]{article}  % Article class with the 11pt size option
\usepackage{texdraw}           % TeXdraw commands

\begin{document}
 ...
\begin{texdraw}
  ...                     % TeXdraw commands to generate a drawing
\end{texdraw}
 ...
\end{document}

As the TeXdraw commands are processed by TeX, an intermediate PostScript file is generated. The intermediate PostScript has a name of the form `name.ps1'. The name part is derived from the name of the main TeX file being processed. If more than one drawing is produced, the digit in the file name extension is incremented.(1)

The TeXdraw commands to produce a drawing are inserted between \btexdraw and \etexdraw commands, or for LaTeX, between \begin{texdraw} and \end{texdraw} commands. This results in a TeX box of appropriate size containing the drawing generated by the TeXdraw commands. The TeXdraw box can be positioned in a document like any other TeX box.

The \centertexdraw{...} macro centers the box generated by TeXdraw. The vertical space taken up is equal to the vertical size of the drawing. The \centertexdraw macro is normally used in vertical mode (between paragraphs). A \par command (a blank line will do also) before a \centertexdraw command will terminate horizontal mode and return to vertical mode. For LaTeX, a structured equivalent to the \centertexdraw{...} command is shown below.

\begin{center}
\begin{texdraw}
  ...
\end{texdraw}
\end{center}

The \everytexdraw command can be used to define a set of TeXdraw commands that will be executed at the beginning of every TeXdraw drawing. It is invoked as \everytexdraw{ ...}, with the desired TeXdraw commands as arguments.

\btexdraw
Start a TeXdraw drawing. The drawing is terminated with an \etexdraw command.
\etexdraw
End a TeXdraw drawing started with a \btexdraw command. The resulting TeXdraw drawing is placed in a box with height equal to the height of the drawing and width equal to the width of the drawing. The depth of the box is zero.
\begin{texdraw}
Start a TeXdraw drawing. The drawing is terminated with an \end{texdraw} command. This command is for use with LaTeX.
\end{texdraw}
End a TeXdraw drawing started with a \begin{texdraw} command. The resulting TeXdraw drawing is placed in a box with height equal to the height of the drawing and width equal to the width of the drawing. The depth of the box is zero. This command is for use with LaTeX.
\centertexdraw{ ... }
Center a TeXdraw box horizontally. The argument contains TeXdraw commands. The resulting box has the horizontal size \hsize and height equal to the height of the drawing.
\everytexdraw{ ... }
Specify TeXdraw commands to be executed at the beginning of every TeXdraw drawing.

2.2 Command syntax

Generally TeXdraw commands that take a single argument need a terminating blank or newline after the argument. Arguments that are self-delimiting, such as coordinates within parentheses and text within braces, do not need the terminating blank. However, even when not needed by the defining syntax of the command, blanks following command arguments are allowed and ignored within the TeXdraw environment.

On entering the TeXdraw environment, TeX is in internal vertical mode (vertical mode inside a \vbox). In this mode, spaces can be placed freely between commands. However, any other extraneous input that generates output that is not part of the TeXdraw environment is disallowed.

Blank lines are interpreted as paragraph breaks, equivalent to a \par command. The TeXdraw macro \centertexdraw is defined with the \long attribute to allow \par commands and blank lines to be interspersed between TeXdraw commands. The \btexdraw and \etexdraw commands also allow \par command and blank lines to be included.

2.3 TeXdraw coordinates

The TeXdraw coordinate system has increasing x to the right and increasing y upward. The coordinates (without the unit) are floating point numbers. Integer values can be written without a decimal point. The size of the drawing is determined by the maximum excursions of the coordinates specified in TeXdraw commands.

Consider the following example of TeXdraw commands to draw a simple figure.

\centertexdraw{
  \drawdim cm  \linewd 0.02
  \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2)
  \textref h:C v:C \htext(2 3){$\sum \rho_n$}
}

This drawing uses units of centimetres, with a line width of 0.02 cm. The x coordinate ranges between 1 and 3 while the y coordinate ranges between 2 and 4. When included into a document, the size of the drawing is 2 cm by 2 cm. The drawing is placed in a TeX box, with the lower lefthand corner of the box corresponding to TeXdraw coordinate (1 2) and the upper righthand corner at (3 4). The \centertexdraw command centers the drawing horizontally. The \textref command controls the centering of the text. The text in this drawing is centered (both horizontally and vertically) at the coordinate (2 3).

2.4 Coordinate specification

Coordinates are specified within parentheses, with blanks (but no comma) between the values. Leading blanks and trailing blanks are permitted within the parentheses. The coordinates refer to units, which are specified by the \drawdim command. The default is inches, but any valid TeX dimension unit can be specified. Symbolic specification of saved coordinate values will be discused later (see section 3.3 Saving positions).

\drawdim dim
Set the units to dim. The argument dim can be any valid TeX dimension unit. The units are used to interpret coordinate values. Examples of valid units: cm, mm, in, pt, and bp.

Examples of coordinate and scaling specifications:

\drawdim {cm} \move(2 2)
Set the units to centimetres, move to a position 2 cm to the right and 2 cm up from the origin of the drawing coordinate system.
\drawdim bp
Set the units to big points.
\lvec ( 2.2 +5.5) \lvec(2.3 -2) \lvec(2.2 5.4 )
Examples of acceptable coordinate specifications.

2.5 Line vectors

TeXdraw implements moves, line vectors and arrow vectors. There are both absolute and relative motion versions of these vector commands. TeXdraw maintains a current position. Lines are drawn from the current position to a new coordinate, with the new coordinate becoming the new current position. An explicit move can be used to establish a new current position. The position (0 0) is used if there is no move to an initial current position.

The \move and \rmove commands establish a new current position without drawing a line. The \lvec and \rlvec commands draw a line from the current position to a new position, which then becomes the new current position. The \avec and \ravec commands draw a line with an arrowhead from the current position to a new coordinate, which then becomes the new current position. The tip of the arrow is at the new current position. The direction of the arrow follows the direction of the line. Since this direction is undefined for zero length vectors, these are not allowed for \avec or \ravec. Zero length arrow vectors will generate a PostScript print error: undefinedresult. For any non-zero length vector, the full size arrowhead is drawn, even if that arrowhead is longer than the line length.

The absolute motion versions of these commands specify the coordinate of the final position.

\move (x y)
Move to coordinate (x y). The new current position is (x y).
\lvec (x y)
Draw a line from the current position to coordinate (x y). The new current position is (x y).
\avec (x y)
Draw a line with an arrowhead from the current position to (x y). The new current position is (x y). The arrowhead is aligned with the line, with the tip at (x y).

The relative motion versions of these commands interpret the coordinates as displacements relative to the current position. Given the displacements (dx dy) as a parameter, each of the relative motion commands moves dx units in the x direction and dy units in the y direction.

\rmove (dx dy)
Move from the current position, dx units in the x direction and dy units in the y direction. The final position becomes the new current position.
\rlvec (dx dy)
Draw a line from the current position, dx units in the x direction and dy units in the y direction. The final position becomes the new current position.
\ravec (dx dy)
Draw a line with an arrowhead from the current position, dx units in the x direction and y units in the y direction. The final position becomes the new current position. The arrowhead is aligned with the line, with the tip at the new current position.

Lines can be customized with commands to change the line width, line pattern and line gray level rendition. In addition, commands for changing the type and size of the arrowhead are available.

\linewd width
Set the line width to width units. Initially width is 0.01 inches (corresponding to 3 pixels at 300 pixels to the inch).
\lpatt (pattern)
Set lines to have the pattern (pattern). A pattern is a sequence of on/off lengths separated by blanks and enclosed in parentheses. The lengths alternately specify the length of a dash and the length of a gap between dashes. Each length is interpreted using the current scaling and drawing units. The pattern is used cyclically. The empty pattern signifies a solid line. The initial line pattern is a solid line, corresponding to the empty pattern \lpatt ().
\setgray level
Set the gray level of lines. Gray levels are real values from 0 (black) through intermediate values (gray) to 1 (white). The initial gray level is 0 corresponding to black.
\arrowheadtype t:type
Set the arrowhead type to type, where type is one of F, T, W, V, or H. There are two kinds of arrowheads. The first kind is a triangle. There are 3 variants: type T is an empty triangle, type F is a filled triangle (using the current gray level for lines), type W is a triangle filled with white. The second kind of arrowhead is an open ended Vee. There are 2 variants: type V has the stem continue to the tip, type H has the stem stop at the base of the arrowhead. The initial arrowhead type is T.
\arrowheadsize l:length w:width
Set the arrowhead size to be length units long and width units wide. The width is measured across the "base" of the arrowhead. The initial arrowhead size has a length of 0.16 inches and a width of 0.08 inches.

Note that the lines which outline the arrowhead will be drawn with the same line pattern used for the stem. Normally, arrow vectors are drawn with the line pattern set for a solid line. Note that the fill level used for the F variant of the arrowhead uses the same gray level as used for lines. The difference between the T variant and the W variant only shows up if the arrowhead is placed over non-white areas of the drawing. The W variant obliterates the area under the arrowhead.

Examples of line parameter and arrowhead settings are shown in the following code.

\centertexdraw{
  \drawdim in
  \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0 0.5)
  \linewd 0.01 \setgray 0   \arrowheadtype t:V \avec(0.5 0.5)
  \linewd 0.015 \lpatt(0.067 0.1) \lvec (1 0)
  \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(1.5 0.5)
  \arrowheadtype t:H \avec(2.0 0.5)
  \setgray 0.4 \arrowheadtype t:W \avec(3.0 0)
}

2.6 TeX text

Text may be superimposed on the drawing. The text argument of the \htext command is in horizontal mode. This text can be ordinary text, math mode expressions, or even more complicated boxes consisting of tables and the like. The resulting TeX text is placed in a box. The reference point of the box can be chosen to be one of nine locations: horizontally left, center or right; vertically top, center or bottom. The \htext command takes one of two forms.

\htext (x y){text}
\htext {text}
The first form of this command places the TeX text text horizontally with the text reference point at the coordinate (x y). The new current position is (x y). The second form of this command places the TeX text text horizontally with the text reference point at the current position. The text reference point is set with the \textref command.

Text can be placed vertically using the \vtext command. The text argument is in horizontal mode. The TeX text is placed in a box and then rotated counterclockwise. The reference point is the point in the box, before rotation of the text. Not all PostScript printer drivers support vertical text.

\vtext (x y){text}
\vtext {text}
The first form of this command places the TeX text text vertically with the text reference point at the coordinate (x y). The new current position is (x y). The second form of this command places the TeX text text vertically with the text reference point at the current position. In both cases, the TeX text is placed in a box and the box is rotated counterclockwise by 90 degrees about the text reference point. The text reference point is set with the \textref command.

Text can be placed at an arbitrary angle using the \rtext command. The text argument is in horizontal mode. The TeX text is placed in a box and then rotated counterclockwise. The reference point is the point in the box, before rotation of the text. Not all PostScript printer drivers support rotated text.

\rtext td:angle (x y){text}
\rtext td:angle {text}
The first form of this command places the TeX text text at an angle with the text reference point at the coordinate (x y). The new current position is (x y). The second form of this command places the TeX text text at an angle with the text reference point at the current position. In both cases, the TeX text is placed in a box and the box is rotated counterclockwise by angle degrees about the text reference point. The text reference point is set with the \textref command.

The reference point for subsequent TeX text in a \htext, \vtext or \rtext command is set with the \textref command.

\textref h:h-ref v:v-ref
Set the text reference point for subsequent text commands. The horizontal reference point h-ref is one of L, C or R (left, center or right). The vertical reference point v-ref is one of T, C or B (top, center or bottom). For rotated text, the reference point is determined before rotation. The initial text reference point corresponds to \textref h:L v:B.

The font used to render the text is determined as for any other TeX text. Normally the font used outside of TeXdraw is in effect. If desired, other fonts can be specified as part of the text. Any font changes within a TeXdraw text command remain local to that command.

Only the coordinate of the text reference point in a \htext, \vtext or \rtext command is used in calculating the size of the drawing. This means that text itself can spill outside of the drawing area determined by TeXdraw. The area of the drawing can be increased to include the text by issuing additional \move commands.

\centertexdraw{
             \avec(-0.75 -0.25) \textref h:R v:C \htext{H-text}
  \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext{H-text}
  \move(0 0) \avec(0 +0.5)      \textref h:L v:T \vtext{V-text}
  \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext{H-text}
  \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext{H-text}
}

2.7 Circles, ellipses and arcs

TeXdraw supplies commands to generate circles, ellipses and arcs. There are two forms of the circle command. The \lcir command draws a circle of given radius. The \fcir command draws a filled circle. In the latter case, the circle is filled by a specified gray level. For the filled circle, the line defining the circumference of the circle is not drawn. Note that the gray level area filled in by the \fcir command is opaque, even if the fill is chosen to be white. For either form of the circle command, the drawing size is increased if necessary to contain the circle.

The \lellip command generates an ellipse specified by the radius of the ellipse in the x direction and the radius of the ellipse in the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipse is sym the y direction. The ellipsey the xv-refipse is sym the yyy direction. The55"> y direction. The ellipse

y directiont{V-text} \move(0 0) \aveVAR>y direction. The ellipsey Circles, ellrection. The ellipse is sy the y direction. The ellipse is sym m te y direction The ellipse is sym the y direct on. The ellipse is sy the y direction. The ellip"IDX57"> h:R v:B \htext{pse in the x direction and the rad the ylies commandscomon. The elliE="IDX37"> direction. T sAR>}-int. The teeAR>} direction. The5e of given radius. er case, the circle or the f

Ce ellipsCODE>-int. The te Set }yy the x command.="IDX52"> TeAove(0 pen e,mode inside a command is us Set

Notet can cto the tip, type Hther extraneous ipse is0.7t grtidth . Fortidth<-ed 07 ted 07)lank lines are intert drawn. , grF\textref On entering/CODE> ch vector, the \fcir

The fo6ut any valid TeX dim6/VAR> of 0.08 inchraw.texi on 1is in intern mod4xtref). Th0e second form0 of this comma,>). Th1e second form1 of this comma, The first for2e second form2lute motion vershe units rst for3e second form3position is ( Cent tVAR>f the forion. e defining ts the ifiwithin+0.5)

uplieVAR>f the forion. e defining ts the T ifiwithin 2) \lvecVArolawithin "phe "f > The apt hCODE>\tem of s ophe v:v-rhe TeXdraw dith eius of thecVArolawithi at TT> and optional There areuiangln, commandowhe, TeXdraw environm of thraw.te vbe spelocal nd arrec circ There r440ub44g. the ,E>TT> and ox(u) = (1-u)^3 x0 + 3u (1-u)^2 x1 + 3u^2 (1-u) x2 + u^3 x3 y(u) = (1-u)^3 y0 + 3u (1-u)^2 y1 + 3u^2 (1-u) y2 + u^3 y3 and is opaque, even if the fill isc commands dr1e second form1 of thirst for2e second form2lute morst for3e second form3position is

The first for3e second form3position is ). Th1e second form1 of this commarshe units rst for2e second form2lute motion veces vbe svecVArolawithinche arrowe on fevel. FoX100"set with thlocalctionto interupdate \fcir commandhe second ft drawn. CODE>3"set with threc nds.

CODE>\ts placng TeX text Set the units

A form `` > wheadVAR>rommant

\documeecVArolawithino the 
ch

>
 not ways
he 0)el.
e clE>


manal psstextref\everytexdraraw environment.

circwithidrawing.   on 
E>TT> and opaces cawraw.texi on o diretexdraent.

inside a \vived from the "texdraw_2./CODE> .  Fw_2./c
comma0 1)
  • The fo6or any other TeX tex6the drawing. The tex6s that are self-dt all PostSdealhe TeXdpaAR> Note thaded Vee. segor LaTnits in thale unds A> PRE> io circle oA> comm itifont used,in thalCODE> ODE> command inate and scasequent TeXnate and scaling sps Set between ODE>

    Set, units to centimetreasequent Tedn internfing the TeXdoA> < ue withfing > PRE> io circle et > fining t> ue command is casesocanatess plae that thes to big poVee. e filledosition, wX100"withident, TeX ithe curre. Thion. The t internve-picturcified as part offing the TeXE="SEC5" HREF="ifingo big pofings) > PRE> io circle oregcome The elliocal or \rteT e \lcifingo big pm the regcome25">e cle oA>
    ue withtes an ellipion.he ellip hen i ueo titselhe a formed as part offing the TeXlank liellipse is ind is a fingy< of the drawing can ellipse is ncreased ius onclude the is opaque, even if the fill is fing is sym the yn is < ue the x digreR>). A pa withrecti) > PRE> io circle oregcome Theent, TeX liellipse is VAR> direction. Thel rendition. In addition, commands for changing the type and size of the asrrowhead are av of the circle7pse is sym the yn is < PRE> io circle oregcome The or \ VAR> direction. ThTforion. arIDX5NAME=> ue DX58"> el renditioel foIn addition, commands for anging the type and size of the asrrowhe d are av ofX52"> Text cinside a \vbtes an e"flag"e The ellPRE> io ce drawinE="SEC5"> ue w"IDX5NAME="IDX57"><> enocal and. ven radiust wircumf. part offactE>, W < ue terptermth then part ofthat thes to big poerence point he tip, type H .ngth)les comma0 efere/c comma0ngth<85) uea withCODE> C from t ueo tCthe box is zeands moVee. There ars5"(e.CODEized with commtimetreasequent Tet thethe box

    also) bef > uea withCODE>nate > ueae yy the rotation ments rela/VE>\drawdim bp

    ints. ckagd{tex{texdraw}. /A> ue terbee> comm It)

    a rot> ue wt witlieVilDX18">e of C from rot> ue wt wit Ea inge ca5"> ue Theeot> ue> di n set for a solids i f is mmanrot> ue idoA> AfingTT> andynrawino the formcoordinate range1espon">s the is ,rmcoordinate range1espon">previous is ,rmcoordinate range3espon">nf 0.16 ,rmcoordinate range11espon">X100.16 >y,rmcoordinate rangeorrespon">lanks xt. n. ts is v ofXBODYCr f/HTM2"><./usr/sh fo/doc/te loca-piipt hs/te rang/te range3espon0000644000000000000000000003315210023712056022151 0uCODE rootroot<t intern- 3. DrytexdrSegor LaDX18"Sectionr f/HEArm ofBODYCr no the formcoordinate range1espon">s the i