Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
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}

enter image description here

share|improve this answer
    
here we go again :) –  percusse Aug 20 '12 at 17:50
    
@percusse LOL! Unbelievable! –  Gonzalo Medina Aug 20 '12 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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