Drawing the crystal lattice in LaTeX

While LaTeX packages TikZ and PStricks  (see previous post) extensively support 2D, the  3D support is somewhat limited: z-coordinate (depth) is not accounted for in certain cases, so the the newer object declaration or higher layer “covers” older object or lower layer.

Possible solution is using Asymptote package. It comes with additional bonuses like inlining code into TeX code, export into various image formats and even embedding PRC graphics within PDF files. Just what one needs for imaging the crystal structure! :-)

Continue reading

Advertisements

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.

An explanatory remark

Currently I’m a PhD student, finishing my thesis. During the preparation of the manuscript I used LaTeX for the typesetting and git for the revision control.

I would like to share certain ideas and techniques which for the preparation of the manuscript and data visualization, so following posts of this blog will cover (but won’t be limited to) this topic. And I hope that this experience will be useful for anybody else.