Ps Tricks PPT
Ps Tricks PPT
Ps Tricks PPT
Sandeep Kumar
August 2, 2017
Introduction: PsTricks
Introduction: PsTricks
Introduction: PsTricks
Program to Compile
Program to Compile
A Simple Example
\ d o c u m e n t c l a s s [ 1 1 p t ] { book }
\ usepackage { p s t r i c k s }
\ b e g i n { document }
\ end { document }
The command
‘\begin{pspicture}(m0,n0)(m1, n1)’
sets aside space in coordinate system with lower-left corner (m0, n0) (by
default (0, 0)) and upper-right corner (m1, n1).
Grid
Grid
PSTricks provides the macro ‘psgrid’ to generate a grid. The general syntax is:
where (x1, y1), (x2, y2) are the coordinates of opposite corners of the grid. The horizontal labels
are positioned at the positions (x0, ∗) and vertical labels at the positions (∗, y 0). If (x0, y 0) is
not specified then (x1, y 1) is used for labeling purpose.
3
2
\ begin { p s p i c t u r e }(0 , 0)(3 ,3)
\ psgrid (0 ,0)(3 ,3)
\ end { p s p i c t u r e } 1
0
0 1 2 3
Grid
One can also customize a grid using different parameters and their possible values, which are
given in the following table:
Dots
Dots
PSTricks provides the macro \psdot to draw dots of different types. The general syntax for this
command is:
where par1, par2,..., par3 and val1, val2, ..., val3 specify parameter names and their
corresponding values. The pairs (x1, y1)(x2, y2) ... (x3, y3) specifies the coordinates where the
dots are to be drawn.
Different parameters and their possible values are given in the following table:
Plotting Dots
\ p s s e t { x u n i t =0.7cm , y u n i t =0.7cm} 3 u u
\ p s g r i d [ s u b g r i d d i v =1 , g r i d d o t s = 4 ] ( 0 , 0 ) ( 3 , 3 )
\ p s d o t s [ d o t s t y l e =+](1 , 1 ) ( 2 , 1 ) ( 3 , 1 ) 2 ut ut ut
\ p s d o t s [ d o t s t y l e= t r i a n g l e ] ( 1 , 2 ) ( 2 , 2 ) ( 3 , 2 )
\ p s d o t s [ d o t s t y l e= t r i a n g l e ∗ ] ( 1 , 3 ) ( 2 , 3 ) 1
\ end { p s p i c t u r e } + + +
0
0 1 2 3
PSTricks provides the macro ‘psline’ to draw a line. The general syntax is:
where par1, par2,..., par3 and val1, val2, ..., val3 specify parameter names and their
corresponding values. The argument arrows specifies the type of arrows. (x1, y1), (x2, y2) are
the starting and ending points of the line.
To draw a collection of line segments, connected end to end, use the following command:
where {(x1, y1), (x2, y2)}, {(x2, y2), (x3, y3)}, ... , {(x(n-1), y(n-1)), (xn, yn)} are the end
points of the line segments.
Drawing Line
3
\ begin { p sp i c t u re }(4 ,4)
\ p s g r i d [ s u b g r i d d i v =1 , g r i d d o t s = 4 ] ( 0 , 0 ) ( 4 , 4 )
\ p s l i n e (0 , 0 ) ( 2 , 1) 2
\ p s l i n e [ l i n e w i d t h =1p t ]{<−>}(0, 2 ) ( 3 , 2 )
\ p s l i n e [ l i n e w i d t h =2p t ]{<−>}(2, 0 ) ( 4 , 2 )
(2 , 4 ) ( 0 , 3) 1
\ end { p s p i c t u r e }
0
0 1 2 3 4
Circle
PSTricks provides the macros ‘pscircle’ and ‘pscircle*’ to draw a hollow circle and a filled
circle respectively. The general syntax is:
The above command draws a circle of radius r with center (x, y ). The possible parameters and
their values are same, as those of \psline.
4
3
\ begin { p sp i c t u re }(4 ,4)
\ p s g r i d [ s u b g r i d d i v =1 , g r i d d o t s = 4 ] ( 0 , 0 ) ( 4 , 4 ) 2
\ p s c i r c l e [ l i n e c o l o r =g r e e n ] ( 2 , 2 ){ 2 }
\ p s c i r c l e ∗ [ l i n e w i d t h =1p t ] ( 2 , 2 ) { 1 }
\ end { p s p i c t u r e } 1
0
0 1 2 3 4
Sandeep Kumar (SBSC, DU) PsTricks August 2, 2017 12 / 23
Graphic Objects
Ellipse
PSTricks provides the macros ‘psellipse’ and ‘psellipse*’ to draw a hollow ellipse and a
filled ellipse respectively. The general syntax for this macro is:
The above command draws an ellipse with r 1 and r 2 as horizontal and vertical radii respectively
and center (x, y ). The possible parameters and their values are same, as those of \psline.
3
2
\ begin { p sp i c t u re }(3 ,3)
\ p s g r i d [ s u b g r i d d i v =1 , g r i d d o t s = 4 ] ( 0 , 0 ) ( 3 , 3 )
\ p s e l l i p s e [ l i n e w i d t h =1p t ] ( 1 . 5 , 1 . 5 ) ( 1 . 5 , 1 ) 1
\ end { p s p i c t u r e }
0
0 1 2 3
PSTricks provides the macros ‘put’ and ‘rput’ to put a label at a specified location. The
general syntax is:
\put(x, y){text}
\rput{A}(x, y){text}
where (x, y) is the point where the label ‘text’ is to be putted. In ‘rput’ macro, A specifies the
angle at which the label is to be rotated.
(3, 3)
3
2)
\ p s g r i d [ s u b g r i d d i v =1 , g r i d d o t s = 4 ] ( 0 , 0 ) ( 3 , 3 )
(2,
\ r p u t { 3 0 } ( 1 , 1 ) { ( 1 , 1 )}
\ r p u t { 6 0 } ( 2 , 2 ) { ( 2 , 2 )} 1
\ r p u t { 9 0 } ( 3 , 3 ) { ( 3 , 3 )} 1)
(1,
\ end { p s p i c t u r e }
0
0 1 2 3
Co-ordinate Axes
PSTricks provides the macro ‘psaxes’ to draw the coordinate axes. The general syntax is:
where the co-ordinates (x, y), (x1, y1), (x2, y2) define the intersection point of axes, lower-left
corner and upper-right corner, respectively, of the co-ordinate system. The possible arrows type,
parameters and their values are same, as those of \psline.
y
2
\ begi n { p s p i c t u r e }( −1.5 , − 1 . 5 ) ( 2 . 5 , 2 . 5 )
1
\ p s a x e s [ l i n e c o l o r =g r a y , l i n e w i d t h =0.5 p t ]{ −}
( 0 , 0)( −1 , −1)(2 , 2 )
\ put ( 2 . 3 , −0.1){ $x$ }
x
\ put ( − 0 . 1 , 2 . 3 ) { $y$ }
\ end { p s p i c t u r e } −1 1 2
−1
PSTricks provides the macro ‘psplot’ to plot functions. Before using this function, include the
package ‘pst-plot’ in the preamble of the document. The general syntax is:
where x_min and x_max specify the domain of the function. The parameters and their values are
same as those of macro \psline.
‘yMinValue’ and ‘yMaxValue’ that restrict the graph of the given function between these two
values.
myFunction is the function that is to be plotted, which needs to be in postfix form, which is a
bit inconvenient to use.
By setting the property ‘algebraic=true’, we can avoid the postfix notation and can work with
standard notations.
Plotting Functions
5
\ begi n { p s p i c t u r e }( −3.5 , − 1 . 5 ) ( 3 . 5 , 5 . 5 ) 4
\ p s a x e s {−>}(0, 0 ) ( − 3 . 5 , − 1 . 5 ) ( 3 . 5 , 5 . 5 )
x2
3
\ p s p l o t [ a l g e b r a i c =t r u e ]{ −3}{3}{ x+2}
2
+
\ p s p l o t [ a l g e b r a i c =t r u e , yMaxValue =5]{ −3}{3}{ x ˆ2} 2
x
\ r p u t { 4 5 } ( 1 , 2 . 3 ) { $x+2$ }
1
\ r p u t {90}( −2 , 3 ){ $x ˆ2 $ }
\ end { p s p i c t u r e }
−3 −2 −1
−1 1 2 3
Mathematical Functions
PSTricks also provides standard mathematical functions. A list of all these functions is given in
the below table:
2
Sin(
x )
1
x)
s(
Co
−4 −3 −2 −1 1 2 3 4
−1
−2
|x| 2
−3 −2 −1 1 2 3
−1
[x]
−2
−3
(f ′ (c) = 0)
\begin{pspicture}(-4,-1)(1,4)
\psplot[algebraic=true]{-2}{0}{x^3 -4*x}
\psline(-3,3.08)(1,3.08)
\put(-2.5, -0.5){$(a, f(a))$}
\put(-0.5, -0.5){$(b, f(b))$}
\put(-1.75, 3.5){$(f’(c) = 0)$} f (a) = f (b)
\put(-4,1){$f(a) = f(b)$}
\end{pspicture}
Exercises:
Thank You