12

This question led to a new package:
movement-arrows

Is it possible in gb4e to gloss an example AND have a movement arrow in the example.

I'm currently using gb4e, and I want an arrow from 't' to 'een auto'. I already looked at other packages (xytree, tikz), but I found no way to do this

\documentclass[11pt]{article}
\usepackage{gb4e}

\begin{document}

\begin{xlist}
        \ex \label{scramble-det}
        \gll 
        ... dat Jan een auto gisteren t gekregen heeft.\\
        ... that John a car  yesterday t gotten has \\
        ... that John a car yesterday.
\end{xlist}
\end{document}

The following, as an example, is taken from the gb4e documentation, but I don't understand it at and therefore cannot modify it to suit my needs:

enter image description here

2
  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with {} on it).
    – Adam Liter
    Oct 22, 2013 at 18:26
  • If you're interested in using tikz this question and answer might be helpful. Though I personally would like to see an answer that uses the code from the gb4e documentation, as it would be nice to learn what is actually going on there.
    – Adam Liter
    Oct 22, 2013 at 20:12

2 Answers 2

13

Update:

Please use the packaged version of the answer shown in my other answer.

Original answer

Here's a way to do this using my version of the popular tikzmark macro, since the gb4e version of arrows is very cumbersome to use. If you need the real \tikzmark for some other purpose, you'll need to change the name of the macro in my code.

Mainly this puts together bits of code from various sources. There are two issues to be solved: first connecting words in the gloss with arrows and second, adding some space after the gloss for the arrow to exist in.

I've created a new \ex macro \arrowex which is for an example that will have an arrow. Each word that you want to connect with an arrow gets introduced with the \tikzmark command. The node names will be the same as the word itself. Finally, the \arrow macro connects the words.

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand\tikzmark[1]{\tikz[remember picture, baseline=(#1.base)] \node[anchor=base,inner sep=0pt, outer sep=0pt] (#1) {#1};}

% This code from http://tex.stackexchange.com/q/55068/2693
\tikzset{
    ncbar angle/.initial=90,
    ncbar/.style={
        to path=(\tikztostart)
        -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
        -- (\tikztotarget)
    },
    ncbar/.default=0.5cm,
}

% Thanks to Paul Gessler adn Percusse for code improvement here
\newcommand{\arrow}[2]{\begin{tikzpicture}[remember picture,overlay]
\draw[->,shorten >=3pt,shorten <=3pt] (#1.base) to [ncbar=\arrowht] (#2.base);
\end{tikzpicture}
\setlength{\arrowht}{0ex}
}
\usepackage{gb4e}
% The following code modified from 
% http://permalink.gmane.org/gmane.comp.tex.linguistics/1036
% This adds some extra space after the first line
\newlength{\arrowht}
\setlength{\arrowht}{0ex}
\newcommand*\cgdepthstrut{{\vrule height 0pt depth \arrowht width 0pt}}
\renewcommand\eachwordone{\cgdepthstrut\rmfamily}
\renewcommand\glt{\vskip -\topsep}
\let\trans=\glt
\newcommand\arrowex{\setlength{\arrowht}{2.5ex}\ex}


\begin{document}
\begin{exe}
\ex\label{scramble-det}
\begin{xlist}
        \arrowex 
        \gll 
        \ldots dat Jan \tikzmark{een} auto gisteren \tikzmark{t}  gekregen heeft.\\
        \ldots that John a car  yesterday t gotten has \\
        \ldots that John a car yesterday.
        \arrow{t}{een}
\end{xlist}
\end{exe}

\begin{exe}
\ex\label{scramble-det}
\begin{xlist}
        \ex 
        \gll 
        \ldots dat Jan een auto gisteren t gekregen heeft.\\
        \ldots that John a car  yesterday t gotten has \\
        \ldots that John a car yesterday.
\end{xlist}
\end{exe}
\end{document}

output of code

6
  • Nice. One minor nitpick: the OP wanted an arrow from 't' to 'een auto', not just 'een', I believe. :-)
    – Adam Liter
    Oct 22, 2013 at 20:23
  • 1
    @Adam Picky. The simplest fix is to use \arrow{t}{een.east} instead.
    – Alan Munn
    Oct 22, 2013 at 20:29
  • Cool! Thanks a million! Just for future reference: is it also possible to have a movement arrow above the sentence? If so, how?
    – krowland
    Oct 22, 2013 at 22:02
  • It's possible, but not trivial; I'd need to rewrite the code quite a bit, which I don't have time for at the moment.
    – Alan Munn
    Oct 22, 2013 at 22:14
  • 3
    I'm starting to smell a new package here.
    – Alan Munn
    Oct 22, 2013 at 22:22
6

Finally I have made good on my comment, and have turned my original answer into a package. The underlying code is different, and the package allows both over- and under-arrows, so I'm adding a separate answer. The package also adds the possibility of circled labels, in response to this question:

Here's a sample document showing some of what it can do.

\documentclass[11pt]{article}

\usepackage{gb4e}
\usepackage{movement-arrows}
\begin{document}
\begin{exe}
\ex
\begin{xlist}
\ex{
\arrowgloss\gll\ldots dat Jan \mkword[een]{een auto} gisteren \mkword{t}  gekregen heeft.\\
\ldots that John {a \hspace*{1em} car}  yesterday t gotten has \\
\ldots that John a car yesterday.}
\mvarrow{t}{een}
\ex  \mkword{Where} did this move from \mkword{t}?
\mvarrow[circ=1]{t}{Where}
\ex Another example.
\end{xlist}
\end{exe}

\begin{exe}
\ex
\begin{xlist}
\ex This \mkword{is} not \mkword[t]{<be>} verb movement.
\mvarrow{t}{is}
\ex It  \mkword{PRES} not \mkword[be]{be} verb lowering.
\mvarrow[circ=2]{PRES}{be}
\end{xlist}
\end{exe}

\begin{exe}
\arrowstrut
\ex \mkword{What} \mkword{has} \mkword[twh]{<what>} \mkword[thas]{<has>}
moved? 
\mvarrow[circ=1]{thas}{has} 
\mvarrow*[circ=2]{twh}{What}
\end{exe}

\end{document}

output of code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .