我还没有找到在序列图下添加标签(如图片中)的方法。可以吗?我想在文本中引用图表,但我不知道如何为每个序列图显示标签。TIA
例如
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgf-umlsd}
\newcommand{\newthreadShift}[4][gray!30]{
\newinst[#4]{#2}{#3}
\stepcounter{threadnum}
\node[below of=inst\theinstnum,node distance=0.8cm] (thread\thethreadnum) {};
\tikzstyle{threadcolor\thethreadnum}=[fill=#1]
\tikzstyle{instcolor#2}=[fill=#1]
}
\begin{sequencediagram}
\centering
\newthread{A}{Alice}
\newthreadShift{B}{Bob}{3cm}
\begin{messcall}{A}{$C, Id$}{B}{}
\end{messcall}
\begin{messcall}{B}{$C, Id$}{A}{}
\end{messcall}
\end{sequencediagram}
如下图所示:
我如何在第 V 部分之前的图表(即图 1)中添加标签。
答案1
为了好玩,但你可能喜欢:
\documentclass[margin=3mm, many]{standalone}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning,
quotes
}
\usepackage{tikzpeople}
\begin{document}
\begin{tikzpicture}[
node distance = 55mm,
> = Straight Barb,
ms/.style = {minimum size=7mm},
ts/.style = {transform canvas={yshift=#1}},
N/.style = {draw, fill=gray, inner sep=0pt,
minimum height=22mm, minimum width=2mm,
node contents={},
},
every edge quotes/.style = {auto, font=\small,
text=black, inner sep=1pt}
]
\node (s) [alice,ms] {Alice};
\node (r) [bob, ms,right=of s] {Bob};
%
\node (L) [N, below right=2mm of s.north east] (L);
\node (R) [N, below left=2mm of r.north west] (R);
\draw[dotted] (L.south) edge ++ (0,-0.5)
(R.south) edge ++ (0,-0.5);
\draw [->,ts= 5ex] (L) edge["{$C,Id$}"] (R);
\draw [<-,ts= 2ex] (L) edge["{$C,Id$}"] (R);
\draw [->,ultra thick, gray,
ts=-2ex] (L) edge["data?"] (R);
\end{tikzpicture}
\end{document}