1

I have a matrix and want to reference several nodes of this matrix. How do I add a line for some of the cells?

I came up with this:

\documentclass[12pt]{scrbook}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
        \matrix (m) [matrix of nodes]
        {1 & 2 & 3 & 4 & 5 \\};

        \foreach \i in {0, 3}
        {
                \pgfmathsetmacro\iplusone{1+\i}
                \pgfmathsetmacro\itimesfour{4*\i}
                \draw (m-1-\iplusone .south) -- node [at end] {\itimesfour} +(0, -1);
        };
\end{tikzpicture}
\end{document}

Which is a simplified version of what I want to do. However, this does not work and gives the error:

Package PGF Math Error: Unknown operator `s' or `so' (in '0.south').

I don't know where to start with this error at hand.

  • 3
    You need to use \pgfmathtruncatemacro otherwise you have a another . in the output: (m-1-0.0.south) (TikZ parses that as node name m-1-0 and anchor 0.south which it tries as an angle since no anchor is named 0.south. Besides that, there is a spurious { right before the relative coordinate and \itemtimesfour should be \itimesfour. – Qrrbrbirlbel Jul 02 '13 at 13:21

0 Answers0