I would like to place text exactly centred over an exactly specified point on a highly complex path as shown in this Figure:
I have developed my example by specifying the point at 0.1 from the beginning of path and adding a mark to it:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text, decorations.markings}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (1, 3);
\coordinate (C) at (2, -1);
\coordinate (D) at (3, 0.5);
%placement of mark
\draw plot [smooth] coordinates { (A) (B) (C) (D) };
\path [
postaction={decorate},
decoration={
markings,
mark = at position 0.1 with {\fill[red] circle[radius=0.2cm];}
}
] plot [smooth] coordinates { (A) (B) (C) (D) };
%placement of text
\path [
postaction={decorate},
decoration={
text along path,
raise=0.4cm,
text align/left indent = {0.1\dimexpr\pgfdecoratedpathlength\relax},
text={here!!}
}
] plot [smooth] coordinates { (A) (B) (C) (D) };
\end{tikzpicture}
\end{document}
The output is
To centre the text over the mark I would only need to replace left with center in text align/left indent = {0.1\dimexpr\pgfdecoratedpathlength\relax}. Then everything would be perfect! Unfortunately after this change the example no longer compiles.
How to fix this problem?





\fill[red] circle[radius=0.2cm];. – Jun 25 '19 at 16:185in\pgfmathsetmacro{\mywidth}{5*width("here!!")}. You need to explain that 0.1 is a factor to 5 to produce 0.5. If some other position is used the new coefficient is calculated as 0.5/coeff. – Viesturs Jun 27 '19 at 16:180.1and0.1*5=1/2. One could write a simple style that does arbitrary positions. – Jun 27 '19 at 16:22