5.2 The picture Environment
107
Most drawing commands have one of the two forms
\put(x,y){object}
or
\multiput(x,y)(∆x,∆y){n}{object}
Bézier curves are an exception. They are drawn with the command
\qbezier(x
1
,y
1
)(x
2
,y
2
)(x
3
,y
3
)
5.2.2 Line Segments
\setlength{\unitlength}{5cm}
\begin{picture}(1,1)
\put(0,0){\line(0,1){1}}
\put(0,0){\line(1,0){1}}
\put(0,0){\line(1,1){1}}
\put(0,0){\line(1,2){.5}}
\put(0,0){\line(1,3){.3333}}
\put(0,0){\line(1,4){.25}}
\put(0,0){\line(1,5){.2}}
\put(0,0){\line(1,6){.1667}}
\put(0,0){\line(2,1){1}}
\put(0,0){\line(2,3){.6667}}
\put(0,0){\line(2,5){.4}}
\put(0,0){\line(3,1){1}}
\put(0,0){\line(3,2){1}}
\put(0,0){\line(3,4){.75}}
\put(0,0){\line(3,5){.6}}
\put(0,0){\line(4,1){1}}
\put(0,0){\line(4,3){1}}
\put(0,0){\line(4,5){.8}}
\put(0,0){\line(5,1){1}}
\put(0,0){\line(5,2){1}}
\put(0,0){\line(5,3){1}}
\put(0,0){\line(5,4){1}}
\put(0,0){\line(5,6){.8333}}
\put(0,0){\line(6,1){1}}
\put(0,0){\line(6,5){1}}
\end{picture}
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
(
(
(
(
(
(
(
(
(
(
(
(
(
((
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
Convert pdf fillable form to html - control software system:C# PDF Convert to HTML SDK: Convert PDF to html files in C#.net, ASP.NET MVC, WinForms, WPF application
How to Convert PDF to HTML Webpage with C# PDF Conversion SDK
www.rasteredge.com
Convert pdf fillable form to html - control software system:VB.NET PDF Convert to HTML SDK: Convert PDF to html files in vb.net, ASP.NET MVC, WinForms, WPF application
PDF to HTML Webpage Converter SDK for VB.NET PDF to HTML Conversion
www.rasteredge.com
108
Producing Mathematical Graphics
Line segments are drawn with the command
\put(x,y){\line(x
1
,y
1
){length}}
The \line command has two arguments:
1. a direction vector,
2. a length.
The components of the direction vector are restricted to the integers
−6, −5, ..., 5, 6,
and they have to be coprime (no common divisor except 1). The figure
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.
5.2.3 Arrows
\setlength{\unitlength}{0.75mm}
\begin{picture}(60,40)
\put(30,20){\vector(1,0){30}}
\put(30,20){\vector(4,1){20}}
\put(30,20){\vector(3,1){25}}
\put(30,20){\vector(2,1){30}}
\put(30,20){\vector(1,2){10}}
\thicklines
\put(30,20){\vector(-4,1){30}}
\put(30,20){\vector(-1,4){5}}
\thinlines
\put(30,20){\vector(-1,-1){5}}
\put(30,20){\vector(-1,-4){5}}
\end{picture}
-
:
1
*

X
X
X
X
X
X
Xy
C
C
C
C
CO
 

Arrows are drawn with the command
\put(x,y){\vector(x
1
,y
1
){length}}
For arrows, the components of the direction vector are even more narrowly
restricted than for line segments, namely to the integers
−4, −3, ..., 3, 4.
Components also have to be coprime (no common divisor except 1). Notice
the effect of the\thicklines command on the two arrows pointing to the
upper left.
control software system:VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to
Convert to PDF with embedded fonts or without original fonts fast. Convert multiple pages PowerPoint to fillable and editable PDF documents.
www.rasteredge.com
control software system:VB.NET Create PDF from Excel Library to convert xlsx, xls to PDF
Create fillable and editable PDF documents from Excel in Create searchable and scanned PDF files from Excel in VB Convert to PDF with embedded fonts or without
www.rasteredge.com
5.2 The picture Environment
109
5.2.4 Circles
\setlength{\unitlength}{1mm}
\begin{picture}(60, 40)
\put(20,30){\circle{1}}
\put(20,30){\circle{2}}
\put(20,30){\circle{4}}
\put(20,30){\circle{8}}
\put(20,30){\circle{16}}
\put(20,30){\circle{32}}
\put(40,30){\circle{1}}
\put(40,30){\circle{2}}
\put(40,30){\circle{3}}
\put(40,30){\circle{4}}
\put(40,30){\circle{5}}
\put(40,30){\circle{6}}
\put(40,30){\circle{7}}
\put(40,30){\circle{8}}
\put(40,30){\circle{9}}
\put(40,30){\circle{10}}
\put(40,30){\circle{11}}
\put(40,30){\circle{12}}
\put(40,30){\circle{13}}
\put(40,30){\circle{14}}
\put(15,10){\circle*{1}}
\put(20,10){\circle*{2}}
\put(25,10){\circle*{3}}
\put(30,10){\circle*{4}}
\put(35,10){\circle*{5}}
\end{picture}
bej
&
%
$
&
%
$
behjm

"
!
#
"
!
#
&
%
$
r u x z }
The command
\put(x,y){\circle{diameter}}
draws a circle with center (x,y) and diameter (not radius) diameter. The
pictureenvironmentonlyadmitsdiametersuptoapproximately14mm,
and even below this limit, not all diameters are possible. The \circle*
command produces disks (filled circles).
As in the case of line segments, one may have to resort to additional
packages, such as eepic or pstricks. For a thorough description of these
packages, see The L
A
T
E
XGraphics Companion [4].
There is also a possibility within thepicture environment. If one is not
afraid of doing the necessary calculations (or leaving them to a program),
arbitrary circles and ellipses can be patched together from quadratic Bézier
curves. See Graphics in LAT
E
X2
ε
[17] for examples and Java source files.
control software system:VB.NET Create PDF from Word Library to convert docx, doc to PDF in
Create PDF files from both DOC and DOCX formats. Convert multiple pages Word to fillable and editable PDF documents.
www.rasteredge.com
control software system:C# Create PDF from OpenOffice to convert odt, odp files to PDF in
Convert OpenOffice Text Document to PDF with embedded Create PDF document from OpenOffice Presentation in both ODT, ODS, ODP forms to fillable PDF formats in
www.rasteredge.com
110
Producing Mathematical Graphics
5.2.5 Text and Formulas
\setlength{\unitlength}{0.8cm}
\begin{picture}(6,5)
\thicklines
\put(1,0.5){\line(2,1){3}}
\put(4,2){\line(-2,1){2}}
\put(2,3){\line(-2,-5){1}}
\put(0.7,0.3){$A$}
\put(4.05,1.9){$B$}
\put(1.7,2.95){$C$}
\put(3.1,2.5){$a$}
\put(1.3,1.7){$b$}
\put(2.5,1.05){$c$}
\put(0.3,4){$F=
\sqrt{s(s-a)(s-b)(s-c)}$}
\put(3.5,0.4){$\displaystyle
s:=\frac{a+b+c}{2}$}
\end{picture}
H
H
H
H
H
A
B
C
a
b
c
F=
s(s−a)(s−b)(s− c)
s:=
a+b +c
2
As this example shows, text and formulas can be written into apicture
environment with the \put command in the usual way.
5.2.6 \multiput and \linethickness
\setlength{\unitlength}{2mm}
\begin{picture}(30,20)
\linethickness{0.075mm}
\multiput(0,0)(1,0){26}%
{\line(0,1){20}}
\multiput(0,0)(0,1){21}%
{\line(1,0){25}}
\linethickness{0.15mm}
\multiput(0,0)(5,0){6}%
{\line(0,1){20}}
\multiput(0,0)(0,5){5}%
{\line(1,0){25}}
\linethickness{0.3mm}
\multiput(5,0)(10,0){2}%
{\line(0,1){20}}
\multiput(0,5)(0,10){2}%
{\line(1,0){25}}
\end{picture}
The command
\multiput(x,y)(∆x,∆y){n}{object}
has 4 arguments: the starting point, the translation vector from one object
control software system:C# PDF Field Edit Library: insert, delete, update pdf form field
A professional PDF form creator supports to create fillable PDF form in C#.NET. An advanced PDF form maker allows users to create editable PDF form in C#.NET.
www.rasteredge.com
control software system:C# Create PDF from Excel Library to convert xlsx, xls to PDF in C#
Create fillable and editable PDF documents from Excel in both .NET WinForms and ASP.NET. Create searchable and scanned PDF files from Excel. Convert to PDF with
www.rasteredge.com
5.2 The picture Environment
111
to the next, the number of objects, and the object to be drawn. The
\linethicknesscommandappliestohorizontalandverticallinesegments,
but neither to oblique line segments, nor to circles. It does, however, apply
to quadratic Bézier curves!
5.2.7 Ovals
\setlength{\unitlength}{0.75cm}
\begin{picture}(6,4)
\linethickness{0.075mm}
\multiput(0,0)(1,0){7}%
{\line(0,1){4}}
\multiput(0,0)(0,1){5}%
{\line(1,0){6}}
\thicklines
\put(2,3){\oval(3,1.8)}
\thinlines
\put(3,2){\oval(3,1.8)}
\thicklines
\put(2,1){\oval(3,1.8)[tl]}
\put(4,1){\oval(3,1.8)[b]}
\put(4,3){\oval(3,1.8)[r]}
\put(3,1.5){\oval(1.8,0.4)}
\end{picture}
#
"
!
#
"
!
#
"
!
!
The command
\put(x,y){\oval(w,h)}
or
\put(x,y){\oval(w,h)[position]}
produces an oval centered at (x,y) and having widthw and heighth. The
optional position argumentsb,t,l,r refer to “top”, “bottom”, “left”, “right”,
and can be combined, as the example illustrates.
Line thickness can be controlled by two kinds of commands:
\linethickness{length }ontheonehand,\thinlinesand \thicklines
on the other. While\linethickness{length} applies only to horizontal and
vertical lines (and quadratic Bézier curves),\thinlines and\thicklines
apply to oblique line segments as well as to circles and ovals.
control software system:C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF
Convert multiple pages PowerPoint to fillable and editable PDF documents. Easy to create searchable and scanned PDF files from PowerPoint.
www.rasteredge.com
control software system:C# Create PDF from Word Library to convert docx, doc to PDF in C#.
Convert multiple pages Word to fillable and editable PDF documents in both .NET WinForms and ASP.NET. Convert both DOC and DOCX formats to PDF files.
www.rasteredge.com
112
Producing Mathematical Graphics
5.2.8 Multiple Use of Predefined Picture Boxes
\setlength{\unitlength}{0.5mm}
\begin{picture}(120,168)
\newsavebox{\foldera}
\savebox{\foldera}
(40,32)[bl]{% definition
\multiput(0,0)(0,28){2}
{\line(1,0){40}}
\multiput(0,0)(40,0){2}
{\line(0,1){28}}
\put(1,28){\oval(2,2)[tl]}
\put(1,29){\line(1,0){5}}
\put(9,29){\oval(6,6)[tl]}
\put(9,32){\line(1,0){8}}
\put(17,29){\oval(6,6)[tr]}
\put(20,29){\line(1,0){19}}
\put(39,28){\oval(2,2)[tr]}
}
\newsavebox{\folderb}
\savebox{\folderb}
(40,32)[l]{%
definition
\put(0,14){\line(1,0){8}}
\put(8,0){\usebox{\foldera}}
}
\put(34,26){\line(0,1){102}}
\put(14,128){\usebox{\foldera}}
\multiput(34,86)(0,-37){3}
{\usebox{\folderb}}
\end{picture}
Apicture box can be declared by the command
\newsavebox{name}
then defined by
\savebox{name}(width,height)[position]{content}
and finally arbitrarily often be drawn by
\put(x,y){\usebox{name}}
The optional position parameter has the effect of defining the ‘anchor
point’ of the savebox. In the example it is set tobl which puts the anchor
point into the bottom left corner of the savebox. The other position specifiers
are top and right.
control software system:C# Create PDF Library SDK to convert PDF from other file formats
Create writable PDF from text (.txt) file. HTML webpage to interactive PDF file creator freeware. Create fillable PDF document with fields.
www.rasteredge.com
control software system:VB.NET Create PDF Library SDK to convert PDF from other file
Best VB.NET component to convert Microsoft Office Word Create and save editable PDF with a blank page Create fillable PDF document with fields in Visual Basic
www.rasteredge.com
5.2 The picture Environment
113
The name argument refers to a L
A
T
E
Xstorage bin and therefore is of a
command nature (which accounts for the backslashes in the current example).
Boxed pictures can be nested: In this example,\foldera is used within the
definition of \folderb.
The\oval command had to be used as the\line command does not
work if the segment length is less than about 3mm.
5.2.9 Quadratic Bézier Curves
\setlength{\unitlength}{0.8cm}
\begin{picture}(6,4)
\linethickness{0.075mm}
\multiput(0,0)(1,0){7}
{\line(0,1){4}}
\multiput(0,0)(0,1){5}
{\line(1,0){6}}
\thicklines
\put(0.5,0.5){\line(1,5){0.5}}
\put(1,3){\line(4,1){2}}
\qbezier(0.5,0.5)(1,3)(3,3.5)
\thinlines
\put(2.5,2){\line(2,-1){3}}
\put(5.5,0.5){\line(-1,5){0.5}}
\linethickness{1mm}
\qbezier(2.5,2)(5.5,0.5)(5,3)
\thinlines
\qbezier(4,2)(4,3)(3,3)
\qbezier(3,3)(2,3)(2,2)
\qbezier(2,2)(2,1)(3,1)
\qbezier(3,1)(4,1)(4,2)
\end{picture}
H
H
H
H
H
H
HD
D
D
D
D
D
As this example illustrates, splitting up a circle into 4 quadratic Bézier
curves is not satisfactory. At least 8 are needed. The figure again shows the
effect of the\linethickness command on horizontal or vertical lines, and of
the\thinlines and the\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.
LetP
1
=(x
1
,y
1
),P
2
=(x
2
,y
2
)denote the end points, andm
1
,m
2
the
respective slopes, of a quadratic Bézier curve. The intermediate control point
S= (x, y) is then given by the equations
rclx =
m
2
x
2
−m
1
x
1
−(y
2
−y
1
)
m
2
−m
1
,
y= y
i
+m
i
(x− x
i
)
(i = 1, 2).
(5.1)
See Graphics inLAT
E
X2
ε
[17] for a Java program which generates the neces-
sary \qbezier command line.
114
Producing Mathematical Graphics
5.2.10 Catenary
\setlength{\unitlength}{1cm}
\begin{picture}(4.3,3.6)(-2.5,-0.25)
\put(-2,0){\vector(1,0){4.4}}
\put(2.45,-.05){$x$}
\put(0,0){\vector(0,1){3.2}}
\put(0,3.35){\makebox(0,0){$y$}}
\qbezier(0.0,0.0)(1.2384,0.0)
(2.0,2.7622)
\qbezier(0.0,0.0)(-1.2384,0.0)
(-2.0,2.7622)
\linethickness{.075mm}
\multiput(-2,0)(1,0){5}
{\line(0,1){3}}
\multiput(-2,0)(0,1){4}
{\line(1,0){4}}
\linethickness{.2mm}
\put( .3,.12763){\line(1,0){.4}}
\put(.5,-.07237){\line(0,1){.4}}
\put(-.7,.12763){\line(1,0){.4}}
\put(-.5,-.07237){\line(0,1){.4}}
\put(.8,.54308){\line(1,0){.4}}
\put(1,.34308){\line(0,1){.4}}
\put(-1.2,.54308){\line(1,0){.4}}
\put(-1,.34308){\line(0,1){.4}}
\put(1.3,1.35241){\line(1,0){.4}}
\put(1.5,1.15241){\line(0,1){.4}}
\put(-1.7,1.35241){\line(1,0){.4}}
\put(-1.5,1.15241){\line(0,1){.4}}
\put(-2.5,-0.25){\circle*{0.2}}
\end{picture}
-
x
6
y
u
In this figure, each symmetric half of the catenaryy = coshx− 1 is
approximated by a quadratic Bézier curve. The right half of the curve ends
in the point (2, 2.7622), the slope there having the valuem = 3.6269. Using
again equation (5.1), we can calculate the intermediate control points. They
turn out to be (1.2384, 0) and (1.2384, 0). The crosses indicate points of
the real catenary. The error is barely noticeable, being less than one percent.
This example points out the use of the optional argument of the
\begin{picture}command. Thepictureisdefinedinconvenient“mathe-
matical” coordinates, whereas by the command
\begin{picture}(4.3,3.6)(-2.5,-0.25)
its lower left corner (marked by the black disk) is assigned the coordinates
(−2.5,−0.25).
5.3 The PGF and TikZ Graphics Packages
115
5.2.11 Rapidity in the Special Theory of Relativity
\setlength{\unitlength}{0.8cm}
\begin{picture}(6,4)(-3,-2)
\put(-2.5,0){\vector(1,0){5}}
\put(2.7,-0.1){$\chi$}
\put(0,-1.5){\vector(0,1){3}}
\multiput(-2.5,1)(0.4,0){13}
{\line(1,0){0.2}}
\multiput(-2.5,-1)(0.4,0){13}
{\line(1,0){0.2}}
\put(0.2,1.4)
{$\beta=v/c=\tanh\chi$}
\qbezier(0,0)(0.8853,0.8853)
(2,0.9640)
\qbezier(0,0)(-0.8853,-0.8853)
(-2,-0.9640)
\put(-3,-2){\circle*{0.2}}
\end{picture}
-
χ
6
β= v/c = tanhχ
t
The control points of the two Bézier curves were calculated with formulas
(5.1). The positive branch is determined byP
1
=(0, 0),m
1
=1 andP
2
=
(2,tanh 2),m
2
=1/cosh
2
2. Again, the picture is defined in mathematically
convenient coordinates, and the lower left corner is assigned the mathematical
coordinates (−3,−2) (black disk).
5.3 The PGF and TikZ Graphics Packages
Today every LAT
E
Xoutput generation system can create nice vector graphics,
it’s just the interfaces that are rather diverse. The pgf package provides an
abstraction layer over these interface. The pgf package comes with a large
manual/tutorial of its own [18]. So we are only going to scratch the surface
of the package with this little section.
The pgf package comes with a high level access language provided by the
tikz package. TikZ provides highly efficient commands to draw graphics right
from inside your document. Use thetikzpicture environment to wrap your
TikZ commands.
As mentioned above, there is an excellent manual for pgf and friends.
So instead of actually explaining how it works, I will just show you a few
examples so that you can get a first impression of how this tool works.
First a simple nonsense diagram.
116
Producing Mathematical Graphics
\begin{tikzpicture}[scale=3]
\clip (-0.1,-0.2)
rectangle (1.8,1.2);
\draw[step=.25cm,gray,very thin]
(-1.4,-1.4) grid (3.4,3.4);
\draw (-1.5,0) -- (2.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\filldraw[fill=green!20!white,
draw=green!50!black]
(0,0) -- (3mm,0mm)
arc (0:30:3mm) -- cycle;
\end{tikzpicture}
Note the semicolon (;) character. It separates the individual commands.
Asimple Venn diagram.
\shorthandoff{:}
\begin{tikzpicture}
\node[circle,draw,
minimum size=3cm,
label=120:{economics}]
at (0,0) {};
\node[circle,draw,
minimum size=3cm,
label=60:{psychology}]
at (1,0) {};
\node (i) at (0.5,-1) {};
\node at (0.6,-2.5)
{behavioral economics}
edge[->,thick,
out=60,in=-60] (i);
\end{tikzpicture}
economics
psychology
behavioral economics
If you are using tikz in connection with babel some of the characters used
in the TikZ language may get modified by babel, leading to odd errors. To
counteract this, add the \shorthandoff command to your code.
Note the foreach loops in the next example.
Documents you may be interested
Documents you may be interested