多年来,我一直在努力解决一个问题。我尝试从森林树中某个节点的一部分绘制箭头。由于 xelatex 中的一个错误,这不适用于包tikzmark
和子节点命令。
该主题在这里进行了讨论:
修复或替换森林中的 tikzmark/pgfmark/subnode
我太笨了,无法理解这些解决方案。有些解决方案似乎已经过时了。xelatex 中的底层错误似乎尚未修复,pdflatex 似乎也停止工作了。
我想要做的是使用双箭头连接 // 后的所有 V。这应该可以安全地复制和粘贴。我可以向左或向右移动箭头,但当我更改字体大小时,这会中断。有什么解决办法吗?当然,子节点解决方案是首选。
\documentclass{article}
\usepackage{forest}
\useforestlibrary{linguistics}
\forestapplylibrarydefaults{linguistics}
\usetikzlibrary{arrows}
\tikzset{
%Define standard arrow tip
>=stealth'}
\newcommand{\sliste}[1]{%
\mbox{%
$\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}
\begin{document}
\begin{forest}
where n children=0{tier=word}{}
[S
[{V \sliste{ S$/\!/$V }},name=vini
[V,name=vlast [liest$_j$] ] ]
[{S$/\!/$V}, name=sv
[NP [Conny] ]
[{V$'$$\!/\!/$V}, name=v1v
[NP [das Buch, roof] ]
[{V$\!/\!/$V}, name=vv [\_$_j$] ] ] ] ] ]
\path[semithick,<->,color=green] (v1v.east) edge [bend left=44] (vv.east);
\path[semithick,<->,color=green] (v1v.north east) edge [bend right=44] (sv.east);
\path[semithick,<->,color=green] (sv.north) edge [bend right=24] (vini.north);
\draw[semithick,<->,color=green] (vini.south) -- (vlast.north);
\end{forest}
\end{document}
使用有效的子节点命令后,它看起来应该像这样:
\documentclass{article}
\usepackage{tikz} \usetikzlibrary{tikzmark}
\usepackage{forest}
\useforestlibrary{linguistics}
\forestapplylibrarydefaults{linguistics}
\usetikzlibrary{arrows}
\tikzset{
%Define standard arrow tip
>=stealth'}
\newcommand{\sliste}[1]{%
\mbox{%
$\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}
\begin{document}
\begin{forest}
where n children=0{tier=word}{}
[S
[{V \sliste{ S$/\!/$\subnode{vini}{V} }},name=vinix
[V,name=vlast [liest$_j$] ] ]
[{S$/\!/$\subnode{sv}{V}}, name=svx
[NP [Conny] ]
[{V$'$$\!/\!/$\subnode{v1v}{V}}, name=v1vx
[NP [das Buch, roof] ]
[{V$\!/\!/$\subnode{vv}{V}}, name=vvx [\_$_j$] ] ] ] ] ]
\path[semithick,<->,color=green] (v1v.east) edge [bend left=44] (vv.east);
\path[semithick,<->,color=green] (v1v.north east) edge [bend right=44] (sv.east);
\path[semithick,<->,color=green] (sv.north) edge [bend right=24] (vini.north);
\draw[semithick,<->,color=green] (vini.south) -- (vlast.north);
\end{forest}
\end{document}
答案1
在以 tikz 相关的形式提出问题后,我被指出了针对类似问题的这个解决方案:
我根据自己的forest
问题进行了调整。我遇到的困难是绘图必须在 之外进行forest
,因为subnode
坐标似乎只在树之外有效。
\documentclass{article}
\usepackage[linguistics]{forest}
\forestapplylibrarydefaults{linguistics}
\usetikzlibrary{positioning, tikzmark, arrows}
\tikzset{
%Define standard arrow tip
>=stealth'}
% WORKAROUND:
% Definition copied from /usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf-via-dvi.def
% Compare https://tex.stackexchange.com/q/229500 and comments!
\makeatletter
\def\pgfsys@hboxsynced#1{%
{%
\pgfsys@beginscope%
\setbox\pgf@hbox=\hbox{%
\hskip\pgf@pt@x%
\raise\pgf@pt@y\hbox{%
\pgf@pt@x=0pt%
\pgf@pt@y=0pt%
\special{pdf: content q}%
\pgflowlevelsynccm%
\pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
\special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
\pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
\wd#1=0pt%
\ht#1=0pt%
\dp#1=0pt%
\box#1%
\pgfsys@invoke{n Q Q Q}%
}%
\hss%
}%
\wd\pgf@hbox=0pt%
\ht\pgf@hbox=0pt%
\dp\pgf@hbox=0pt%
\pgfsys@hbox\pgf@hbox%
\pgfsys@endscope%
}%
}
\makeatother
\begin{document}
\begin{forest}
where n children=0{tier=word}{}
[S
[{V S$/\!/$\subnode{vini}{V} },name=vinix
% [V,name=vlast [liest$_j$] ] ] does not work, has to be subnode
[\subnode{vlast}{V} [liest$_j$] ] ]
[{S$/\!/$\subnode{sv}{V}}, name=svx
[NP [Conny] ]
[{V$'$$\!/\!/$\subnode{v1v}{V}}, name=v1vx
[NP [das Buch, roof] ]
[{V$\!/\!/$\subnode{vv}{V}}, name=vvx [\_$_j$] ] ] ] ] ]
% \path[semithick,<->,color=green] (v1v.east) edge [bend left=44] (vv.east);
% \path[semithick,<->,color=green] (v1v.north east) edge [bend right=44] (sv.east);
% \path[semithick,<->,color=green] (sv.north) edge [bend right=24] (vini.north);
% \draw[semithick,<->,color=green] (vini.south) -- (vlast.north);
\end{forest}
\begin{tikzpicture}[remember picture, overlay]
\path[semithick,<->,color=green] (vv.north) edge [bend right=44] (v1v.east);
\path[semithick,<->,color=green] (v1v.north) edge [bend right=44] (sv.east);
\path[semithick,<->,color=green] (sv.north) edge [bend right=24] (vini.north);
\draw[semithick,<->,color=green] (vini.south) -- (vlast.north);
\end{tikzpicture}
\end{document}
tixmark prefix
请注意,当同一文档中有多个树时,此解决方案会失效。一种解决方案是在图像前放置一个声明。例如\tikzset{tikzmark prefix=fig-German-v2}
。这似乎打开了一个新的名称空间。