如何让我的路径节点从某个位置开始跟随路径?

如何让我的路径节点从某个位置开始跟随路径?

我正在尝试制作一个带有弯曲箭头的图表,我希望它的节点从“近端”点开始跟随箭头。我已经在谷歌上搜索了几个小时,但找不到方法。我尝试了不同的方法,并在此网站上搜索解决方案。这是我目前所得到的:

\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}

我感觉我已经很接近了,$x\longmapsto e$只需要沿着箭头的曲线走。

答案1

是的,你非常接近了。但在你的第一个案例中

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

您用没有文本的方式修饰了节点(包含)的路径$x \longmapsto e$

在下面的例子中,显示了所有可能性,我只需使用sloped沿路径放置的典型节点(此处为蓝色)。

代码

\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

代码

\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}

输出

在此处输入图片描述

相关内容