在链连接箭头线上添加标签

在链连接箭头线上添加标签

我想在链连接箭头线上添加一些标签。

可以添加任何命令来将样式与标签连接起来吗?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,chains}
\begin{document}
\begin{tikzpicture}[
    node distance=1.5cm,
    arrow/.style={->, >=Stealth, thick},
    every on chain/.append style={draw,join,rounded corners,minimum width=2cm, minimum height=1cm, align=center},
    every join/.style={arrow},
    start chain=C1 going right,
    ]

  \def\nodes{
    A/A2B,
    B/B2C,
    C/C2A%
    }
    \foreach \name/\label [count=\i] in \nodes {
      \typeout{debugme \label}
        \node[on chain,join] (N\i) {\name};
    }

\end{tikzpicture}
\end{document}

输出: 在此处输入图片描述

答案1

来自 js bibra 的回答,chain-end以及chain-begin

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                %positioning,
                % scopes,
                quotes,}
\begin{document}
    \begin{tikzpicture}[
        node distance=1.5cm,
        arrow/.style={->, >=Stealth, thick},
        every on chain/.append style={draw,join,rounded corners,minimum width=2cm, minimum height=1cm, align=center},
        every join/.style={arrow},
        start chain=going right,
        ]
        
        \def\nodes{
            A/,
            B/A2B,
            C/B2C%
        }
        \foreach \name/\label [count=\i] in \nodes {
            % \node[on chain,join=by {->,"\label"}] (N\i) {\name};
            \node[on chain,join=by {"\label"}] (N\i) {\name};
            }    
        \draw [arrow] (chain-end.south) -- ++(0,-1.) -|  (chain-begin.south) node[above,pos=0.25]{C2A};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

由于最后一个节点显示为一个空框,因此无法找到如何删除它 - 部分答案 - 可能一些老手会介入以提供帮助

输出

在此处输入图片描述

平均能量损失

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,chains,positioning,scopes,quotes}
\begin{document}
    \begin{tikzpicture}[
        node distance=1.5cm,
        arrow/.style={->, >=Stealth, thick},
        every on chain/.append style={draw,join,rounded corners,minimum width=2cm, minimum height=1cm, align=center},
        every join/.style={arrow},
        start chain=C1 going right,
        ]
        
        \def\nodes{
            A/,
            B/A2B,
            C/B2C,
              /C2A%
        }
        \foreach \name/\label [count=\i] in \nodes {
            \node[on chain,join=by {->,"\label"}] (N\i) {\name};
        }
        
    \end{tikzpicture}
\end{document}

相关内容