# How do I make my path node follow the path from a certain position?

I am trying to make a diagram with a curved arrow and I want its node to follow the arrow from about the "near end" point. I have been googling for hours now and I can't find the way to do it. I've tried different things and searched this site for solutions. This is what I have so far:

\documentclass[11pt]{article}

\usepackage[a4paper,margin=2cm]{geometry}
\usepackage[dutch]{babel}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{matrix,arrows,decorations.text,decorations.pathmorphing,decorations.markings}

\begin{document}
$$\begin{tikzpicture}[description/.style={fill=white,inner sep=1pt}] \matrix(m)[matrix of math nodes, row sep=5em, column sep=5em, text height=1.5ex, text depth=0.25ex]{ \partial I & I & E \\ (\partial I)\times I & I\times I & B \\}; \path[->] (m-1-1) edge node[auto] {i_1} (m-1-2) edge (m-2-1) (m-1-2) edge node[auto] {x\longmapsto e} (m-1-3) edge (m-2-2) (m-2-1) edge node[auto] {i_2} (m-2-2) edge[out=45,in=225,-,line width=6pt,draw=white] (m-1-3) %edge[out=45,in=225] node[pos=0.7,auto,swap,postaction={decorate,decoration={text along path}}] {x\longmapsto e} (m-1-3) %edge[out=45,in=225,postaction={decorate,decoration={text along path,raise=-8pt,text={||{x\longmapsto e}}}}] node[pos=0.7,auto,swap] {x\longmapsto e} (m-1-3) edge[out=45,in=225,postaction={decorate,decoration={text along path,raise=-8pt,markings,mark=at position 0.7 with {\node {x\longmapsto e};}}}] (m-1-3) %edge[out=45,in=225,postaction={decorate,decoration={text along path,raise=-8pt,markings,mark=at position 0.7 with {\node {};},text={||{x\longmapsto e}}}}] (m-1-3) (m-2-2) edge[dashed,bend right=25] node[auto,swap] {\tilde{\alpha}} (m-1-3) edge node[auto,swap] {\alpha} (m-2-3) (m-1-3) edge node[auto] {p} (m-2-3); \end{tikzpicture}$$
\end{document}


I feel like I'm very close, the $x\longmapsto e$ only has to follow the curve of the arrow.

• You decorate the path of the node (a rectangle) with nothing (no text). You want to use the decoration on the edge and give it a text to use as decoration, i.e. postaction={decorate}, decoration={text along path, text={<text goes here>}}. Ah, wait, you have a few variation in there. Can you show us what you want? Do you know of tikz-cd/tikz-cd? Sep 9 '13 at 15:25

Yes, you were very close. But in your first case

edge[out=45,in=225]
node[…,
postaction={decorate,decoration={text along path}}
] {$x\longmapsto e$}
(m-1-3)


you decorated the path of the node (which contains $x \longmapsto e$) with no text.

In the example below, all possibilites are shown, I’d simply use the typical node that is placed sloped along the path (here in blue).

## Code

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.text,decorations.markings}
\begin{document}
\begin{tikzpicture}
\matrix(m)[matrix of math nodes, row sep=5em, column sep=5em, text height=1.5ex, text depth=0.25ex]{
\partial I           & I         & E \\
(\partial I)\times I & I\times I & B \\};
\path[->]
(m-2-1) edge[out=45,in=225,
postaction={
decorate,
decoration={
markings,
mark=at position 0.3 with {\node[transform shape, red, above] {$x\longmapsto e$};}
}
},
postaction={
decorate,
decoration={
text along path,
raise=1ex,
text align={align=left, left indent=10em},
text={{$x$} {$\longmapsto$} {$e$}}
}
}
] node[near end, sloped, below, blue] {$x\longmapsto e$} (m-1-3)
;
\end{tikzpicture}
\end{document}


## tikz-cd

### Code

\documentclass[tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[
row sep=5em, column sep=5em,
% \textstyle but \scriptsize:
% previous font: \everymath\expandafter{\the\everymath\scriptstyle}
every label/.append style={font=\scriptsize}
]
% first row:
\partial I \rar{i_1}
\dar
& I     \rar{x \to e}
\dar
& E \dar{p}                                                                 \\
% second row:
(\partial I) \times I \rar{i_2}
\arrow[crossing over, out=45, in=225]{urr}
[sloped, auto=false, below, near end]{x \longmapsto e}
& I\times I \rar{\alpha}
\urar[dashed,bend right=25][swap]{\tilde\alpha}
& B
\end{tikzcd}
\end{document}