关于这个问题:
我有两个问题:
- 我的后退箭头太靠下(参见示例 1)。
- 到目前为止,我的注释已经减少了(参见示例 1 中的“[VF”)。
因此我有一个半问题:
- 我怎样才能将向后箭头改为位于文本下方(以便两个箭头相等)?
- 针对问题 1 的修改能解决我的问题 2 吗?
感谢您的关注。
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{gb4e}
\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 https://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}
\begin{exe}
\ex Example 1
\gll ~\tikzmark{lachend} ~sagte sie \tikzmark{t} das\\
[VF ][LSK][ MF {} {} ]\\
\arrow{t}{lachend}
\ex Example 2
\gll und ~hob sie t ~~auf schrecklich weinend\\
{} [LSK][ MF \tikzmark{t} ][RSK][ \tikzmark{NF} {} ]\\
\arrow{t}{NF}
\end{exe}
\end{document}
答案1
编辑:
过了一会儿,我发现问题的根源在于 的定义\exdepthstrut
。随着高度和深度的变化,以及箭头锚点的相应变化,我得到了以下结果:
修正后的 MWE 为:
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{gb4e}
\newlength{\arrowht}
\setlength{\arrowht}{-2.5ex}% <-- changed
\newcommand*\exdepthstrut{{\vrule height 0.75\arrowht depth -0.25\arrowht width 0pt}}% <-- changed
\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=\arrowht,% <-- changed
}
% Thanks to Paul Gessler and Percusse for code improvement here
\newcommand{\arrow}[2]{\begin{tikzpicture}[remember picture,overlay]
\draw[->,shorten >=1ex,shorten <=1ex] ([yshift=1.25ex] #1.south) to [ncbar] ([yshift=1.25ex] #2.south);% <-- changed
\end{tikzpicture}
}
\begin{document}
\begin{exe}
\ex Example 1
\gll ~\tikzmark{lachend} ~sagte sie \tikzmark{t} das\\
~[VF ][LSK][ MF {} {} ]\\
\arrow{t}{lachend}
\ex Example 2
\gll und ~hob sie t ~~auf schrecklich weinend\\
{} [LSK][ MF \tikzmark{t} ][RSK][ \tikzmark{NF} {} ]\\
\arrow{t}{NF}
\end{exe}
\end{document}