# Example: Plane partition

Published 2009-08-17 | Author: Jang Soo Kim

Illustration of a plane partition.

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Plane partition
% Author: Jang Soo Kim
\documentclass{minimal}
\usepackage{tikz}
% Three counters
\newcounter{x}
\newcounter{y}
\newcounter{z}

% The angles of x,y,z-axes
\newcommand\xaxis{210}
\newcommand\yaxis{-30}
\newcommand\zaxis{90}

% The top side of a cube
\newcommand\topside[3]{
\fill[fill=yellow, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (0,1) --(150:1)--(0,0);
}

% The left side of a cube
\newcommand\leftside[3]{
\fill[fill=red, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
shift={(\zaxis:#3)}] (0,0) -- (0,-1) -- (210:1) --(150:1)--(0,0);
}

% The right side of a cube
\newcommand\rightside[3]{
\fill[fill=blue, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}

% The cube
\newcommand\cube[3]{
\topside{#1}{#2}{#3} \leftside{#1}{#2}{#3} \rightside{#1}{#2}{#3}
}

% Definition of \planepartition
% To draw the following plane partition, just write \planepartition{ {a, b, c}, {d,e} }.
%  a b c
%  d e
\newcommand\planepartition[1]{
\setcounter{x}{-1}
\foreach \a in {#1} {
\setcounter{y}{-1}
\foreach \b in \a {
\setcounter{z}{-1}
\foreach \c in {1,...,\b} {
\cube{\value{x}}{\value{y}}{\value{z}}
}
}
}
}

\begin{document}

\begin{tikzpicture}
\planepartition{{5,3,2,2},{4,2,2,1},{2,1},{1}}
\end{tikzpicture}

\end{document}


• #1 Dick van der Leeden, April 4, 2010 at 3:16 p.m.

Great work!

I noticed however that a zero in the definition, such as

\planepartition{{5,3,0,2},{4,2,2,1},{2,1},{1}}


results in a stack of 2 cubes in stead of no cubes!

Is it possible to fix this?

Thanks, Dick

• #2 Dick van der Leeden, April 4, 2010 at 8:39 p.m.

I guess I found a solution myself, here is the new definition of \planepartition

\newcommand\planepartition[1]{
\setcounter{x}{-1}
\foreach \a in {#1} {
\setcounter{y}{-1}
\foreach \b in \a {
\setcounter{z}{-1}
\foreach \c in {0,...,\b} {
\cube{\value{x}}{\value{y}}{\value{z}}}
}
}
}
}

• #3 Vin, October 8, 2010 at 3:49 a.m.

Jang Soo Kim's programme is impressive.

Dick's work makes it prefect.

Is the part "\addtocounter{y}{0}" necessary in the ifthenelse statement?

##### Scientific and technical areas

Learn TikZ: TikZ.org