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'm using the decorations library to put bended text along a path. That works fine. However, I'd like to have the bended text as a node, so that I can later use it as a reference (for instance to draw a line to it). Is that possible? How do I define the nodes's name?

Here you have a MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\begin{tikzpicture}

\node at (0,0) (nodeA) {A};
\node at (2,2) (nodeB) {B};

\draw (nodeA) -- (nodeB);

\draw [decoration={text along path,
    text={path text},text align={center}},decorate]  (nodeA) -- (nodeB);

    \node at (0,2) (nodeC) {C};
    \draw [->] (nodeC) -- (.8,1.2);

\end{tikzpicture}

\end{document}

In the last bit, where a line is drawn from (nodeC) to the "path text", I had to use a coordinate, but I'd like to be able to use the a node reference.

The picture looks like this:

MWE result

share|improve this question
3  
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Kurt Oct 10 '12 at 14:48
    
Unfortunately, text decorations seperate the text into individual letters and put them into distinct boxes. So if you can provide an MWE then we can try to see if we can squeeze in a coordinate or a node. –  percusse Oct 10 '12 at 16:22
    
@percusse: I've edited my question adding a MWE. I didn't manage to put the code in a comment (I'm new in this forum). –  Didac Busquets Oct 11 '12 at 9:13
2  
Editing the question is always better than putting the code in a comment - you did the right thing. –  Loop Space Oct 11 '12 at 9:14
    
What shape would you like the node to be? Making it follow the shape of the text would be quite hard to do. Putting coordinates at each letter would be possible, followed by fitting a rectangular node to the whole lot. An alternative would be to use the path as a reference. –  Loop Space Oct 11 '12 at 9:17

1 Answer 1

up vote 13 down vote accepted

If you just want the text rotated and sloped along the path, you can use the sloped option to the node, and don't need to use a decoration.

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

    \node at (0,0) (nodeA) {A};
    \node at (2,2) (nodeB) {B};

    \draw (nodeA) -- (nodeB);

    \draw (nodeA) -- (nodeB) node [midway, above, sloped] (TextNode) {path text};
    \node at (0,2) (nodeC) {C};
    \draw [->] (nodeC) -- (TextNode);

\end{tikzpicture}
\end{document}
share|improve this answer
    
That's exactly what I needed... and much easier the using decorations. –  Didac Busquets Oct 11 '12 at 10:52

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.