# TIKZ-PGF: Align two text-nodes to the left

I want to draw two text nodes in tikz-figure where the text is aligned left and not centered:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node at (1.0, 2.0) {veeeeeeeeeeery long text node};
\node at (1.0, 1.0) {short text node};
\end{tikzpicture}
\end{figure}

\end{document}


Here, the positions define the center of the text. What I want to do is to specify the left position of text. Who to do this?

-

If I understand correctly, you want the text in the nodes to appear left-aligned. You can use the anchor option that tells TikZ which one of the node's anchors to place at the specified coordinates:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [anchor=west] at (1.0, 2.0) {veeeeeeeeeeery long text node};
\node [anchor=west] at (1.0, 1.0) {short text node};
\end{tikzpicture}
\end{document}


-
I've added the picture obtained. I hope you don't mind :). –  Claudio Fiandrino Aug 11 '12 at 12:28
@Claudio Should have done it myself, thanks. –  Baldrick Aug 11 '12 at 13:17

This is quite easy: just use \node[right] to tell TikZ to fraw the nodes rightward from the specified position:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[right] at (1.0, 2.0) {veeeeeeeeeeery long text node};
\node[right] at (1.0, 1.0) {short text node};
\end{tikzpicture}
\end{figure}

\end{document}


If you want the texts not that far apart, you can do it without trying by using named nodes for referencing:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[right,inner sep=0,minimum height=0.6cm] (a) at (1.0, 2.0) {veeeeeeeeeeery long text node};
\node[below right,inner sep=0,minimum height=0.6cm] (b) at (a.south west) {short text node};
\node[below right,inner sep=0,minimum height=0.6cm] (c) at (b.south west) {another text node};
\node[below right,inner sep=0,minimum height=0.6cm] (d) at (c.south west) {yet another text node};
\end{tikzpicture}
\end{figure}

\end{document}


If you use the align=<key> option for the node, you can also use \\ inside the node for line breaking, thus putting all the content in a single node:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[align=left] {veeeeeeeeeeery long text node\\ short text node\\ another text node\\yet another text node};
\end{tikzpicture}
\end{figure}

\end{document}


If it does not matter where the line breaks occur, you can use the text width=<length> option to automatically break the text:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[text width=5cm] {veeeeeeeeeeery long text node; short text node; another text node; yet another text node};
\end{tikzpicture}
\end{figure}

\end{document}


-