6

I'd like to place a node with multi-line text using as anchor the eastmost point at the baseline of the last line, without having to manually break the lines. Specifying the node text width breaks this.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (10,0);
\foreach \x in {1, 4, 7}
  \draw (\x,-1) -- (\x,1);
\node[anchor=base east, 
      align=right, 
      ] at (1,0) {some text some\\text some text};
\node[anchor=base east, 
      align=right, 
      text width=3cm
      ] at (4,0) {some text some text some text};
\node[anchor=base east, 
      align=right, 
      text width=3cm
      ] at (7,0) {some text some\\text some text};
\end{tikzpicture}
\end{document}

enter image description here

I'd expect something like the second option to do what I want. Is this doable in some other way? Is this a bug?

1 Answer 1

6

You could use a parbox inside the node. Then you can set its baseline:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (10,0);
\foreach \x in {1, 4, 7}
  \draw (\x,-1) -- (\x,1);
\node[anchor=base east,
      align=right,
      ] at (1,0) {some text some\\text some text};
\node[anchor=base east,
      align=right,
      draw=red,inner sep=0pt
      ]  at (4,0) {\parbox[b]{3cm}{some text some text some text}};
\node[anchor=base east,
      align=right,
      text width=3cm,
      ] at (7,0) {some text some\\text some text};
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.