It is quite usual in scientific texts that one needs to places several graphs next to each other for a better comparison. In general this leads to a “matrix style” placement of the graphs. Let us discuss the ways how to get it in LaTeX.

# Tag Archives: tikz

# TikZ vs. PSTricks

LaTeX boasts nearly perfect means of drawing and visualizing scientific data and schemes. Among them there are: Metapost, Asymptote, PSTricks and TikZ .

- Metapost is a programming language, interpreted into either PS or SVG. It looks like to be the first approach to the Tex-graphics in its kin.
- Asymptote is a programming vector graphics language, inspired by Metapost, allowing to expand TeX capabilities from 2D into 3D. It also has capabilities in exporting drawings in different formats.
- PSTricks is a collection of macros allowing the direct inclusion of Post Script language in TeX. Creation of graphs can be simplified by additional packages like pst-plot and many, many others (check out the examples section on the homepage). Roughly, PSTricks is able doing everything PS can, and also is limited by it.
- TikZ/PGF is a package, consisting of lower-level (PGF) programming language and higher level (TiKZ) user-friendly layer for it. It is quite similar to PSTricks, however the “raw” PS support is more limited.

Having some experience with the last of them, I prefer TiKZ over PSTricks.

The reasons are:

- Easier PDF output in TikZ (can be achieved in PSTricks using pst-pdf package or by
`latex && dvipdf`

), - inline picture inclusion, e.g. \tikz \draw[domain=0:360,smooth,variable=\t] plot ({sin(\t)},\t/360,{cos(\t)});
- more powerful mathematical engine, ( in PSTricks one could use pst-math, pst-func, pst-add and others);
- VERY powerful concept of \datavisualization , one could also use pfgplots package for the same result,
- powerful nodes and graphs packages,
- easier extension of TikZ package for your needs using pgf-language.

# Standalone LateX

A common approach for using images in latex documents is adding \usepackage{graphicx} to the preamble and of myfile.tex inserting image in the following text with \includegraphics{my_image.eps} ( the image type can be different including png, jpg and even .pdf).

If the image type is a some kind of mathematical graph or drawing/scheme one could use TikZ or PSTricks to draw it. However, this approach results in “double work”, e.g. even on a minor change one needs first to compile my_image.tex to my_image.eps, then recompile myfile.tex to update picture in the resulting pdf. Additionally this method has drawbacks, such as changing font size of the text in on resizing the my_image.eps.

One of the possible ways to solve this problem is using standalone package. It allows inserting my_image.tex file in a myfile.tex as an image, while keeping the possibility to compile my_image.tex as a standalone image. Example file listings can be seen in a dedicated gists.

This text is mostly based on the following discussion on tex.stackexchange.