Here's an example using the movement-arrows
package which provides a \mkword
macro to mark text and give it a node name. Then I've created a \link
macro which links the speaker labels. I've made the text itself a tabular.
\spkr{<name>}{<subscript>}
The \spkr
macro defined here takes two arguments. The second argument is the subscript, and the first argument is the text. Underlyingly this uses the \mkword
macro and creates a referrable node composed of the name and the subscript number. The name cannot contain any markup; if you need that, you will need to use the \mkword
macro directly.
\link[depth]{<node 1>}{<node 2>}
The \link
macro links two nodes previously defined with \spkr
(or \mkword
) and links them with a depth of <depth>
.
The \maxlink
length is an adjustment factor so that the links don't bleed into the left margin.
This solution still requires quite a bit of manual formatting. So for small examples it works quite well, but automating it would require quite a bit more work.
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{movement-arrows}
\newlength{\maxlink}
\setlength{\maxlink}{2em}% extra space for links
\newcommand\spkr[2]{\mkword[#1#2]{#1\sb#2}}
\newcommand\link[3][1em]{\tikz[overlay,remember picture]{\draw(#2.west) -|-[distance=-#1] (#3.west);}}
\usepackage{tabularx}
\usepackage{array}
\newcolumntype{s}{@{}>{\hspace{\maxlink}}r}
\newcolumntype{t}{>{: ``}X<{''}}
\let\sb\textsubscript
\begin{document}
\begin{tabularx}{\linewidth}{slt}
\spkr{A}{1} & to trainman in station & Have you got the time? \\
\spkr{B}{2} & & Standard or Daylight Savings?\\
\spkr{A}{3} & & What are you running on?\\
\spkr{B}{3} & & Standard.\\
\spkr{A}{2} & & Standard then.\\
\spkr{B}{1} & & It's five o'clock.
\end{tabularx}
\link[3em]{A1}{B1}
\link[2em]{A2}{B2}
\link[1em]{A3}{B3}
\end{document}
