Question
How to add text to arbitrary positions in TikZ-pictures relative to certain objects (maybe even following their shape) ?
Situation
I have combined two solutions to Tikz-questions found here on stackexchange, namely:
Even though I could create the desired drawing, I do not fully understand the provided solutions. Therefore the following problem came up: I was unable to figure out the right way to insert some text (a is not close enough and could be rotated along the curve) as depicted in this image:
MWE
\documentclass[preview]{standalone}
\usepackage{filecontents}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{intersections}
\begin{filecontents}{projection.tikz}
% tangent: https://tex.stackexchange.com/a/25940/74942
% intersection: https://tex.stackexchange.com/a/58216/74942
\begin{tikzpicture}[
tangent/.style={
decoration={
markings,% switch on markings
mark=
at position #1
with
{
\coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
\coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
\coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
}
},
postaction=decorate
},
use tangent/.style={
shift=(tangent point-#1),
x=(tangent unit vector-#1),
y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
] % tangent
\draw[help lines,xstep=.5,ystep=.5] (0,0) grid (4,3); %grid
\draw [
name path=curve,
tangent=0.4
] (0,0)
to [out=60,in=180] (2,2)
to [out=0, in=160] (3,1.75)
to [out=-20, in=-120] (4,3);
\draw [blue, name path=tangent, use tangent] (-1,0) -- (2,0)
node[sloped,inner sep=0cm,below,pos=.8,
anchor=north west,
minimum height=1cm,
minimum width=1cm](N){a};
\path [name path=proj] (N.north west)% intersection
node (P) {b} -- (N.south west);
\draw [name intersections={of=curve and proj}, blue] (P.center)
--
(intersection-1);
\end{tikzpicture}
\end{filecontents}
\begin{document}
\input{./projection.tikz}
\end{document}
a
to be?a
should be where "and here" is.