Overview | The picture Environment | The pstricks Package LaTeX Graphics The picture Environment LaTeX Graphics

# Basics

## Line segments

Source file
The line command has two arguments:
• a direction vector,
• a length.
The components of the direction vector have to be coprime (no common divisor except 1), and they are restricted to the integers

The picture illustrates all 25 possible slope values in the first quadrant. The length is relative to unitlength. The length argument is the vertical coordinate in the case of a vertical line segment, the horizontal coordinate in all other cases.

Because of the restrictions to direction vectors, drawing line segments usually necessitates an extensive search for suitable points. In many cases, drawing the desired line segments may not be possible without the use of additional packages, such as eepic, or pstricks.

## Circles

Source file
The argument of the circle command is relative to unitlength and determines the diameter (not the radius). The original picture environment only admits diameters up to approximately 14mm, and even below this limit, not all diameters are possible. The circle* command produces disks (filled circles).

As for drawing larger circles, see the section about circles and ellipses.

## Arrows

Source file
For arrows, the components of the direction vector are even more restricted than for line segments, namely to the integers

Components also have to be coprime (no common divisor except 1). Notice the effect of the \thicklines command on the arrows pointing to the upper left.

## The multiput and the linethickness command

Source file
The \multiput command has 4 arguments: the starting point, the translation vector, the number of objects, and the object to be drawn. The \linethickness{length} command applies to horizontal and vertical line segments, but neither to oblique line segments, nor to circles. It does, however, apply to quadratic Bézier curves!

## Ovals, thinlines, thicklines

Source file
Line thickness can be controlled by two kinds of commands: \linethickness{length} on the one hand, thinlines and thicklines on the other. While \linethickness{0.075mm} applies only to horizontal and vertical lines (and quadratic Bézier curves), \thinlines and \thicklines apply to oblique line segments as well as to curves such as circles or ovals.

## Text, formulas, colors

Source file
The color package allows the use of colors inside and outside of picture environments.

Predefined colors of the color package are: black, white, red, green, blue, yellow, cyan, and magenta. As the current example shows, the definecolor command allows for the definition of arbitrary further colors in terms either of the gray, or the rgb color model. (LATEX also supports a third color model, cymk).

As this example shows, the colorbox and the fcolorbox commands are not compatible with latex2html, which produced this text.

Source file
As this example illustrates, splitting up a circle into four quadratic Bézier curves is not satisfactory. For a better solution, see the section about quadratic Bézier curves.

The example again shows the effect of the linethickness command on horizontal or vertical lines, and of the thinlines and thicklines commands on oblique line segments. It also shows that both kinds of commands affect quadratic Bézier curves, each command overriding all previous ones.

Let denote the end points, and the respective slopes, of a quadratic Bézier curve. The intermediate control point is then given by the equations

(1)

• java qbezier <> <> <> <> <> <>
writes a file qbezier.tex which can be pasted into a picture environment, whence it draws the desired curve.

## Marking angles

Source file
In the current picture, arcs are approximated by quadratic Bézier curves.

In order to get the control points of an arc of radius marking the angle , one has to
1. translate and rotate the angle in order to move the vertex to the origin and have the bisector point in the direction of the axis (transformation ),
2. reduce the vectors and to length ,
3. let the intermediate control point be equal to , and being the coordinates of point after transformation and reduction to length ,
4. apply the transformation to points , , and .
If the Java program arc.java (see PDF Version) is started with the command line
• java arc <> <> <> <> <> <> <>,
it produces a file arc.tex which can be pasted into a picture environment, whence it draws the required arc. As can be seen from the above input file, the obtuse angle is marked in parts: by consequtively marking the angles and .

## Line thickness again: the linethickness command

Source file
As can be seen from this picture, the command linethickness{length} applies to horizontal and vertical lines as well as to Bézier curves, but not to circles, or oblique line segments. Ovals are a combination of horizontal and vertical lines, and arcs.

## Line thickness again: thinlines and thicklines

Source file
As the comparison of the lower half of the picture with the upper half shows, the thinlines and the thicklines commands apply to all line segments and curves, but the effect cannot said to be very striking.

## Multiple use of predefined partial pictures

Source file
A partial picture can be declared and defined by the commands
• \newsavebox{name}     (declaration)
• \newsavebox{name}(size)[position]{content}     (definition)
and then be arbitrarily often used by the command
• \usebox{name}.
The name argument refers to a LATEX storage bin and therefore is of a command nature (which accounts for the backlashes in the current example). size is a numeric pair referring to the current value of \unitlength.

An object defined with the savebox command (such as \foldera in the current example) can be used in the definition of another such element (\folderb). The \oval command was applied because the connecting segments are two short to be drawn with the \line command.

# Applications

Source file

Source file

Source file

Source file

## Rapidity

Source file
Each symmetric half of the tanh curve is approximated by a quadratic Bézier curve. See (1) for details.

Source file

## Line of simultaneousness

Source file
The inserts in the input file drawing the angle markings are produced, according to Marking angles with the Java program arc.java (see PDF Version).

Source file

# Additional Examples of Bézier Curves

## Catenary

Source file
The right half of the curve ends in the point , the slope there having the value . Using equation (1) in the section Quadratic Bézier curves, we can calculate the intermediate control points. They turn out to be and . Or, using the Java program qbezier.java described there (see PDF Version), we can generate the qbezier command lines and insert them into the LATEX file. The red crosses indicate points of the real catenary. The error is barely noticeable, being less than one percent.

Source file

## Catenaries ofconstant length

Source file

From the equation

of the catenary, it is seen that all catenaries can be obtained by scaling the curve with factor . A catenary of length having its vertex in the origin and ending in the point satisfies (see http://www.vsmp.ch, Bulletin nr. 87) the equations

From these equations, for we get:

Using equation (1) in the section Quadratic Bézier curves, we can calculate the intermediate control points. Or we can, by using the Java program qbezier.java described there (see PDF Version), produce the qbezier command lines and insert them into the LATEX file.

## Circles and ellipses

Source file
The circle () was built from 8 arcs, each of 45 degrees, and each approximated by a quadratic Bézier curve. Circles and ellipses can then be obtained by rotating, scaling and translating.
Thus, the building block of all the circles and ellipses is the quadratic Bézier curve determined by the control points

(2)

45 degrees arc

The quadratic Bézier curve with control points (2) is given by the equation

From this, we get:

(3)

The error amounts to approximately 0.3 percent. From (3), we further conclude that for . Letting , we can see the symmetry with respect to :

The Java program bezierellipsen.java (see PDF Version) generates a file, ellipse.tex, which can be pasted into a picture environment. Running the program with
• java bezierellipsen <u> <v> <a> <b> <phi>
produces a file representing the ellipse with center and radii und , and rotated by <phi> degrees.

# Enhancing the picture Environment with Packages epic and eepic

The packages epic and eepic enhance the picture environment. They are extensively described in GOOSSENS, MITTELBACH, SAMARIN[1].

## matrixput

Source file
The \matrixput command is the natural generalization of the \multiput command to two dimensions.

As this example shows, not all the pixels always make it into the final picture.

## putfile

Source file
The slash in the command \putfile{data/datafile1} may have to be replaced by the backslash on a Windows system. The two files datafile1 and datafile2 contain one coordinate pair on each line.

datafile1, for example, contains the lines

10 10
20 20
30 20
35 21
50 15
55 16
52 17
60 16

## Line segments and circlesin the eepic package

Source file
With the use of the eepic package, line segments of any slope (defined by two integers), and circles of any radius can be drawn within the picture environment.

## Bibliography

1
M. Goossens, F. Mittelbach, A. Samarin The LATEX Companion

2
M. Goossens, S. Rahtz, F. Mittelbach The LATEX Graphics Companion

3
John D. Hobby, User's Manual, http://cm.bell-labs.com/who/hobby/

4
Alan Hoenig, TeX Unbound, OXFORD UNIVERSITY PRESS, 1998, ISBN 0-19-509685-1

5
Donald E. Knuth. The METAFONTbook. ADDISON-WESLEY, 1992, ISBN 0-201-13445-4 und ISBN 0-201-13444-6 (soft)

6
Leslie Lampert. LATEX - A Document Preparation System. ADDISON-WESLEY, 1994 (13th Printing November 2001), ISBN 0201529831

7
Helmut Kopka. LATEX - Eine Einführung. ADDISON-WESLEY, 1992, ISBN 3-89319-434-7

8
Helmut Kopka. LATEX - Erweiterungsmöglichkeiten. ADDISON-WESLEY, 1992, ISBN 3-89319-356-1

9
Keith Reckdahl, Using Imported Graphics in LaTeX2e,
ftp://ftp.dante.de/tex-archive/info/epslatex.ps,
ftp://ftp.dante.de/tex-archive/info/epslatex.pdf