1

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.

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

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}

enter image description here

3

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.