2

I am drawing an arrow with text above it

\documentclass[tikz]{standalone} 
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\draw[<-, thick, postaction={decorate, decoration={text along path,text align=center, raise=.7em, text={Process}}}]
        (0, 0) to [bend left=60] (5, 0);
\end{tikzpicture}
\end{document}

The result cuts off the top of the text of the label. enter image description here

How can I fix the bounding box of the tikzpicture so that it adjusts itself the text of the label? Can I get the decorations to extend the bounding box, the way arrows.meta does for arrows?


I would like the bounding box of the tikzpicture to adjust automatically to the contents of the picture, rather than have to fine tune a fixed value.

If I put the text in its own node, it doesn't get cut off, but then it doesn't follow the path of the arrow.

Of course, I can not raise the text, but then it is too close to the arrow.


The accepted answer here has nothing to do with my problem, since the arrows.meta package doesn't change the bounding box for decorations. The other answers to that question suggest adding margins, but I do not want to have to fine tune the margin parameter (and then have to change it again, if I move the arrow decoration).

15
  • 1
    Without a complete example, it's difficult to answer. The answer, I think, is that you made a mistake before because your code compiles perfectly. Feb 18, 2020 at 15:00
  • 2
    If we try OP's code with standalone class, we get the issue about which s/he is talking. Try this \documentclass[tikz]{standalone} \usetikzlibrary{decorations.text} \begin{document} \begin{tikzpicture} \draw[<-, thick, postaction={decorate, decoration={text along path,text align=center, raise=.7em, text={Process}}}] (0, 0) to [bend left=60] (5, 0); \end{tikzpicture} \end{document}
    – Niranjan
    Feb 18, 2020 at 15:04
  • 6
    Does this answer your question? Why are the endpoint lines of intervals (`|-|`) not shown completely?
    – Kate
    Feb 18, 2020 at 15:12
  • 1
    It is a known bug: tex.stackexchange.com/q/497684.
    – user194703
    Feb 18, 2020 at 16:00
  • 1
    @AlainMatthes I do reproduce the issue. More precisely, if I compile the example, the text is barely in (but not cut as badly as in the OP's screen shot). If I use text={|\Huge|Process}, then it gets cut more badly. The fact that it is is originally partly visible is IMHO an accident because the bounding box gets overestimated, a well known effect for Bezier curves that you wrote a nice answer for. ;-)
    – user194703
    Feb 18, 2020 at 19:39

2 Answers 2

2

The bounding box is not calculated correctly. One can proof this by drawing the bounding box using \draw[red] (current bounding box.north west) rectangle (current bounding box.south east);

enter image description here

Quick hack is to add a margin to standalone class.

\documentclass[tikz,margin=1cm]{standalone} 
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\draw[<-, thick, postaction={decorate, decoration={text along path,text align=center, raise=.7em, text={Process}}}]
        (0, 0) to [bend left=60] (5, 0);
\end{tikzpicture}
\end{document}
0

By making the text follow a path different from that of the arrow, the text follows a bend and is not cut off by the bounding box

\begin{tikzpicture}
\pgfmathsetmacro{\xa}{0}
\pgfmathsetmacro{\xb}{5}
\pgfmathsetmacro{\y}{0}
\pgfmathsetmacro{\m}{.2}

\draw[<-, thick]
        (\xa, \y) to [bend left=60] (\xb, \y);

\path [decorate,decoration={text along path, text align=center, text={Process}}] (\xa, \y + \m) to [bend left=60] (\xb, \y + \m);

\end{tikzpicture}

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.