1

In reference to this question:

  • Movement arrow in gloss

    I have two additional questions.

    1. How can I reduce the space between the lines and the example?
    2. How can I make it work for multiple examples listed under the same number? For example, I would need to draw arrows connecting words in three examples bulleted together:

 \documentclass[12pt]{article}

 \usepackage{expex}
 \usepackage{tikz}
 \usepackage{xparse}

 \lingset{everygla=,aboveglftskip=0pt,*=?*, textoffset=!-.6em, everyglb=\footnotesize, everyglft=\slshape}

 \newcommand\Tikzmark[2]{%
 \tikz[remember picture]\node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
 }

\NewDocumentCommand\DrawArrow{O{}mmmmO{3}}{
\tikz[remember picture,overlay]
    \draw[-,straight corners,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1] 
(#2) -- ++(0,-#6\ht\strutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux) -- (#3);
}

\begin{document}

\pex
\a My name is Carl.
\b His name is John.
\c Her name is Claire.
\xe

\end{document}
RobertP.
  • 741
  • How come you're using xparse for the \DrawArrow command? – Alenanno Jul 31 '16 at 09:40
  • By the way, straight corners is not a valid option. If you meant the opposite of rounded corners, then you should write sharp corners. But even then, the command is pointless because that's the default for lines. – Alenanno Jul 31 '16 at 09:42
  • I just copied and pasted the code I found [here]{http://tex.stackexchange.com/questions/231041/how-to-use-pstricks-with-expex-to-draw-arrows-in-examples}. Thanks for clarifying that – RobertP. Jul 31 '16 at 10:03

1 Answers1

2

It's not at all clear why you used code from a question different from the one you linked to in your question. Here's a version of that code adapted for use with ExPex. The basic idea is the same, but the implementation is slightly different.

The height of the arrow is controlled by the length \arrowht; I've set it to -2.5ex but you can make it shorter by setting it to, e.g., -1.5ex.

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{expex}

\newlength{\arrowht}
\setlength{\arrowht}{-2.5ex}
\newcommand*\exdepthstrut{{\vrule height 0pt depth -\arrowht width 0pt}}
\newcommand\tikzmark[1]{\tikz[remember picture, baseline=(#1.base)] \node[anchor=base,inner sep=0pt, outer sep=0pt] (#1) {#1\exdepthstrut};}

% 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 and 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}
}
\begin{document}

\pex
\a \tikzmark{My} name is \tikzmark{Carl}.
\a 
\begingl
\gla \tikzmark{His} name is \tikzmark{John}.//
\glb His name is John//
\endgl
\a Her name is Claire.
\xe
\arrow{My}{Carl}
\arrow{His}{John}

\end{document}

output of code

Alan Munn
  • 218,180