
我試圖在 S 節點和矩陣之間畫一條線,但未能使其工作。我究竟做錯了什麼?
微量元素:
\documentclass[a4paper,12pt]{article}
\usepackage{fontspec,tikz, tikz-qtree, multicol,avm,array}
\usetikzlibrary{matrix, positioning, trees, calc, arrows, fit,tikzmark,positioning}
\begin{document}
\begin{multicols}{2}
\begin{tikzpicture}
\begin{scope}
\Tree [.\tikzmark{S}{S} [.NP [.Det the ]
[.N cat ] ]
[.VP [.V sat ]
[.PP [.P on ]
[.NP [.Det the ]
[.N; mat ] ] ] ] ]
\end{scope}
\end{tikzpicture}
\columnbreak
\begin{avm}
\scriptsize
\[{} \tikzmark{PRED}{PRED} `avoid <SUBJ, OBJ>'; TNS $\neq$ PAST \cr
TOPIC \[ PRED `kind<COMP>' \cr
DEF +; LOC FAR; NUM SG \cr
COMP \[ PRED `of <OBJ>' \cr
OBJ \[ PRED `cake'\] \] \]\tikzmark{topic} \cr
SUBJ \[ PRED `pro'; NUM SG; PERS 1; CASE NOM\] \cr
OBJ \[ $\qquad$ \]\tikzmark{object} \cr
ADJ \[ PRED `usually'\] \]
\end{avm}
\begin{tikzpicture}[remember picture,overlay]
\draw[->] (pic cs:S)--(pic cs:PRED);
\draw[-] (pic cs:topic) to[out=0,in=0,looseness=2] (pic cs:object);
\end{tikzpicture}
\end{multicols}
\end{document}
答案1
這是由於工作方式造成的tikz-qtree
。詳細的解釋可以在以下位置找到我的答案到\使用 tikz-qtree 連接節點時繪製對齊,使線居中
從該答案中剪下並貼上我的程式碼是這裡解決方案的一半。另一半是\tikzmark
從樹上移除。不幸的是,\tikzmark
遇到了與(如該答案中所解釋的)相同的問題tikz-qtree
,因此需要類似的調整。幸運的是,這不是必需的。由於 atikz-qtree
位於tikzpicture
環境內部,因此我們可以使用普通的tikz
節點標籤系統來引用 a 中的節點tikzpicture
。 (tikzmark
開髮用於外部atikzpicture
實際上不應該在內部使用,因為它會受到嵌套 tikzpicture 綜合症.)
\documentclass[a4paper,12pt]{article}
%\url{https://tex.stackexchange.com/q/219072/86}
\usepackage{fontspec,tikz, tikz-qtree, multicol,avm,array}
\usetikzlibrary{matrix, positioning, trees, calc, arrows, fit,tikzmark,positioning}
\makeatletter
\def\unwind@subpic#1{%
% is #1 the current picture?
\edef\subpicid{#1}%
\ifx\subpicid\pgfpictureid
% yes, we're done
\else
% does #1 have a parent picture?
\expandafter\ifx\csname pgf@sh@pi@#1\endcsname\relax
% no, the original node was not inside the current picture
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\pgfsys@getposition{\pgfpictureid}\pgf@shape@current@pos
\pgf@process{\pgfpointorigin\pgf@shape@current@pos}%
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
\pgf@process{\pgfpointorigin\subpic@parent@pos}%
\advance\pgf@xa by \pgf@x%
\advance\pgf@ya by \pgf@y%
\pgf@x=\pgf@xa
\pgf@y=\pgf@ya
\else
% yes, apply transform, save picture location, and move up to parent picture
\pgfsys@getposition{\csname pgf@sh@pi@#1\endcsname}\subpic@parent@pos%
{%
\pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
\pgf@pos@transform{\pgf@x}{\pgf@y}%
\global\pgf@x=\pgf@x
\global\pgf@y=\pgf@y
}%
\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}%
\fi
\fi
}
\def\pgf@shape@interpictureshift#1{%
\def\subpic@parent@pos{\pgfpointorigin}%
\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}%
}
\makeatother
\begin{document}
\begin{multicols}{2}
\begin{tikzpicture}[remember picture]
\begin{scope}
\Tree [. \node (S) {S}; [.NP [.Det the ]
[.N cat ] ]
[.VP [.V sat ]
[.PP [.P on ]
[.NP [.Det the ]
[.N; mat ] ] ] ] ]
\end{scope}
\end{tikzpicture}
\columnbreak
\begin{avm}
\scriptsize
\[{} \tikzmark{PRED}{PRED} `avoid <SUBJ, OBJ>'; TNS $\neq$ PAST \cr
TOPIC \[ PRED `kind<COMP>' \cr
DEF +; LOC FAR; NUM SG \cr
COMP \[ PRED `of <OBJ>' \cr
OBJ \[ PRED `cake'\] \] \]\tikzmark{topic} \cr
SUBJ \[ PRED `pro'; NUM SG; PERS 1; CASE NOM\] \cr
OBJ \[ $\qquad$ \]\tikzmark{object} \cr
ADJ \[ PRED `usually'\] \]
\end{avm}
\begin{tikzpicture}[remember picture,overlay]
\draw[->] (S)--(pic cs:PRED);
\draw[-] (pic cs:topic) to[out=0,in=0,looseness=2] (pic cs:object);
\end{tikzpicture}
\end{multicols}
\end{document}
答案2
切換到 pdfLaTeX 後即可使用。為此,需要fontspec
從已載入的包中刪除。
使用 XeLaTeX 我注意到問題仍然存在。