Custom Graphics

Boxing Text Clipping Rotating and scaling Text along a path Text as graphic

Online LATEX Tutorial Part II – Graphics GraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphicsGraphics PSTricks andandandandandandandandandandandandandandandandandandandandandandandandandandandandandand XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments TTTTTTTTTTTTTTTTTTETETETETETETETETETETETETEEEEEEEEEEEEEEEEEE and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       1/23 Boxing Text Clipping Rotating and scaling Text along a path Text as graphic 9. Tricks with Text

In our discussions so far, we’ve been focusing on graphic objects and we’ve treated text only incidentally in Chapter 6, as labels in pictures. We now see Online LATEX Tutorial how text can be manipulated in various ways using PSTricks. Part II – Graphics PSTricks

E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       2/23 Custom Graphics 9.1. Boxing Text Boxing Text Clipping LATEX has various macros for putting text in boxes (or putting boxes around Rotating and scaling text) and PSTricks defines its own boxing macros. The advantage of using Text along a path these is the ease of adorning these boxes using colors, shadows and so on. Text as graphic The simplest of such commands is the \psframebox as in the example below: \psframebox[fillstyle=solid,% fillcolor=Cyan,% linecolor=RoyalBlue]% {\color{Red} \LARGE\bfseries Text In A Box A Text In A Box} Online LTEX Tutorial Part II – Graphics The distance between the sides of the box and the enclosed text is controlled by the framesep parameter. By default, its value is 3 point, but as with other PSTricks parameters, can be set to any desired value, as shown in the next example: \psframebox[framesep=10pt,% fillstyle=solid,% fillcolor=Cyan,% linecolor=RoyalBlue]% {\color{Red} Text In A Box E Krishnan, CV Radhakrishnan and AJ Alex \LARGE\bfseries constitute the graphics tutorial team. Comments Text In A Box} and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E \psframebox \psdblframebox This document is generated by pdfTEX with A variant of the is the which, as the name hyperref, pstricks, pdftricks and pdfscreen indicates, doubles each line of the frame packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       3/23 Custom Graphics \psdblframebox[framesep=10pt,% Boxing Text fillstyle=solid,% fillcolor=Cyan,% Clipping linecolor=RoyalBlue,% Rotating and scaling doublecolor=Apricot,% Text along a path doublesep=3pt]% Text In A Box Text as graphic {\color{Red} \LARGE\bfseries Text In A Box}

Recall that the doublesep parameter determines the width of the space be- tween the double lines and the doublesep the color of this space, as men- Online LAT X Tutorial tioned in Chapter 3. The default value of doublesep for the \psdblframebox E is \pslinewidth and the default value of doublecolor is white. Part II – Graphics Another variant is the \psshadowbox which, obviously enough, draws a (single) frame with a shadow, as shown below: PSTricks

\psshadowbox[framesep=10pt,% fillstyle=solid,% fillcolor=Cyan,% linecolor=RoyalBlue,% shadowcolor=Blue,% shadowsize=5pt]% Text In A Shadow Box E Krishnan, CV Radhakrishnan and AJ Alex {\color{Red} constitute the graphics tutorial team. Comments \LARGE\bfseries and suggestions may be mailed to Text In A Shadow Box} [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with Note that the parameters shadowsize and shadowcolor are discussed in hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux Chapter 3. and is released under lppl If you are tired of plain old rectangular boxes, you can try \psdiabox, The Indian TEX Users Group which draws a diamond shaped box: Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       4/23 Custom Graphics

\psdiabox[fillstyle=solid,% Boxing Text fillcolor=Apricot,% Clipping linecolor=Mahogany]% Rotating and scaling {\color{Brown} \large\bfseries Text along a path \renewcommand{% Text Text as graphic \arraystretch}{1.2} In A Diamond \begin{tabular}{c} Text\\ Box In A Diamond\\ Box \end{tabular}} Online LATEX Tutorial or \pstribox, which draws a triangular box: \pstribox[fillstyle=gradient,% Part II – Graphics gradbegin=CornflowerBlue,% gradend=Apricot,% PSTricks gradmidpoint=1,% linecolor=Cyan]% {\color{Red} \large\bfseries \renewcommand{% \arraystretch}{1.2} \begin{tabular}{% Text E Krishnan, CV Radhakrishnan and AJ Alex @{\hspace{-15pt}}c@{\hspace{-15pt}}} In A constitute the graphics tutorial team. Comments Text\\ Triangle Box and suggestions may be mailed to In A\\ [email protected] Triangle Box c 2004, The Indian TEX Users Group \end{tabular}} This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux Recall that the gradient style of filling requires the pst-grad package, as and is released under lppl explained in Chapter 2. The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills For those who are inclined towards curves than angles, there’s a Trivandrum 695014, india \pscirclebox: http://www.tug.org.in       5/23 Custom Graphics

\pscirclebox[fillstyle=solid,% Boxing Text fillcolor=SpringGreen,% Clipping linecolor=Green]% Rotating and scaling {\color{Orange} \large\bfseries Text along a path \renewcommand{% Text Text as graphic \arraystretch}{1.2} In A \begin{tabular}{c} Text\\ Circle In A\\ Box Circle\\ Box \end{tabular}} Online LATEX Tutorial or even a \psovalbox: Part II – Graphics \psovalbox[fillstyle=solid,% fillcolor=Orange,% PSTricks linecolor=BrickRed]% {\color{SpringGreen} \large\bfseries \renewcommand{% Text \arraystretch}{1.2} In An \begin{tabular}{c} Text\\ Oval E Krishnan, CV Radhakrishnan and AJ Alex In An\\ Box constitute the graphics tutorial team. Comments Oval\\ and suggestions may be mailed to Box [email protected] \end{tabular}} c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen Another parameter for the various boxes is the boxsep whose default value packages in an intel pc running gnu/linux lppl is true. In this case, the box that is produced (in the TEXnical sense) is the size and is released under of the “frame” around it. If it is set to false, then the box produced is the size The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills of what’s inside, so that the frame is transparent to TEX. This is apparent only Trivandrum 695014, india when the boxes are used within some surrounding text as illustrated below: http://www.tug.org.in       6/23 Custom Graphics

\color{Blue} Boxing Text Thus we find that $x+y=3$ and Clipping using this together with Rotating and scaling \psovalbox[linecolor=Red]% Text along a path {$xˆ2+yˆ2=3$} Thus we £nd that x + y = 3 found earlier, we see that and using this together with Text as graphic $x=2$ and $y=1$ x2 + y2 = 3 found earlier, \vspace{1cm} we see that x = 2 and y = 1

Thus we find that $x+y=3$ and using this together with Thus we £nd that x + y = 3 \psovalbox[linecolor=Red,% and using this together with x2 + y2 = 3 found earlier, we see boxsep=false]% A that x = 2 and y = 1 Online LT X Tutorial {$xˆ2+yˆ2=3$} E found earlier, we see that $x=2$ and $y=1$ Part II – Graphics PSTricks Each of the boxing commands above has a starred version, which draws a solid shape around the enclosed text instead of just a frame. This is similar to the starred versions of graphic objects we’ve seen earlier, but the color of the boxes is determined by fillcolor instead of linecolor for other graphic objects. E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       7/23 Custom Graphics

\SaveVerb{box}=\psframebox= Boxing Text \psframebox[fillstyle=solid,% Clipping fillcolor=Cyan]% Rotating and scaling {\color{Red} Text along a path \LARGE\bfseries Text as graphic Text In A \UseVerb{box}} \psframebox \vspace{1cm} Text In A

\SaveVerb{starbox}=\psframebox*= Text In A \psframebox* \psframebox*[fillstyle=solid,% fillcolor=Cyan]% {\color{Red} Online LATEX Tutorial \LARGE\bfseries Text In A \UseVerb{starbox}} Part II – Graphics PSTricks (Here, the command pair \SaveVerb and \UseVerb come from the package fancyvrb and are used to get the control sequence strings \psframebox and \psframebox* as arguments of the commands.) We’ve mentioned in Chapter 6 that the \rput* command puts the text first in a \psframebox*. But there are occasions when we’ve to use both \rput and \psframebox together instead of a single \rput*, as in the example below: E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       8/23 Custom Graphics \psset{linecolor=Blue} Boxing Text \begin{pspicture}(0,0)(4,5) \pspolygon[fillstyle=solid,% Clipping fillcolor=Cyan]% Rotating and scaling (0,0)(4,0)(2,4) Text along a path \psline(2,0)(2,4) Text as graphic \psset{linecolor=Mahogany,% linestyle=dotted,% dotsep=1pt,% arrows=<->} h \psline(2.3,0)(2.3,4) \rput(2.3,2){% \psframebox*[boxsep=false,% fillcolor=Cyan]% A {\color{Red} $h$}} r Online LTEX Tutorial \psline(0,-0.3)(2,-0.3) \rput*(1,-0.3){\color{Red} $r$} Part II – Graphics \end{pspicture} PSTricks

Note that here, we cannot use \rput* directly for the label h, since the default color of \psframebox* is white, (which is OK for the label r) but we want the color of the box for h to be cyan, to blend it with its background. While on the topic of “putting”, we should also mention the command \cput \cput* \pscirclebox E Krishnan, CV Radhakrishnan and AJ Alex (and of course ) which combines the functions of constitute the graphics tutorial team. Comments and \rput (or \rput*), as shown in the next example: and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       9/23 Custom Graphics \Large Boxing Text \psset{fillstyle=solid,unit=2cm} \begin{pspicture}(0,-1)(1,1) Clipping \SpecialCoor Rotating and scaling \pspolygon[linecolor=Cyan]% Text along a path (0,1)(1;210)(1;330) Text as graphic \cput*[fillcolor=Red]% A (0,1) {\color{White} $A$} \cput*[fillcolor=Green]% (1;210) {\color{White} $B$} \cput*[fillcolor=Blue]% B C (1;330) A {\color{White} $C$} Online LTEX Tutorial \end{pspicture} Part II – Graphics PSTricks

E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       10/23 Custom Graphics 9.2. Clipping Boxing Text Clipping We can clip text, that is, cut off everything outside a specified boundary, using Rotating and scaling the \psclip....\endpsclip commands. A simple example is given below: Text along a path Text as graphic \psclip{% \psdiamond[linecolor=Red,% fillstyle=solid,% fillcolor=Yellow]% (2,0.25)(2.5,0.5)} Cut Diamond \color{Blue}\Huge Cut Diamond \endpsclip Online LATEX Tutorial By careful use of coordinates, we can create an overlay effect with suitable Part II – Graphics clipping, as in the next example: \begin{pspicture}(0,0)(6,2) PSTricks \rput[bl](0.5,1){% \color{Blue}\Huge Cut Diamond} \psclip{\psdiamond*[linecolor=Yellow]% (3,1.25)(2.25,0.5)} \rput[bl](0.5,1){% \color{OliveGreen}\Huge Cut Diamond} Cut Diamond \endpsclip E Krishnan, CV Radhakrishnan and AJ Alex \end{pspicture} constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group Or special effects like this: E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       11/23 Custom Graphics \begin{pspicture}(0,0)(2.5,2) Boxing Text \rput{2}{% \psclip{\pscustom[style=bluestyle]{% Clipping \psline(1.6,1.4)(0,1.4)(0,0)(1,0) Rotating and scaling \tearcurve}} Text along a path \rput[bl](0,0){\color{Red}\Large\bfseries Text as graphic \begin{tabular}{c} Text In A\\ Torn Box \end{tabular}} \endpsclip} \end{pspicture} \hspace{-2.6cm} TTextextIn A \begin{pspicture}(0,0)(2.5,2) In A A \rput{-2}{% TTornornBoxBox Online LTEX Tutorial \psclip{\pscustom[style=bluestyle]{% \tearcurve Part II – Graphics \psline(1.6,1.4)(3,1.4)(3,0)(1,0)}} \rput[bl](0,0){\color{Red}\Large\bfseries PSTricks \begin{tabular}{c} Text In A\\ Torn Box \end{tabular}} \endpsclip} \end{pspicture} E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments bluestyle \tearcurve and suggestions may be mailed to Here, the custom style and the custom curve are [email protected] defined as follows: c 2004, The Indian TEX Users Group \newpsstyle{bluestyle}{% This document is generated by pdfTEX with linecolor=Blue,% hyperref, pstricks, pdftricks and pdfscreen fillstyle=solid,% packages in an intel pc running gnu/linux fillcolor=Cyan} and is released under lppl \newcommand{\tearcurve}{% \pscurve(1,0)(1.1,0.3)(1.2,1)(1.3,1)% The Indian TEX Users Group (1.4,1.2)(1.6,1.6)} Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       12/23 Custom Graphics

Incidentally,note that the \psclip...\endpsclip commands can be used Boxing Text to clip not only text, but graphic objects also, as shown in the example below: Clipping Rotating and scaling \psset{unit=0.66,linecolor=Red} \begin{pspicture}(0,-7)(6.5,2) Text along a path \coloraxes(0,0)(0,-2)(7,2) Text as graphic \plotsqsin \plotabssin \psclip{\ycirc(3.1416,0){0.5}} \coloraxes(0,0)(0,-2)(7,2) \plotsqsin \plotabssin \endpsclip \dotline(2.6416,0)(1.1416,-4) Online LAT X Tutorial \dotline(3.6416,0)(5.1416,-4) E \psclip{\ycirc(3.1416,-4){2}} \psset{origin={3.1416,4},unit=1.33cm} Part II – Graphics \coloraxes(0,0)(0,-2)(7,2) \plotsqsin PSTricks \plotabssin \endpsclip \end{pspicture} where the various customized commands used are as follows: E Krishnan, CV Radhakrishnan and AJ Alex \newcommand{\plotsqsin}{% constitute the graphics tutorial team. Comments \psplot[plotpoints=500,plotstyle=curve,linecolor=Blue]% and suggestions may be mailed to {0}{6.2832}{57.2958 x mul sin 2 exp}} [email protected] \newcommand{\plotabssin}{% c 2004, The Indian T X Users Group \psplot[plotpoints=500,plotstyle=curve,linecolor=Green]% E This document is generated by pdfT X with {0}{6.2832}{57.2958 x mul sin abs}} E hyperref, pstricks, pdftricks and pdfscreen \definecolor{PaleYellow}{cmyk}{0,0,0.2,0} packages in an intel pc running gnu/linux \newpsobject{ycirc}{pscircle}{fillstyle=solid,fillcolor=PaleYellow} and is released under lppl \newpsobject{dotline}{psline}{linestyle=dotted,dotsep=1pt} \newpsobject{coloraxes}{psaxes}% The Indian TEX Users Group {linestyle=solid,linecolor=Apricot,labels=none,ticks=none} Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       13/23 Custom Graphics 9.3. Rotating and scaling Boxing Text Clipping There are are also ready to use commands for rotating text left, right or down, Rotating and scaling leaving the needed amount of spaces. Text along a path Text as graphic go straight \rotateright{\color{Red} go down} go

\rotatedown{\color{Green} turn upside down} down

\rotateleft{\color{Blue} go up} up down upside turn

go straight again go straight go go straight again

A better effect can be obtained by computing the heights of various upright Online LATEX Tutorial boxes and raising and lowering them by the appropriate lengths: \newlength{\dlen} Part II – Graphics \settoheight{\dlen}{% \rotateright{\color{Red} go down}} PSTricks \newlength{\ulen} \settoheight{\ulen}{% \rotateleft{\color{Blue} go up}}

go straight go straight go

\raisebox{-\dlen}{% down go straight again

up

down upside \rotateright{\color{Red} go down} turn

\rotatedown{% go E Krishnan, CV Radhakrishnan and AJ Alex \color{Green} turn upside down} constitute the graphics tutorial team. Comments \rotateleft{\color{Blue} go up}} and suggestions may be mailed to [email protected] \raisebox{\ulen-\dlen}{% go straight again} c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux For such manipulation of long pieces of text, these commands also have and is released under lppl the “environmental” forms \begin{Rotateleft}...\end{Rotateleft} and The Indian TEX Users Group others. Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       14/23 Custom Graphics

\textbf{\color{Red} Question}: Boxing Text \color{Blue} Why did the tachyon Clipping cross the street?\\[10pt] Rotating and scaling \begin{Rotatedown}

Question: Why did the Text along a path

\parbox{\linewidth}{% tachyon cross the street?

side other the

\textbf{\coor{Red} Answer}: on Text as graphic

Answer eady alr it’s Because \color{Blue} Because it’s already : on the other side} \end{Rotatedown}

Text can also be scaled, using the command \scalebox. The general form of this command is Online LATEX Tutorial \scalebox{number1 number2}{text} Part II – Graphics where number1 is the horizontal scaling and number2 is the vertical scaling. If only one number is specified, it is used for scaling in both directions. This is PSTricks illustrated in the examples below: \scalebox{0.8 4}{% \color{Red}tall and lean}

\bigskip E Krishnan, CV Radhakrishnan and AJ Alex \scalebox{4 0.8}{% constitute the graphics tutorial team. Comments tall and lean and suggestions may be mailed to \color{Green}short and fat} [email protected] short and fat c 2004, The Indian T X Users Group \bigskip E large but proportional This document is generated by pdfTEX with \scalebox{2}{% hyperref, pstricks, pdftricks and pdfscreen \color{Blue}large but proportional} packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Using negative numbers for scaling, we can flip text around either axis: Trivandrum 695014, india http://www.tug.org.in       15/23 Custom Graphics

{\Large\bfseries\color{Red} MIRROR} Boxing Text {\color{Blue}\rule[-0.3cm]{0.1cm}{1cm}} Clipping {\Large\bfseries\color{Red} Rotating and scaling \scalebox{-1 1}{MIRROR}} MIRROR MIRROR Text along a path \vspace{1cm} Text as graphic

{\Large\bfseries\color{Red} MIRROR}\\ MIRROR

{\color{Blue}\rule{2.5cm}{0.1cm}}\\ {\Large\bfseries\color{Red} MIRROR \scalebox{1 -1}{MIRROR}}

A We also have the \scaleboxto command with the general form Online LTEX Tutorial \scaleboxto(number1,number2){text} Part II – Graphics With this command text is scaled to have width number1 units and height PSTricks plus depth equal to number2 units. If one of the numbers is set to 0, then the box s scaled to have width and height (plus depth) equal to the other number. (Of course, we cannot set both numbers equal to 0).

\scaleboxto(1.5,1){\color{Red} tall and lean} E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments \bigskip and suggestions may be mailed to [email protected] \scaleboxto(7,0.2){\color{Green} tall and lean c 2004, The Indian TEX Users Group short and fat} This document is generated by pdfT X with short and fat E hyperref, pstricks, pdftricks and pdfscreen \bigskip small but proportional packages in an intel pc running gnu/linux and is released under lppl \scaleboxto(3,0){\color{Blue} small but proportional} The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       16/23 Custom Graphics 9.4. Text along a path Boxing Text Clipping One of the interesting features of the PostScript language is that it treats text Rotating and scaling as graphical object. This allows various manipulations of text. The package Text along a path pst-text provides the command \pstextpath to set text along a specified path. Text as graphic Look at this example: \begin{pspicture}(0,0)(3,2) \pstextpath{% e w we have t x \psframe[framearc=0.3,linecolor=Blue](0,0)(3,1.4)}{% o t N

\color{Red}\Large Now we have text going around a box} g

o

o i a d n u o r a g \end{pspicture} b n Onlinex LATEX Tutorial Note that the general form of the command \pstextpath is Part II – Graphics \pstextpath{graphic}{text} PSTricks where, graphic specifies the path along which the specified text is to be set. By default, \pstextpath draws also the graphic specified, but this can be suppressed by setting linestyle=none, as shown below:

E Krishnan, CV Radhakrishnan and AJ Alex \begin{pspicture}(-3,-1)(3,5) constitute the graphics tutorial team. Comments tion and suggestions may be mailed to ua y \colaxes[labels=none](0,0)(-3,-1)(3,5) q = e 4 [email protected] e \pstextpath{% h − t x f 2 c 2004, The Indian T X Users Group \psplot[linestyle=none]{-2}{2}{4 x 2 exp sub}}{% o E f o h r This document is generated by pdfT X with \color{Red} This is the graph of the p E a − r 2 hyperref, pstricks, pdftricks and pdfscreen equation $y=4-xˆ2$ for g e ≤ packages in an intel pc running gnu/linux $-2\le x\le 2$} h x t s ≤ lppl \end{pspicture} i and is released under 2 s i

h T The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       17/23 Custom Graphics

(Note that \colaxes used in he above example is a custom command, dis- Boxing Text cussed in Chapter 7). Clipping What if we need something like this? Rotating and scaling Text along a path Text as graphic

uation eq y e = th 4 f o − x h 2 p f a o r r g − e 2 h t ≤ s i x A s Online LT X Tutorial i ≤ E h 2 T Part II – Graphics PSTricks The trick is to first draw the curve and then use \pstextpath to set the text along a slightly scaled up version of the curve, without actually drawing the second curve:

\begin{pspicture}(-3,-1)(3,5) y = E Krishnan, CV Radhakrishnan and AJ Alex \colaxes[labels=none](0,0)(-3,-1)(3,5) on 4 ti a − x constitute the graphics tutorial team. Comments \psset{linecolor=Blue} u 2 q f and suggestions may be mailed to \psplot{-2}{2}{4 x 2 exp sub} e o e r h [email protected] \psset{linestyle=none,unit=1.12cm} t − f 2 o ≤ c 2004, The Indian T X Users Group \pstextpath{% h x E p \psplot{-2}{2}{4 x 2 exp sub}}{% a ≤ This document is generated by pdfT X with r E g 2 hyperref, pstricks, pdftricks and pdfscreen \color{Red} This is the graph of the e h equation $y=4-xˆ2$ for t packages in an intel pc running gnu/linux s i $-2\le x\le 2$} s and is released under lppl i

h \end{pspicture} T The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       18/23 Custom Graphics

But this is not exactly what we want. The trouble is that the command Boxing Text \pstextpath, by default, places the beginning of the text at the beginning of Clipping the path; however, it has an optional parameter which can be used to shift Rotating and scaling the position of the text: Text along a path Text as graphic

\begin{pspicture}(-3,-1)(3,5) \colaxes[labels=none](0,0)(-3,-1)(3,5) uation \psset{linecolor=Blue} eq y e = h \psplot{-2}{2}{4 x 2 exp sub} t 4 f o − x \psset{linestyle=none,xunit=1.13cm,yunit=1.05cm} h 2 p f \pstextpath[c]{% a o r r g − \psplot{-2}{2}{4 x 2 exp sub}}{% e 2 A h Online LT X Tutorial t \color{Red} This is the graph of the ≤ E s i x

s equation $y=4-xˆ2$ for i ≤

h 2 $-2\le x\le 2$} T Part II – Graphics \end{pspicture} PSTricks

Note how we used the optional value c to center the text relative to the curve. (Note also the slight difference in xunit and yunit to get the text at the top just right). Other optional values are l (the default) for left justification and r for right justification. These are illustrated in the next example: E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       19/23 Custom Graphics \begin{pspicture}(-3,-1)(3,5) Boxing Text \colaxes[labels=none](0,0)(-3,-1)(3,5) \psset{linecolor=Blue} Clipping \psplot{-2.2}{2.2}{4 x 2 exp sub} Rotating and scaling rnin \psset{unit=1.15cm,linestyle=none} tu g Text along a path \pstextpath[l]{% Text as graphic \psplot{-2.1}{2.1}{4 x 2 exp sub}}{% \color{Red}\textit{increasing}} \pstextpath[r]{% \psplot{-2.1}{2.1}{4 x 2 exp sub}}{% \color{Red}\textit{decreasing}} d \psset{unit=1.07cm} g e c n i r s e a \pstextpath[c]{% a e s r i n \psplot{-2.1}{2.1}{4 x 2 exp sub}}{% c g n A \color{Red}\textit{turning}} i Online LTEX Tutorial \end{pspicture} Part II – Graphics PSTricks

E Krishnan, CV Radhakrishnan and AJ Alex constitute the graphics tutorial team. Comments and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       20/23 Custom Graphics 9.5. Text as graphic Boxing Text Clipping The package pst-char provides the command \pscharpath which can be used Rotating and scaling to embellish text with colors and the like just as it were a graphic object. We Text along a path give a couple of examples to illustrate this: Text as graphic \begin{pspicture}(0,-1)(8,2) \DeclareFixedFont{\bigrm}{T1}{ptm}{m}{n}{1.5cm} \pscharpath[fillstyle=solid,% fillcolor=SkyBlue,% linecolor=Red]% {\bigrm PSTricks} \end{pspicture} Online LATEX Tutorial Part II – Graphics Here, the command \DeclareFixedFont is the LATEX way of specifying the font to be used. PSTricks \begin{pspicture}(0,-1)(8,2) \DeclareFixedFont{\bigsf}{T1}{phv}{b}{n}{1.5cm} \pscharpath[linecolor=Yellow,% fillstyle=gradient,% gradbegin=Yellow,% gradend=Red,% gradmidpoint=1,% E Krishnan, CV Radhakrishnan and AJ Alex gradangle=5]% constitute the graphics tutorial team. Comments {\bigsf PSTricks} and suggestions may be mailed to [email protected] \end{pspicture} c 2004, The Indian T X Users Group E This document is generated by pdfTEX with \pscharclip...\endpscharclip hyperref, pstricks, pdftricks and pdfscreen This package also contains the command air , packages in an intel pc running gnu/linux which like \psclip...\endpsclip pair, clips any object within them,but this and is released under lppl time to the shape of the specified text: The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       21/23 Custom Graphics

\begin{pspicture}(-1.5,-1)(8,2) Boxing Text \DeclareFixedFont{\bigsf}{T1}{phv}{b}{n}{1.5cm} Clipping \DeclareFixedFont{\smallrm}{T1}{ptm}{m}{n}{2mm} Rotating and scaling \pscharclip[linestyle=none,%Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Text along a path fillstyle=solid,%Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Text as graphic fillcolor=Cyan]%Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript {\rput[bl](0,0){%Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \bigsf PSTricks}}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \rput[t]{90}(0,0){% Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \begin{minipage}{8cm}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \offinterlineskipPostcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \newcounter{pscount}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \setcounter{pscount}{500}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript A \whiledo{\value{pscount}>0}{%Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Online LT X Tutorial Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript E Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \addtocounter{pscount}{-1}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \color{Blue}\smallrmPostcript Postcript Postcript}Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Part II – Graphics \end{minipage}} Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \endpscharclip Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript \end{pspicture} Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript PSTricks Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript Postcript (Here, the text to bePostcript clippedPostcript Postcript isPostcript “PostScript”Postcript Postcript Postcript Postcript writtenPostcript Postcript 500 times, in small font, specified by \smallrm, which is generated by the code starting with \newcounter, put in a box 8 centimeters wide and turned through ninety E Krishnan, CV Radhakrishnan and AJ Alex degrees.). constitute the graphics tutorial team. Comments As in the case of \psclip this can also be used to produce an overlay effect. and suggestions may be mailed to [email protected] c 2004, The Indian T X Users Group E This document is generated by pdfTEX with hyperref, pstricks, pdftricks and pdfscreen packages in an intel pc running gnu/linux and is released under lppl The Indian TEX Users Group Floor iii, sjp Buildings, Cotton Hills Trivandrum 695014, india http://www.tug.org.in       22/23 Custom Graphics

\DeclareFixedFont{\bigsf}{T1}{phv}{b}{n}{1.75cm} Boxing Text \begin{pspicture}(0,-0.5)(8,3) Clipping \rput[bl](0,0){% Rotating and scaling \begin{minipage}{8cm} Text along a path \color{RoyalBlue} Text as graphic \firstpara \end{minipage}} \pscharclip[linestyle=none,% LATEX has only limited drawing capabilities, while PostScript is a page fillstyle=solid,% description language which has a rich set of drawing commands; and there are programs (such as dvips) which translate the dvi output to PostScript. fillcolor=CornflowerBlue]% So, the natural question is whether one can include PostScript code in a TEX source £le itself for programs such as dvips to process after the T EX {\rput[bl](0.25,0.15){% compilation? This is the idea behind the PSTricks package of Timothy van \bigsf PSTricks}} Zandt. The beauty of it is one need not know PostScript to use it—the necessary PostScript code can be generated by TEX macros de£ned in the \rput[bl](0,0){% package \begin{minipage}{8cm} Online LATEX Tutorial \color{Blue} \firstpara \end{minipage}} Part II – Graphics \endpscharclip \end{pspicture} PSTricks

Here, the command \firstpara is defined by \newcommand{\firstpara}{% \scriptsize \LaTeX\ has only limited drawing capabilities, while E Krishnan, CV Radhakrishnan and AJ Alex PostScript is a page description language which has a rich set of constitute the graphics tutorial team. Comments drawing commands; and there are programs (such as \textsf{dvips}) and suggestions may be mailed to which translate the \texttt{dvi} output to PostScript. So, the [email protected] natural question is whether one can include PostScript code in a c \TeX\ source file itself for programs such as \textsf{dvips} to 2004, The Indian TEX Users Group process after the \TeX\ compilation? This is the idea behind the This document is generated by TEX with \textsf{PSTricks} package of Timothy van Zandt. The beauty of it is hyperref, pstricks, pdftricks and pdfscreen pc gnu/linux one need not know PostScript to use it---the necessary PostScript packages in an intel running lppl code can be generated by \TeX\ macros defined in the package} and is released under The Indian TEX Users Group \tiny Floor iii, sjp Buildings, Cotton Hills just typesets the opening paragraph of our tutorial in font in an Trivandrum 695014, india 8 centimeter wide box. http://www.tug.org.in       23/23