I'm a recent convert to TikZ from xy-pic, and am still trying to get a hang for it. I see that one can add labels to the end of arrows and the like using \node. Is there a way to add an arbitrary piece of text at a given position in the text, regardless of whether there is a shape there, a line there, or nothing at all? Thanks very much for your insight.

-
What do you mean with an arbitrary position in the text? Do you mean at an arbitrary position in your drawing, specified using a coordinate system? Or do you mean at a certain place in your LaTeX document? – Jake Sep 23 '11 at 0:09
Sorry, I mean at an arbitrary position within the drawing itself, preferably specified by coordinates. Many thanks. – Skeptic Sep 23 '11 at 0:12
No problem. Yeah, then using the \node at (<x>,<y>) {<text>} syntax as in Gonzalo's answer is the way to go. – Jake Sep 23 '11 at 0:13

In TikZ you can use nodes to place almost anything (in particular, text) in the position you want. In the following example I used the at construct to specify the exact position of the nodes using explicit coordinates:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[draw] at (0,0) {some text};
\node[draw,align=left] at (3,0) {some text\\ spanning three lines\\ with manual line breaks};
\node[draw,text width=4cm] at (2,-2) {some text spanning three lines with automatic line breaks};
\end{tikzpicture}

\end{document}


I only used the draw option to make the nodes visible. Notice that in the second \node I used the align= key and then used the \\ command to enforce the line breaks at the desired positions. In the third \node, instead of specifying the line breaks "manually", I specified a width for the text and now the line breaking was made automatically.

-
This is great, many thanks. For some reason, though, I get an error in trying to compile across the line containing "align=left". Any ideas on why this is? If I remove that, the picture compiles fine, although the line breaks are ignored. Hmm... – Skeptic Sep 23 '11 at 0:17
@Skeptic: Seems that you are using an outdated version of PGF. Add \pgfversion to your code, and after compilation, you will see in your document the PGF version that your system is using. If your version number is less than 2.10 then you should update it. – Gonzalo Medina Sep 23 '11 at 0:21