# TikZ scripting upper triangular elements only

I would like to do something along the lines of the following snippet but I instead get many errors:

\foreach \x in {0,...,8} {
\foreach \y [evaluate=\y as \z using int(4-\y)] in {0,...,4} {
\ifthenelse{\less{x}{y} \OR \equal{x}{y}}
{ \node at (\x cm,\y cm) (g-\x-\y) {$a_{\x,\z}$}; }
{ }
}
}


meaning show a node only if it belongs to the upper triangular.

-
Please provide complete documents instead of just snippets; where do \less, \OR and \equal come from? – Gonzalo Medina Aug 20 '12 at 17:31

Is this what you mean?

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {0,...,8} {
\foreach \y [evaluate=\y as \z using int(4-\y)] in {0,...,4} {
\pgfmathtruncatemacro{\myresult}{\x<\z ? 1 : 0}
\ifnum\myresult=0%
\node at (\x cm,\y cm) (g-\x-\y) {$a_{\x,\z}$};\fi
}
}
\end{tikzpicture}
\end{document}


-
thank you, good job :) – Giovanni Azua Aug 21 '12 at 12:56

Is something like this what you want?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[line cap=round,line join=round, scale=1]
\foreach \x in {0,...,8} {
\foreach \y [evaluate=\y as \z using int(4-\y)] in {0,...,4} {
\pgfmathparse{\x<=\y ? "\noexpand\node at (\x cm,\y cm) (g-\x-\y) {$a_{\x,\z}$};" : " " }
\pgfmathresult
}
}
\end{tikzpicture}

\end{document}


-
here we go again :) – percusse Aug 20 '12 at 17:50
@percusse LOL! Unbelievable! – Gonzalo Medina Aug 20 '12 at 17:51