答案1
这是一个建议。连接由宏绘制
\Connect{<start>}{<end>}{<level>}{<color>}{<label>}
这是 MWE。
\documentclass[border=3.14mm,standalone]{standalone}
\usepackage{tikz-dependency}
\usetikzlibrary{intersections}
\newcounter{depaths}
\newif\ifIntersect
\tikzset{every picture/.append style={execute at begin picture={%
\xdef\LstPaths{}% may be unnecessary
\setcounter{depaths}{0}}}}
\newcommand{\Connect}[6][]{
\stepcounter{depaths}%\typeout{new\space path\space\thedepaths}
\draw[name path=dep connect \thedepaths-tmp,color=#5,#1](\wordref{1}{#2}.70)
-- ++ (0,0.3+0.3*#4) coordinate (aux-\thedepaths-1) -|
(\wordref{1}{#3}.70) coordinate[pos=0.5] (aux-\thedepaths-2);
\ifnum#3>#2
\node[anchor=south east,font=\tiny\sffamily,inner sep=1pt] at (aux-\thedepaths-1) {#6};
\else
\node[anchor=south east,font=\tiny\sffamily,inner sep=1pt] at (aux-\thedepaths-2) {#6};
\fi
\ifnum\thedepaths>1
\foreach \Y [count=\X] in \LstPaths
{\Intersectfalse
%\typeout{checking\space intersection\space with\space path\space \X}
\path[name intersections={of=dep connect \thedepaths-tmp and dep
connect \X-tmp,total=\t}] \pgfextra{%\typeout{\t:\Y}
\ifnum\t>0
\global\Intersecttrue
%\typeout{paths\space\X\space and\space\thedepaths \space\space have\space common\space points}
\fi};
\foreach \V [count=\W] in \Y
{\ifcase\W % no 0
\or % 1 boring
\or % 2
\ifnum\V=#2
%\typeout{case2-2}
\global\Intersectfalse
\fi
\ifnum\V=#3
%\typeout{case2-3}
\global\Intersectfalse
\fi
\or
\ifnum\V=#3
%\typeout{case3-3}
\global\Intersectfalse
\fi
\ifnum\V=#2
%\typeout{case3-2}
\global\Intersectfalse
\fi
\or
\ifnum\V=#4
%\typeout{case4}
\global\Intersectfalse
\fi
\fi}
\ifIntersect
\foreach [count=\ZZ] \XX in \Y
{\ifnum\ZZ=5
\xdef\oldcolor{\XX}
\fi}
\node[circle,fill=white,inner sep=0pt,outer sep=0pt,minimum size=2mm] (aux-int) at (intersection-1){};
\draw[\oldcolor] (aux-int.west) -- (aux-int.east);
\draw[white,double=#5] (aux-int.south) to[out=30,in=-30] (aux-int.north);
%\typeout{real\space intersection\space of\space path\space \thedepaths\space with\space path\space \X}
\fi
}
\fi
\ifnum\thedepaths=1
\xdef\LstPaths{{\thedepaths,#2,#3,#4,#5}}
\else
\xdef\LstPaths{\LstPaths,{\thedepaths,#2,#3,#4,#5}}
\fi
}
\begin{document}
\begin{dependency}
\begin{deptext}[column sep=1pt]
{ho} \& {ha} \& {he} \& {hi} \& {bo} \& {ba} \& {be} \& {bi} \& {ko} \& {ka} \& {ke} \& {ki} \& {do} \& {da} \& {de} \& {di} \\
\end{deptext}
\Connect{1}{13}{1}{red}{range 3}
\Connect{5}{13}{1}{red}{}
\Connect{9}{13}{1}{red}{}
\Connect{2}{14}{2}{cyan}{range 2}
\Connect{6}{14}{2}{cyan}{}
\Connect{10}{14}{2}{cyan}{}
\Connect{3}{15}{3}{green!60!black}{range 1}
\Connect{7}{15}{3}{green!60!black}{}
\Connect{11}{15}{3}{green!60!black}{}
\Connect{4}{16}{4}{orange}{range 0}
\Connect{8}{16}{4}{orange}{}
\Connect{12}{16}{4}{orange}{}
\foreach \Z [count=\n starting from 0,evaluate=\Z as \Zmax using
{int(\Z+2)},evaluate=\Z as \Ztest using {int(\Z+1)}] in {1,5,9,13}
{\foreach \X [evaluate=\X as \Y using {int(\X+1)}] in {\Z,...,\Zmax}
{\ifnum\X=\Ztest
\draw (\wordref{1}{\X}.-110) to[out=-90,in=-90] node[midway,below,font=\small\sffamily]{\n} (\wordref{1}{\Y}.-110)
;
\else
\draw (\wordref{1}{\X}.-110) to[out=-90,in=-90] (\wordref{1}{\Y}.-110);
\fi
}
}
\end{dependency}
\end{document}