TeXblog

 Typography with TeX and LaTeX

Archive for 10 August 2008

TikZ: shaded cube

10 August 2008 by Stefan Kottwitz

With just a few lines of code you can create a drawing of a cube with a 3D impression, though if it’s not really perspective or raytraced:

\begin{tikzpicture}[on grid]
  \shade[yslant=-0.5,right color=gray!10, left color=black!50]
    (0,0) rectangle +(3,3);
  \draw[yslant=-0.5] (0,0) grid (3,3);
  \shade[yslant=0.5,right color=gray!70,left color=gray!10]
    (3,-3) rectangle +(3,3);
  \draw[yslant=0.5] (3,-3) grid (6,0);
  \shade[yslant=0.5,xslant=-1,bottom color=gray!10,
    top color=black!80] (6,3) rectangle +(-3,-3);
  \draw[yslant=0.5,xslant=-1] (3,0) grid (6,3);
\end{tikzpicture}

This example uses the positioning tikz library.

Output screenshot:

pgf/TikZ 3D cube

By adding some slanted numbers we will get a Sudoku 3D cube:

pgf/TikZ sudoku 3D

TeX source code and pdf output are provided.

I’ve programmed it to answer a question posted on matheplanet.de. At first I wanted to use the matrix tikz library but it seemed to me that matrices of nodes cannot be slanted, at least I didn’t find a way.

Category: Graphics | 4 Comments »

pgf/TikZ 3D drawings

7 August 2008 by Stefan Kottwitz

Today Tomek posted very impressive 3D drawings made with pgf/TikZ in the LaTeX Community Forum.

Here’s one of the drawings showing a cylindrical projection:

pgf/TikZ 3D example

More examples and their complete sourcecode by Tomasz M. Trzeciak can be found in the corresponding posting in the LaTeX Community Forum.

For even more examples demonstrating the capabilities of pgf/TikZ visit the TikZ example gallery provided by Kjell Magne Fauske.

Category: Graphics, Mathematics | 2 Comments »

Jpgfdraw example

7 August 2008 by Stefan Kottwitz

Here’s an example illustration made with Jpgfdraw following a drawing in Singer/Thorpe Lecture Notes in Elementary Topology and Geometry, I made freehand it to illustrate homotopy of paths in my notes.

Screenshot:

Jpgfdraw example homotopy

Output in pdf format: homotopy.pdf
Jpgfdraw binary file: homotopy.jdr
exported tex file: homotopy.tex

LaTeX main document:

\documentclass[a4paper,10pt]{article}
\usepackage[landscape]{geometry}
\usepackage{amsmath,pgf}
\pagestyle{empty}
\begin{document}
\centering
\input{homotopy}
\end{document}

Category: Tools for LaTeX, IDEs and Editors, Graphics, Mathematics | No Comments »

Jpgfdraw 0.5b released

2 August 2008 by Stefan Kottwitz

The vector graphics application for LaTeX users Jpgfdraw beta version 0.5b has been released today.

The author Nicola Talbot announced:

    Jpgfdraw is a graphics application written in Java. You can use Jpgfdraw to:

  • Construct shapes using lines, moves and cubic Bezier segments;
  • Edit shapes by changing the defining control points;
  • Incorporate text and bitmap images (for annotation and background effects);
  • Extract the parameters for TeX’s \parshape command and for \shapepar (defined in the shapepar package);
  • Construct frames for use with the flowfram package;
  • Pictures can be saved in Jpgfdraw’s native binary format (JDR) or native ascii format (AJR) or can be exported as:
    • a pgfpicture environment for use in LaTeX documents with the pgf package;
    • a LaTeX2e package based on the flowfram package;
    • an encapsulated postscript file;
    • a PNG image file;
    • an SVG image file;
  • Incorporate text and bitmap images (for annotation and background effects);
  • Alternative text may be specified for use when exporting to a LaTeX file (e.g. if the text contains symbols or if it should be set in maths mode);
  • Mappings may be used to specify what LaTeX font declarations should be used when exporting to a LaTeX file.

That sounds very promising. I made a quick test today with Ubuntu Linux 8.04. After installing sun-java6-jre I downloaded and installed jpgfdraw-0.5b-us. It worked immediately. For the test I created a drawing and exported it into a pgf picture, tex format. After including it into a tex document and compiling I got the error Illegal unit of measure (pt inserted). It was caused by the numbers of the export file, they were using a comma instead of a decimal point. That problem is mentioned in the Jpgfdraw FAQ, but contrary to the FAQ it is still occuring with version 0.5b as I noticed using the locale de_DE.UTF-8.
After correction It worked perfectly, the drawing was displayed with high quality. Jpgfdraw could establish itself as a very useful tool.

Links:

Category: Tools for LaTeX, IDEs and Editors, Graphics | 1 Comment »