[Tex/LaTex] Movement arrow in gloss

gb4elinguistics

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

Best 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

Related Question