Debian Codegraph @

texmf-dist/doc/latex/movement-arrows/movement-arrows.tex

raw
1 % !TEX TS-program = LuaLaTeXmk
2
3 \documentclass[11pt]{article}
4 \usepackage{calc}
5 \usepackage{fontspec}
6 \usepackage[margin=.75in]{geometry}
7 \usepackage{titling}
8 \usepackage{array, booktabs,tabularx}
9 \usepackage{enumitem}
10 \usepackage{fancyvrb}
11 \usepackage{listings}
12 \usepackage{url}
13 \usepackage[sf,small]{titlesec}
14 \usepackage[section]{placeins}
15 \usepackage[colorlinks=true]{hyperref}
16 \setmonofont{Inconsolatazi4}
17 \usepackage{gb4e}
18 \usepackage{movement-arrows}
19 \usepackage{parskip}
20
21 \DefineShortVerb{\|}
22 \title{The \texttt{movement-arrows} package}
23 \author{Alan Munn\\[email protected]}
24 \date{Version 2.0\\June 2, 2023}
25
26 \lstset{%
27 basicstyle=\ttfamily\small,
28 commentstyle=\itshape\ttfamily\small,
29 showspaces=false,
30 showstringspaces=false,
31 breaklines=true,
32 breakautoindent=true,
33 aboveskip=\baselineskip,
34 language=TeX,
35 frame=tl,
36 }
37
38 \newcommand*{\pkg}[1]{\texttt{#1}}
39 \newcolumntype{t}[1]{>{\ttfamily}#1}
40 \newcolumntype{T}{>{\ttfamily}c}
41 \newcommand*{\bs}{\textbackslash}
42 \setlength{\droptitle}{-1in}
43 \renewcommand{\abstractname}{\sffamily Abstract}
44
45
46
47 \begin{document}
48 \maketitle
49 \thispagestyle{empty}
50 \begin{abstract}{\noindent
51 The |movement-arrows| package supplies simple support for drawing arrows between elements in text or math. Its origin comes from linguistics, where drawing arrows between words is often used as an indication that the word or phrase has moved, hence the package name. Because of this origin, the package is aware of the main linguistics packages for example sentences and can be used with those packages, but does not require you to use of any of them. Arrows can also be annotated with labels. The package uses TikZ as a base, and various properties of the arrows can be adjusted using TikZ styles. The package has been tested with the \pkg{gb4e}, \pkg{linguex}, \pkg{covington} and \pkg{ExPex} example packages.
52 }
53 \end{abstract}
54
55 \section{Basic usage}
56 The way the package works is that you mark words in text using the |\mkword| macro and then use the |\mvarrow| or |\mvlink| macro to connect the words. Here's a simple example:
57
58 \begin{quote}
59 \begin{lstlisting}
60 \documentclass{article}
61 \usepackage{movement-arrows}
62 \mkword{Where} did this move from \mkword{t}?
63 \mvarrow{t}{Where}
64 \end{lstlisting}
65 \mkword{Where} did this move from \mkword{t}?
66 \mvarrow{t}{Where}
67 \end{quote}
68
69 \section{Package commands}
70 \begin{table}[htpb]
71 \centering
72 \begin{tabularx}{\textwidth}{t{l}X}
73 \toprule
74 \bs mkword[<name>]\{<word>\} & marks a word or phrase for arrow placement; if \pkg{word} is a single word with no formatting, \pkg{name} will be set to \pkg{word}. If \pkg{word} is a phrase or contains formatting, a \pkg{name} must be given.\\
75 \bs mvarrow[<options>]\{<start>\}\{<end>\} & add an arrow between start and end nodes defined with \pkg{\bs mkword}. \pkg{\bs mvarrow*} draws an arrow above the words.\\
76 \bs mvlink[<options>]\{<start>\}\{<end>\} & add a link (no arrows) between start and end nodes. \pkg{\bs mvlink*} draws an link above the words. \\
77 \bs setarrowstyle\{<style>\} & sets the arrow style; any regular TikZ arrow can be used.\\
78 \bs arrowheight & length for the depth that the vertical line of the arrow drops/raises.\\
79 \bs extraexheight & length to add more space after a line with an arrow.\\
80 \bs glarrowheight & length = sum of previous two lenghts\\
81 \bs arrowstrut & adds vertical space so that upwards links don't encroach on the previous line.\\
82 \bs arrowgloss & tells the package that an arrow appears in a glossed example.\\
83 \bottomrule
84 \end{tabularx}
85 \caption{Package commands}
86 \end{table}
87 \section{More examples}
88 The way the package works is that you mark words in your example sentence using the |\mkword| macro and then use the |\mvarrow| macro to connect the words. So with the following code (using \pkg{gb4e} as our example package), we can get the result in (\ref{where}). Note that you must compile the document twice to place the arrow correctly, because the package uses the TikZ |[remember picture]| function.
89
90
91 \begin{quote}
92 \begin{lstlisting}
93 \begin{exe}
94 \ex \mkword{Where} did this move from \mkword{t}?
95 \mvarrow{t}{Where}
96 \end{exe}
97 \end{lstlisting}
98 \end{quote}
99
100 \begin{exe}
101 \ex \mkword{Where} did this move from \mkword{t}?
102 \mvarrow{t}{Where}
103 \label{where}
104 \end{exe}
105
106 This is the simplest use of the |\mkword| macro: it automatically creates a node with the same name as the word. This only works, however, if the word is a single word with no other formatting.
107
108 For example, if instead of representing traces with \emph{t} we use copies or a subscripted trace, we need to explicitly state the node name in the optional argument of |\mkword|. Here’s a revised example:
109 \begin{quote}
110 \begin{lstlisting}
111 \begin{exe}
112 \ex \mkword[Where]{Where\textsubscript{i}} did
113 this move from \mkword[t]{t\textsubscript{i}}?
114 \mvarrow{t}{Where}
115 \end{exe}
116 \end{lstlisting}
117 \end{quote}
118
119 \begin{exe}
120 \ex \mkword[Where]{Where\textsubscript{i}} did this move from \mkword[t]{t\textsubscript{i}}?
121 \mvarrow{t}{Where}
122 \label{where2}
123 \end{exe}
124 \subsection{Adding labels}
125 The optional argument can be used to add a label to an arrow. There are three built-in label styles: |circ| produces a circled label centred on the line itself. |above| and |below| place an uncircled label above or below the line respectively. Other styles can be created by the user if needed. The |circ| style is defined as follows:
126
127 \begin{quote}
128 \begin{lstlisting}
129 \tikzset{
130 circ/.style = {
131 draw,circle,solid,
132 node contents=#1,
133 fill=white,
134 inner xsep=.2em,
135 inner ysep=0pt,
136 }}
137 \end{lstlisting}
138 \end{quote}
139
140 So to add a circled number “1” to the previous example we add |circ=1|. To add an uncircled label above the arrow we can use |above=1|.
141
142 \begin{quote}
143 \begin{lstlisting}
144 \begin{exe}
145 \ex \mkword[Where]{Where\textsubscript{i}} did
146 this move from \mkword[t]{t\textsubscript{i}}?
147 \mvarrow[circ=1]{t}{Where}
148 \mvarrow*[above=1]{t}{Where}
149 \end{exe}
150 \end{lstlisting}
151 \end{quote}
152
153 \begin{exe}
154 \arrowstrut
155 \ex \mkword[Where]{Where\textsubscript{i}} did
156 this move from \mkword[t]{t\textsubscript{i}}?
157 \mvarrow[circ=1]{t}{Where}
158 \mvarrow*[above=1]{t}{Where}
159
160 \end{exe}
161
162 \subsection{Glossed linguistic examples}
163 Because of the way glossing macros work, arrows that are used in glossed examples using any of the standard linguistic glossing packages must be specially marked. We do this using the |\arrowgloss| command. This should appear before the glossed example that contains the arrow. Here’s a glossed example. In this example, because we want the arrow to point in the middle of \emph{een auto}, since it’s a phrase that has moved, we need to manually adjust the spacing between \emph{a} and \emph{car} in the gloss line. Alternatively we could just use either \emph{een} or \emph{auto} as the marked node and then no adjustment would be needed.
164
165 For sample documents using each of the four linguistics example packages, please visit the \href{https://github.com/amunn/movement-arrows/}{GitHub repository}.
166
167 \begin{quote}
168 \begin{lstlisting}
169 \begin{exe}
170 \ex
171 \begin{xlist}
172 \ex{\arrowgloss
173 \gll\ldots dat Jan \mkword[een]{een auto} gisteren \mkword{t} gekregen heeft.\\
174 \ldots that John {a \hspace*{1em} car} yesterday t gotten has \\
175 \ldots that John a car yesterday.}
176 \mvarrow{t}{een}
177 \ex \mkword{Where} did this move from \mkword{t}?
178 \mvarrow[circ=1]{t}{Where}
179 \ex Another example.
180 \end{xlist}
181 \end{exe}
182 \end{lstlisting}
183 \end{quote}
184
185 \begin{exe}
186 \ex
187 \begin{xlist}
188 \ex{\arrowgloss
189 \gll\ldots dat Jan \mkword[een]{een auto} gisteren \mkword{t} gekregen heeft.\\
190 \ldots that John {a \hspace*{1em} car} yesterday t gotten has \\
191 \ldots that John a car yesterday.}
192 \mvarrow{t}{een}
193 \ex \mkword{Where} did this move from \mkword{t}?
194 \mvarrow[circ=1]{t}{Where}
195 \ex Another example.
196 \end{xlist}
197 \end{exe}
198
199 \subsection{Adding colour or changing the line style}
200 The package uses TikZ styles to style the arrow and the label. The label style |circ| can be modified by using adding parameters directly. The arrow style can be modified by using |\tikzset{link/.append style={...}|. Here is some examples of both usages.
201
202 \begin{quote}
203 \begin{lstlisting}
204 \begin{exe}
205 \tikzset{link/.append style={{red,dashed,very thick}}}
206 \ex \mkword[Where]{Where\textsubscript{i}} did
207 this move from \mkword[t]{t\textsubscript{i}}?
208 \mvarrow[cyan,circ=1]{t}{Where}
209 \end{exe}
210 \end{lstlisting}
211 \end{quote}
212
213
214 \begin{exe}
215 \tikzset{link/.append style={{red,dashed,very thick}}}
216 \ex \mkword[Where]{Where\textsubscript{i}} did
217 this move from \mkword[t]{t\textsubscript{i}}?
218 \mvarrow[cyan,circ=1,thin]{t}{Where}
219 \end{exe}
220
221 The arrow style itself can be changed using the |\setarrowstyle| command. The default arrow style is |->|; to use the |-latex| arrow style, you can use |\setarrowstyle{-latex}|. Any arrow style defined by TikZ is a useable style.
222
223 \subsection{Multiple arrows on one example}
224 If we want to have more than arrow on a single example, it may make sense to have them offset from one another. The position of the labels may also need to be manually adjusted. This is quite easy to do. The length of the vertical line in the arrow is set by the length |\arrowheight|. The position of the label can be moved by adding a |xshift| value. Here’s an example:
225
226 \begin{quote}
227 \begin{lstlisting}
228 \begin{exe}
229 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>} moved?
230 \mvarrow[circ=1,xshift=1em]{thas}{has}
231 \setlength{\arrowheight}{4.5ex}
232 \mvarrow[circ=2]{twh}{What}
233 \end{exe}
234 \end{lstlisting}
235 \end{quote}
236
237 \begin{exe}
238 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>} moved?
239 \mvarrow[circ=1,xshift=1em]{thas}{has}
240 \setlength{\arrowheight}{4.5ex}
241 \mvarrow[circ=2]{twh}{What}
242 \end{exe}
243
244 For examples like this, some manual vertical spacing may be needed to prevent subsequent lines of text from overlapping the arrow.
245
246 \subsection{Arrows on top of words}
247 The starred version of |\mvarrow|, |\mvarrow*| will draw the arrow above the words rather than the default position below the words. Here’s the previous example using a combination of over- and under-arrows. The |\arrowstrut| command before the example add some vertical space so that the upwards arrow doesn't overlap the preceding text.
248
249 \begin{quote}
250 \begin{lstlisting}
251 \begin{exe}
252 \arrowstrut
253 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>}
254 moved?
255 \mvarrow[circ=1]{thas}{has}
256 \mvarrow*[circ=2]{twh}{What}
257 \end{exe}
258 \end{lstlisting}
259 \end{quote}
260
261 \begin{exe}
262 \arrowstrut
263 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>}
264 moved? \mvarrow[circ=1]{thas}{has} \mvarrow*[circ=2]{twh}{What}
265 \end{exe}
266 \clearpage
267 \subsection{Using with ExPex}
268 The ExPex glossing macros work differently from \pkg{gb4e}, \pkg{linguex}, and \pkg{covington}, and so certain things need to be done slightly differently. Here's an example using ExPex:
269
270 \begin{quote}
271 \begin{lstlisting}
272 \pex
273 \a\arrowgloss
274 \begingl[aboveglbskip=\glarrowheight]
275 \gla \ldots dat Jan \mkword[een]{een auto} gisteren \mkword{t} gekregen heeft.//
276 \glb \ldots that John {a\hspace*{1em} car} yesterday t gotten has//
277 \glft \ldots that John got a car yesterday.
278 \mvarrow[circ=1]{t}{een}//
279 \endgl
280 \end{lstlisting}
281 \end{quote}
282
283 There are two important things to note here. First, in the gloss that contains the arrow you need to set |aboveglbskip=\glarrowheight| to leave enough room for the arrow. Secondly, the |\mvarrow| command itself should appear \emph{inside} the |\glft| line rather than outside of that line, i.e., it should appear before the |//| delimiter of the line.
284 \subsection{Using with \pkg{covington}}
285 When using the package with the \pkg{covington} glossing macros, you need to make sure that the |\mvarrow| command is \emph{inside} the last line of gloss set:
286
287 \begin{quote}
288 \begin{lstlisting}
289 \begin{subexamples}
290 \item\arrowgloss\digloss
291 {\ldots dat Jan \mkword[een]{een auto} gisteren \mkword{t} gekregen heeft.}
292 {\ldots that John {a \hspace*{1em} car} yesterday t gotten has}
293 {\ldots that John a car yesterday.\mvarrow{t}{een}}
294 \end{subexamples}
295 \end{lstlisting}
296 \end{quote}
297
298 \section{Links without arrows}
299 All of the |\mvarrow| commands have an alternative version |\mvlink| which simply links the words with no arrows.
300
301 \begin{quote}
302 \begin{lstlisting}
303 \begin{exe}
304 \arrowstrut
305 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>}
306 moved?
307 \mvlink[circ=1]{thas}{has}
308 \mvlink*[circ=2]{twh}{What}
309 \end{exe}
310 \end{lstlisting}
311 \end{quote}
312
313 \begin{exe}
314 \arrowstrut
315 \ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>}
316 moved?
317 \mvlink[circ=1]{thas}{has}
318 \mvlink*[circ=2]{twh}{What}
319 \end{exe}
320
321
322
323 \section{Version history}
324 The first version of this package was written in 2017, but never released publicly. The use of the \pkg{tikz-extra} package |paths.ortho| allowed for the current code to be massively simplified and allowed version 1.0 to be released in May 2023, a little too fast. Version 2.0 changed the basic command name from |\arrow| to |\mvarrow| to avoid conflicts with other packages that define an |\arrow| command, and added the |\arrowgloss| and |\arrowstrut| macros for better spacing options. Bug reports and feature requests are welcome at the \href{https://github.com/amunn/movement-arrows/issues}{GitHub bug tracker}.
325 \section{Acknowledgements}
326 Thanks to the TeX Stackexchange community, from whom I have learned many things, especially about TikZ. The earliest version of the package used code created by user Jake in response to \href{https://tex.stackexchange.com/q/55068/}{a question} I asked. This has now be superseded by the |paths.ortho| methods, but the style described there is quite useful in and of itself. I’ve also benefitted from discussions and suggestions with user percusse.
327
328
329
330
331 \end{document}