1

I would like to ask again the following question:

TikZ: text along path as node

That question was answered with a solution which was good enough for OP at the time. I would, however like to have an answer to the question as posed originally.

More specifically, I want to have a text following a curved path (for instance using decorations) and then use that text to fit a shape around it. In this example, I would like to draw an ellipse fitting "stuff" and "along path" but I don't know how to refer to "along path" because it has no node name.

\documentclass{standalone} \usepackage{pgf,tikz} \usetikzlibrary{decorations.text,fit,shapes} \begin{document} \begin{tikzpicture} \node (A) at (-2,2) {stuff}; \draw[postaction={decorate,decoration={ text along path, text={along path}, % name = (B), <--- this does not work raise = 3 }}] (-1,0) to [out= 90, in=90] (1,0); % \draw[fit=(A)(B), ellipse]{}; <---- I want to be able to do this \end{tikzpicture} \end{document} 
3
  • You have already done what you want. Please can you explain what you want by a sketch? Commented Jan 20, 2020 at 12:42
  • I want to draw a shape (for instance an ellipse) fitting tightly around the words “stuff” and “along path”. Commented Jan 20, 2020 at 12:52
  • I have edited the question. It should hopefully be more clear now. Commented Jan 20, 2020 at 13:21

1 Answer 1

1

With the text along path decoration, the characters will not be put into a node. The text effects along path decoration, however, does.

The /pgf/decoration/text effects/text along path is used to imitate the placement of the text along path decoration (transform shape, inner xsep=0pt, anchor=base).

With a normal space, the distance between g and p is not the same though. I'm using \ instead ({ } would also work).

Code

\documentclass{standalone} \usepackage{tikz} \usetikzlibrary{decorations.text, fit, shapes.geometric} \begin{document} \begin{tikzpicture} \node (A) at (-2,2) {stuff}; \draw[ postaction={ decorate, decoration={ name = text along path, text = {along path}, raise = +3pt}} ] (-1,0) to [out= 90, in=90] (1,0); \end{tikzpicture} \begin{tikzpicture} \node (A) at (-2,2) {stuff}; \draw[ postaction={ decorate, decoration={ name = text effects along path, text = {along\ path}, text effects/character count=\i, text effects/every letter/.style={ shape=rectangle, name=t-\i, /pgf/decoration/text effects/text along path, }, raise = +3pt }, } ] (-1,0) to [out= 90, in=90] (1,0); \node[rectangle, inner sep=+0pt, draw, help lines, fit=(A)(t-1)(t-10)]{}; \node[ellipse, draw, fit=(A)(t-1)(t-10)]{}; \end{tikzpicture} \end{document} 

Output

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.