picture
Synopses:
\begin{picture}(width,height) picture command \end{picture}
or
\begin{picture}(width,height)(xoffset,yoffset) picture command \end{picture}
Where there may be any number of picture command’s.
An environment to create simple pictures containing lines, arrows, boxes, circles, and text. This environment is not obsolete, but new documents typically use much more powerful graphics creation systems, such as TikZ, PSTricks, MetaPost, or Asymptote. None of these are covered in this document; see CTAN.
To start, here’s an example showing the parallelogram law for adding vectors.
\setlength{\unitlength}{1cm} \begin{picture}(6,6) % picture box will be 6cm wide by 6cm tall \put(0,0){\vector(2,1){4}} % for every 2 over this vector goes 1 up \put(2,1){\makebox(0,0)[l]{\ first leg}} \put(4,2){\vector(1,2){2}} \put(5,4){\makebox(0,0)[l]{\ second leg}} \put(0,0){\vector(1,1){6}} \put(3,3){\makebox(0,0)[r]{sum\ }} \end{picture}
The picture
environment has one required argument, a pair of positive real numbers (width,height). Multiply these by the value \unitlength
to get the nominal size of the output, i.e. the space that LaTeX reserves on the output page. This nominal size need not be how large the picture really is; LaTeX will draw things from the picture outside the picture’s box.
This environment also has an optional argument (xoffset,yoffset). It is used to shift the origin. Unlike most optional arguments, this one is not contained in square brackets. As with the required argument, it consists of a pair of two real numbers, but these may also be negative or null. Multiply these by \unitlength
to get the coordinates of the point at the lower-left corner of the picture.
For example, if \unitlength
has been set to 1mm
, the command
\begin{picture}(100,200)(10,20)
produces a box of width 100 millimeters and height 200 millimeters. The picture’s origin is the point (10mm,20mm) and so the lower-left corner is there, and the upper-right corner is at (110mm,220mm). When you first draw a picture you typically omit the optional argument, leaving the origin at the lower-left corner. If you then want to modify your picture by shifting everything, you can just add the appropriate optional argument.
Each picture command tells LaTeX where to put something by providing its position. A position is a pair such as (2.4,-5)
giving the x- and y-coordinates. A coordinate is a not a length, it is a real number (it may have a decimal point or a minus sign). It specifies a length in multiples of the unit length \unitlength
, so if \unitlength
has been set to 1cm
, then the coordinate 2.54
specifies a length of 2.54 centimeters.
LaTeX’s default for \unitlength
is 1pt
. It is a rigid length (see Lengths). Change it with the \setlength
command (see \setlength). Make this change only outside of a picture
environment.
The picture
environment supports using standard arithmetic expressions as well as numbers.
Coordinates are given with respect to an origin, which is by default at the lower-left corner of the picture. Note that when a position appears as an argument, as with \put(1,2){...}
, it is not enclosed in braces since the parentheses serve to delimit the argument. Also, unlike in some computer graphics systems, larger y-coordinates are further up the page, ie. y = 1 is above y = 0.
There are four ways to put things in a picture: \put
, \multiput
, \qbezier
, and \graphpaper
. The most often used is \put
. This
\put(11.3,-0.3){...}
places the object with its reference point at coordinates (11.3,-0.3). The reference points for various objects will be described below. The \put
command creates an LR box (see Modes). Anything that can go in an \mbox
(see \mbox & \makebox) can go in the text argument of the \put
command. The reference point will be the lower left corner of the box. In this picture
\setlength{\unitlength}{1cm} ...\begin{picture}(1,1) \put(0,0){\line(1,0){1}} \put(0,0){\line(1,1){1}} \end{picture}
the three dots are just slightly left of the point of the angle formed by the two lines. (Also, \line(1,1){1}
does not call for a line of length one; rather the line has a change in the x coordinate of 1.)
The \multiput
, qbezier
, and graphpaper
commands are described below.
You can also use this environment to place arbitrary material at an exact location. For example:
\usepackage{color,graphicx} % in preamble ... \begin{center} \setlength{\unitlength}{\textwidth} \begin{picture}(1,1) % leave space, \textwidth wide and tall \put(0,0){\includegraphics[width=\textwidth]{desertedisland.jpg}} \put(0.25,0.35){\textcolor{red}{X Treasure here}} \end{picture} \end{center}
The red X will be precisely a quarter of the \textwidth
from the left margin, and 0.35\textwidth
up from the bottom of the picture. Another example of this usage is to put similar code in the page header to get repeat material on each of a document’s pages.
• \put | Place an object at a specified place. | |
• \multiput | Draw multiple instances of an object. | |
• \qbezier | Draw a quadratic Bézier curve. | |
• \graphpaper | Draw graph paper. | |
• \line | Draw a straight line. | |
• \linethickness | Set thickness of horizontal and vertical lines. | |
• \thinlines | The default line thickness. | |
• \thicklines | A heavier line thickness. | |
• \circle | Draw a circle. | |
• \oval | Draw an oval. | |
• \shortstack | Make a stack of objects. | |
• \vector | Draw a line with an arrow. | |
• \makebox (picture) | Draw a box of the specified size. | |
• \framebox (picture) | Draw a box with a frame around it. | |
• \frame | Draw a frame around an object. | |
• \dashbox | Draw a dashed box. |
© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/picture.html