关于这个问题:
-
我还有两个问题。
- 我怎样才能减少线条和示例之间的空间?
- 如何让它适用于同一编号下列出的多个示例?例如,我需要绘制箭头连接三个示例中的单词:
\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}
答案1
完全不清楚为什么您使用的代码与您在问题中链接的代码不同。这是该代码的一个版本,适用于 ExPex。基本思想是相同的,但实现略有不同。
箭头的高度由长度控制\arrowht
;我将其设置为,-2.5ex
但您可以将其设置为使其更短,例如-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}