This is certainly not yet a full answer, just to tell you that I do not agree with your scepticism on the package. IMHO this is a package with an extremely well-written manual, and here is why I believe you can achieve what you want with it. The key ingredient of this answer is a macro
\Connect{<start>}{<end>}{<level>}{<label>}
where start
, end
and level
are all integers. Its use is illustrated by the following MWE.
\documentclass[border=3.14mm,standalone]{standalone}
\usepackage{mathtools}
\usepackage{tikz-dependency}
\usetikzlibrary{intersections} % not used ... YET
\newcounter{depaths}
\newcommand{\Connect}[5][]{
\stepcounter{depaths}
\draw[name path=dep connect \thedepaths](\wordref{2}{#2}) -- ++ (0,-#4) coordinate (aux-\thedepaths-1) -|
(\wordref{2}{#3}) coordinate[pos=0.5] (aux-\thedepaths-2);
\draw[-latex,shorten >=1pt] (aux-\thedepaths-1) -- (aux-\thedepaths-2);
\ifnum#3>#2
\node[anchor=south east] at (aux-\thedepaths-2) {#5};
\else
\node[anchor=south west] at (aux-\thedepaths-2) {#5};
\fi
\foreach \X in {1,...,#4}
{\fill (\wordref{2}{#2}) ++ (0,-\X) circle(1.5pt);
\fill (\wordref{2}{#3}) ++ (0,-\X) circle(1.5pt);}
\pgfmathtruncatemacro{\DeltaX}{abs(#3-#2)}
\ifnum\DeltaX>1
\foreach \X in {#2,...,#3}
\fill (\wordref{2}{\X}) ++ (0,-#4) circle(1.5pt);
\fi
}
\begin{document}
\begin{dependency}
\begin{deptext}[column sep=1em]
the \& girl \& for \& wh- \& om \& the \& man \& bought \& the \& book\\
A \& O \& U \& U \& O \& A \& O \& I \& A \& O\\
\end{deptext}
\Connect{1}{2}{1}{$\overleftarrow{O}$}
\Connect{4}{2}{6}{$\overleftarrow{O}$}
\Connect{4}{3}{1}{$\overleftarrow{O}$}
\end{dependency}
\end{document}
ADDENDUM: This is an experimental version that draws arcs over intersections. As you can see, there are quite a number of \typeout
s and this is by far not perfect, but perhaps a start. To be more precise, the arcs won't be drawn whenever one of the following criteria is met:
- The first path starts where the second path starts or ends.
- The first path ends where the second path starts or ends.
- The paths have the same level (=3rd parameter of the macro
\Connect{4}{3}{1}
).
It is easy to see that if any of those criteria are met, there is a great chance that there shouldn't be an arc, but the following two paths won't have an arc either:
******************
| | |
*---*-*
| |
*-*
It is possible, though cumbersome, to close this loophole also. Depending on whether this will really also get used somewhere, I may pick up enough motivation to do that and also to make the macros more TikZy, i.e. work with pgfkeys.
\documentclass[border=3.14mm,standalone]{standalone}
\usepackage{mathtools}
\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}[5][]{
\stepcounter{depaths}%\typeout{new\space path\space\thedepaths}
\draw[name path=dep connect \thedepaths-tmp](\wordref{2}{#2}) -- ++ (0,-#4) coordinate (aux-\thedepaths-1) -|
(\wordref{2}{#3}) coordinate[pos=0.5] (aux-\thedepaths-2);
\draw[-latex,shorten >=1pt] (aux-\thedepaths-1) -- (aux-\thedepaths-2);
\ifnum#3>#2
\node[anchor=south east] at (aux-\thedepaths-2) {#5};
\else
\node[anchor=south west] at (aux-\thedepaths-2) {#5};
\fi
\foreach \X in {1,...,#4}
{\fill (\wordref{2}{#2}) ++ (0,-\X) circle(1.5pt);
\fill (\wordref{2}{#3}) ++ (0,-\X) circle(1.5pt);}
\pgfmathtruncatemacro{\DeltaX}{abs(#3-#2)}
\ifnum\DeltaX>1
\foreach \X in {#2,...,#3}
\fill (\wordref{2}{\X}) ++ (0,-#4) circle(1.5pt);
\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
\node[circle,fill=white,outer sep=0pt,minimum size=10pt] (aux-int) at (intersection-1){};
\draw (aux-int.south) -- (aux-int.north);
\draw[white,double=black] (aux-int.west) to[out=60,in=120] (aux-int.east);
%\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}}
\else
\xdef\LstPaths{\LstPaths,{\thedepaths,#2,#3,#4}}
\fi
}
\begin{document}
\begin{dependency}
\begin{deptext}[column sep=1em]
the \& marmot \& for \& wh- \& om \& the \& duck \& bought \& the \& cake\\
A \& O \& U \& U \& O \& A \& O \& I \& A \& O\\
\end{deptext}
\Connect{1}{2}{1}{$\overleftarrow{O}$}
\Connect{4}{2}{6}{$\overleftarrow{O}$}
\Connect{3}{8}{4}{$\overleftarrow{3}$}
\Connect{5}{3}{1}{$\overleftarrow{O}$}
\end{dependency}
\end{document}