# position and align of label

I have to move the text of a node such that the text is right of the node, but I do not see how to combine this with align=left.

In the following MWE (much simplified) the node (c) should have the text left of the node, but I cannot get the left tikz command to position the label in the correct place.

\documentclass[msmallroyalvopaper
]{memoir}
\usepackage{tikz}

\begin{document}

A \hfill Z

\begin{tikzpicture}

\node [ align=left] (top) at (-2,11) {action\\ plus} ;
\node (c) at (1.5,7)
[align=left] {soem first line\\ some second line} ;

\node(bottom) at (-1,4)  [align=left] {a first line \\ a second line };

\draw (top) -- (c) -- (bottom);
\end{tikzpicture}

A \hfill Z

\end{document}


• The text of the node is the node, so the text cannot be to the left of the node. It can be placed to the left of another node, or use the left (east) anchor to position this anchor on certain coordinate. align=left forces that all lines inside the node align to the left, as you can see in your results. – Ignasi Jun 22 '18 at 10:12
• The align key sets the justification of the text inside the node. On the other hand, if you do \node[left] .. the node is placed with its east anchor at the specified coordinate. But I don't really understand what you want to do, do you want to add an additional label to the node? Do you want something like \draw (top) -- (c.east) -- (bottom);? – Torbjørn T. Jun 22 '18 at 10:12
• By "additional label" I meant e.g. \node [label={[align=left]left:soem first line\\ some second line}] (c) at (1.5,7) {}; – Torbjørn T. Jun 22 '18 at 10:15
• Your last comment was exactly what I needed and I was confused with the correct passig of arguments. Thank you! Do you want to put it in as an answer I can accept? – user855443 Jun 22 '18 at 10:22
• I ended with a command like \node [label={[align=left,shift={(-1cm,-0.5cm)}]:some first line\\ some second line}] (c) at (1.5,7) {}; but now the lines interfere with the label. Before the shielding was automatic? What am I doing wrong? – user855443 Jun 22 '18 at 10:57

The text of a node will always be inside the node, as Ignasi says it is the node. But TikZ has the option of adding a label to a node. (A label is essentially a second node attached to the parent node.)

So with

\node [label=foo] (a) at (1,1) {bar};


bar is placed at (1,1) and a points to bar, but you will in addition have the label foo place above bar.

You can set the position of the label relative to the parent node with e.g.

\node [label=left:foo] ...


In addition to left, above left, etc., an angle can be specified.

To add options to the label node, you use

\node [label={[<options>]left:foo}] ...


Note the braces around the entire label.

So to have a multi-line label with align=left on the left side of an empty node:

\node [label={[align=left]left:soem first line\\ some second line}] (c) at (1.5,7) {};


Complete example:

\documentclass[msmallroyalvopaper
]{memoir}
\usepackage{tikz}

\begin{document}

A \hfill Z

\begin{tikzpicture}

\node [align=left] (top) at (-2,11) {action\\ plus} ;
\node [label={[align=left]left:soem first line\\ some second line}] (c) at (1.5,7) {};

\node [align=left](bottom) at (-1,4)  {a first line \\ a second line };

\draw (top) -- (c) -- (bottom);
\end{tikzpicture}

A \hfill Z

\end{document}

• nice explanation! +1 – Zarko Jun 22 '18 at 10:47
• I think node c should be a coordinate otherwise it keeps a minimum size which makes path (top) -- (c) -- (bottom) to show a gap arround c. – Ignasi Jun 22 '18 at 11:42
• @Ignasi Perhaps, it depends on what the node looks like in the real document, the OP said the example was very simplified. It could for example be filled rectangle or something. – Torbjørn T. Jun 22 '18 at 12:38