3

in the double foreach loop below, the last element is not displayed vertically. I do not see why?

\documentclass[border=7pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{ positioning }
\begin{document}
\begin{tikzpicture}

\foreach \cc [count=\ci]  in { 
{0 , 0 , 0 , 0},
{0 , 0 , 0 , 1},
{0 , 0 , 1 , 0},
{0 , 0 , 1 , 1},
{0 , 1 , 0 , 0}, 
{0 , 1 , 0 , 1},
{0 , 1 , 1 , 0}
 }{
\foreach \nn [count=\ni] in \cc {
\node[below right= \ni em and \ci em]{\nn};
}
  }
\end{tikzpicture}

\end{document}

enter image description here

2
  • 1
    Does it work for you if you add an empty element (simply add comma after the last 0})? – TeXnician Aug 28 '18 at 15:42
  • 1
    Just add % after the last element. Otherwise the parser gets confused. – user121799 Aug 28 '18 at 15:45
5

If you do the Ulrike-Fischer trick, i.e. add a % at the right place, it works.

\documentclass[border=7pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{ positioning }
\begin{document}
\begin{tikzpicture}

\foreach \cc [count=\ci]  in { 
{0 , 0 , 0 , 0},
{0 , 0 , 0 , 1},
{0 , 0 , 1 , 0},
{0 , 0 , 1 , 1},
{0 , 1 , 0 , 0}, 
{0 , 1 , 0 , 1},
{0 , 1 , 1 , 0}%
 }{
\foreach \nn [count=\ni] in \cc {\typeout{\nn}
\node[below right= \ni em and \ci em]{\nn};
}
  }
\end{tikzpicture}

\end{document}

enter image description here

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.