Tikz:一个边缘上有两个标签(一个接一个)

Tikz:一个边缘上有两个标签(一个接一个)

我想添加一个标签,该标签位于另一个标签之后。例如,我有:

\documentclass[10pt]{beamer}

\usepackage{tkz-graph}
\GraphInit[vstyle = Shade]

\tikzset{
  LabelStyle/.style = { rectangle, rounded corners, draw,
                        minimum width = 2em, fill = yellow!50,
                        text = red, font = \bfseries },
  VertexStyle/.append style = { inner sep=5pt,
                                font = \Large\bfseries},
  EdgeStyle/.append style = {->, bend left} }




\title{test}

\begin{document}

\begin{frame}{graph}
      \begin{tikzpicture}
        \SetGraphUnit{4}
        \Vertex{A}
        \EA(A){B}
        \Edge[label = first](A)(B)
        \Edge[label = ok](B)(A)
      \end{tikzpicture}
\end{frame}

\end{document}

我希望在同一边缘上的“第一个”标签之后有另一个“第二个”标签。

答案1

采用纯 TiZ,但“导入” 的样式tkz-graph。您仍然可以tkz-graph在文档的其余部分使用。最重要的是,在这张特定的图片中(我不使用tkz-graph),我建议不要使用全局选项(EdgeStyleLabelStyle等)以避免冲突。我改用labelonpathmyvertex

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\tikzset{
  labelonpath/.style = { rectangle, rounded corners, draw,
                        minimum width = 2em, fill = yellow!50,
                        text = red, font = \bfseries },
  myvertex/.style = {circle,inner sep=5pt,font = \Large\bfseries,draw,ball color=orange},
}
\begin{document}
\begin{tikzpicture}
\sffamily
\node[myvertex] (a) {A};
\node[myvertex,right=5cm of a] (b) {B};
\draw[double=orange,double distance=1pt,line width=0.8pt,color=black,->,bend left] (a) to node[pos=.3,sloped,labelonpath] {First} node[pos=.7,sloped,labelonpath] {Second} (b);
\draw[double=orange,double distance=1pt,line width=0.8pt,color=black,->,bend left] (b) to node[midway,sloped,labelonpath] {Okay} (a);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容