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 be able to put a comment below an element in the last row of a TikZ matrix. I thought that the MWE below would allow me to do that, but it does not. To be specific, I thought the MWE below would print "hello" below element 9.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
  \matrix
  {
    \node {8}; &[2mm] \node{1}; &[-1mm] \node {6}; \\
    \node {3}; &      \node{5}; &       \node {7}; \\
    \node {4}; &      \node(a){9}; &    \node {2}; \\
  };
  \node (a.south) {hello};
\end{tikzpicture}
\end{document}

How can I get this to work?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Using \node [below] at (a.south) {hello} works. Without the at you are defining a new node named (a.south).

enter image description here

Why no error message?

  • Leaving out the at does not generate an error as it is perfectly valid syntax. So,

     \node (X) {text 1};
    

    defines a coordinate named (X) at the current location, and

     \node at (Y) {text 2};
    

    places the given text at the coordinate named (Y).

    In your specific example, the first use of \node (a) {9} was defining a coordinate named (a) at the point where the node containing the text 9 is located. Your second use (where you were trying to place hello) was defining a coordinate named (a.south) without explicitly specifying where you wanted this node placed.

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
  \matrix
  {
    \node {8}; &[2mm] \node{1}; &[-1mm] \node {6}; \\
    \node {3}; &      \node{5}; &       \node {7}; \\
    \node {4}; &      \node(a){9}; &    \node {2}; \\
  };
  \node  [below] at (a.south) {hello};
\end{tikzpicture}
\end{document}
share|improve this answer
    
Thanks. Why is the "at" necessary - or put another way - why does a missing "at" not lead to an error? –  user1362373 Feb 10 at 18:19
    
@user1362373: Have updated answer. Please let me know if that clarifies things. –  Peter Grill Feb 10 at 18:48
    
Got it, thanks for the clarification. –  user1362373 Feb 10 at 19:00
add comment

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.