PSTricks

Last updated

PSTricks is a set of macros that allow the inclusion of PostScript drawings directly inside TeX or LaTeX code. It was originally written by Timothy Van Zandt and has been maintained in recent years by Denis Girou, Sebastian Rahtz and Herbert Voss (de).

Contents

Basic usage

PSTricks example (scaled) PSTricksSimple.svg
PSTricks example (scaled)

There is a wide array of commands available for making graphics. Coordinates in PSTricks are always represented in parentheses, as the following example (scaled) illustrates:

\begin{pspicture}(5,5)    %% Triangle in red:\pspolygon[linecolor=red](1,1)(5,1)(1,4)    %% Bezier curve in green:\pscurve[linecolor=green,linewidth=2pt,%      showpoints=true](5,5)(3,2)(4,4)(2,3)    %% Circle in blue with radius 1:\pscircle[linecolor=blue,linestyle=dashed](3,2.5){1}\end{pspicture}

Extensions

Plotting sin(x) with pst-plot PSTricks-Sine.png
Plotting sin(x) with pst-plot

PSTricks commands are low level, so many LaTeX packages have been made in order to ease the creation of several kinds of graphics that are commonly used on mathematical typesetting.

pst-plot provides commands for creating function graphs.

Consider the following example:

\begin{pspicture*}(-7,-2)(7,2)    \psaxes[labels=none](0,0)(-7,-2)(7,2)        % sets up axis\psplot[linecolor=blue, linewidth=1.5pt]%    % plots the sinewave{-7}{7}{x 0.01745329252 div sin}% notice the RPN expression\uput[45](3.1415926,0){$\pi$}% these are the labels\uput[90](-1.570796,0){$-\pi/2$}% \uput is a box positioned at [angle]\uput[-90](1.570796,0){$\pi/2$}% relative to (x,y) coordinate\uput[-135](-3.1415926,0){$-\pi$}% and putting { content } on the box\psline[linewidth=1pt,linecolor=red,linestyle=dotted]%   % red dotted lines      (1.57079632,1)(1.57079632,0)    \psline[linewidth=1pt,linecolor=red,linestyle=dotted]%      (-1.57079632,-1)(-1.57079632,0)  \end{pspicture*}

The previous example also illustrate that TeX commands can be used as elements into the pictures. Since PostScript uses RPN style for mathematical operations, the argument to pst-plot must be supplied in the same form. An alternative is to use the optional argument algebraic, then the formula can be described as an algebraic expression.

pstricks-add extends pst-plot enabling also polar graphs and allowing the use algebraic notation for plots instead of RPN.

pst-math provides trigonometric functions in radians (since PostScript defaults to using degrees) and hyperbolic trigonometric functions.

pst-3dplot is used for creating 3D graphics like the following:

Hyperbolic paraboloid drawn using PSTricks package pst-3dplot PSTricks-Hyperboloid.png
Hyperbolic paraboloid drawn using PSTricks package pst-3dplot

multido provides basic loop functionality for programming graphs with repeating elements:

Plotting a graph while varying parameters with multido Drini-nonuniformconvergence.png
Plotting a graph while varying parameters with multido

pst-eucl is a beta extension for easy creation of geometrical drawings.

Circumcircle of a triangle, illustrated with pst-eucl PSTricks-Circumcircle.png
Circumcircle of a triangle, illustrated with pst-eucl

There are many other extensions, for drawing Circuit diagrams, barcodes, graphs, trees, visualizing data, etc.

Compatibility

PSTricks is only fully compatible with TeX systems using PostScript intermediates, including but not limited to eTeX and others. However, it is not compatible with the widely used pdfTeX engine in PDF mode. As pdfTeX is the default engine in most current installations, users of PSTricks must either force pdfTeX to DVI mode or use auto-pst-pdf. PGF/TikZ is an alternative to PSTricks that is compatible with pdfTeX.

Software which supports PSTricks output

See also

Further reading

Related Research Articles

gnuplot Command-line plotting program

gnuplot is a command-line and GUI program that can generate two- and three-dimensional plots of functions, data, and data fits. The program runs on all major computers and operating systems . It is a program with a fairly long history, dating back to 1986. Despite its name, this software is not part of the GNU Project.

Maple (software)

Maple is a symbolic and numeric computing environment as well as a multi-paradigm programming language. It covers several areas of technical computing, such as symbolic mathematics, numerical analysis, data processing, visualization, and others. A toolbox, MapleSim, adds functionality for multidomain physical modeling and code generation.

GNU TeXmacs

GNU TeXmacs is a scientific word processor and typesetting component of the GNU Project. It was inspired by TeX and GNU Emacs, though it shares no code with those programs. TeXmacs does use TeX fonts. It is written and maintained by Joris van der Hoeven and a group of developers. The program produces structured documents with a WYSIWYG user interface. New document styles can be created by the user. The editor provides high-quality typesetting algorithms and TeX and other fonts for publishing professional looking documents.

MetaPost refers to both a programming language and the interpreter of the MetaPost programming language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost produces vector graphic diagrams from a geometric/algebraic description. The language shares Metafont's declarative syntax for manipulating lines, curves, points and geometric transformations. However,

Inkscape Vector graphics editor

Inkscape is a free and open-source vector graphics editor used to create vector images, primarily in Scalable Vector Graphics (SVG) format. Other formats can be imported and exported.

Xfig

Xfig is a free and open-source vector graphics editor which runs under the X Window System on most UNIX-compatible platforms.

DOT is a graph description language. DOT graphs are typically files with the filename extension gv or dot. The extension gv is preferred, to avoid confusion with the extension dot used by versions of Microsoft Word before 2007.

ConTeXt General-purpose document processor, derived from TeX

ConTeXt is a general-purpose document processor. Like LaTeX, it is derived from TeX. It is especially suited for structured documents, automated document production, very fine typography, and multi-lingual typesetting. It is based in part on the TeX typesetting system, and uses a document markup language for manuscript preparation. The typographical and automated capabilities of ConTeXt are extensive, including interfaces for handling microtypography, multiple footnotes and footnote classes, and manipulating OpenType fonts and features. Moreover, it offers extensive support for colors, backgrounds, hyperlinks, presentations, figure-text integration, and conditional compilation. It gives the user extensive control over formatting while making it easy to create new layouts and styles without learning the low-level TeX macro language.

Cairo is an open source graphics library that provides a vector graphics-based, device-independent API for software developers. It provides primitives for two-dimensional drawing across a number of different back ends. Cairo uses hardware acceleration when available.

Asymptote (vector graphics language)

Asymptote is a descriptive vector graphics language — developed by Andy Hammerlindl, John C. Bowman, and Tom Prince — which provides a natural coordinate-based framework for technical drawing. Asymptote runs on all major platforms. It is free software, available under the terms of the GNU Lesser General Public License (LGPL).

LabPlot

LabPlot is a free software and cross-platform computer program for interactive scientific graphing and data analysis, written for the KDE desktop. It is similar to Origin and is able to import Origin's data files.

Adobe Illustrator Artwork (AI) is a proprietary file format developed by Adobe Systems for representing single-page vector-based drawings in either the EPS or PDF formats. The .ai filename extension is used by Adobe Illustrator.

The computer program pdfTeX is an extension of Knuth's typesetting program TeX, and was originally written and developed into a publicly usable product by Hàn Thế Thành as a part of the work for his PhD thesis at the Faculty of Informatics, Masaryk University, Brno, Czech Republic. The idea of making this extension to TeX was conceived during the early 1990s, when Jiří Zlatuška and Phil Taylor discussed some developmental ideas with Donald Knuth at Stanford University. Knuth later met Hàn Thế Thành in Brno during his visit to the Faculty of Informatics to receive an honorary doctorate from Masaryk University.

PGF/Ti<i>k</i>Z Graphics languages

PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipses and polygons. PGF is a lower-level language, while TikZ is a set of higher-level macros that use PGF. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost. Till Tantau is the designer of the PGF and TikZ languages. He is also the main developer of the only known interpreter for PGF and TikZ, which is written in TeX. PGF is an acronym for "Portable Graphics Format". TikZ was introduced in version 0.95 of PGF, and it is a recursive acronym for "TikZ ist kein Zeichenprogramm".

WinFIG

WinFIG is a proprietary shareware vector graphics editor application. The file format and rendering are as close to Xfig as possible, but the program takes advantage of Windows features like clipboard, printer preview, multiple documents etc.

Lively Kernel Open-source web programming environment

The Lively Kernel is an open-source web programming environment. It supports desktop-style applications with rich graphics and direct manipulation abilities, but without the installation or upgrade troubles of conventional desktop applications. Development began at Sun Microsystems Laboratories in Menlo Park, California, and later moved to the Hasso Plattner Institute in Potsdam-Babelsberg near Berlin.

PyX is a Python package for the creation of PostScript, PDF, and static SVG files. It combines an abstraction of the PostScript drawing model with a TeX/LaTeX interface. Complex tasks like 2d and 3d plots in publication-ready quality are built out of these primitives. Its goals are similar to those of other metalanguages for PDF drawing, such as TikZ or Asymptote.