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}
{}
on it).tikz
this question and answer might be helpful. Though I personally would like to see an answer that uses the code from thegb4e
documentation, as it would be nice to learn what is actually going on there.