
Ich versuche, eine Linie zwischen dem S-Knoten und der Matrix zu zeichnen, aber es funktioniert nicht. Was mache ich falsch?
MWE:
\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}
Antwort1
Dies liegt an der Funktionsweise tikz-qtree
. Die ausführliche Erklärung finden Sie untermeine AntwortZu\draw-Ausrichtung beim Verbinden von Knoten mit tikz-qtree, Linienzentrierung
Das Ausschneiden und Einfügen meines Codes aus dieser Antwort ist hier die Hälfte der Lösung. Die andere Hälfte besteht darin, den \tikzmark
aus dem Baum zu entfernen. Leider \tikzmark
leidet unter demselben Problem wie der tikz-qtree
(wie in dieser Antwort erklärt), sodass eine ähnliche Anpassung erforderlich wäre. Glücklicherweise ist dies nicht erforderlich. Da sich ein tikz-qtree
in einer Umgebung befindet , können wir das normale Knotenbeschriftungssystem tikzpicture
verwenden, um auf Knoten in einem zu verweisen . ( wurde entwickelt fürtikz
tikzpicture
tikzmark
draußena tikzpicture
und sollte eigentlich nicht im Innenbereich verwendet werden, da es dann unter derverschachteltes Tikzpicture-Syndrom.)
\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}
Antwort2
Es funktioniert, nachdem Sie zu pdfLaTeX gewechselt sind. Dazu ist es erforderlich, es fontspec
aus den geladenen Paketen zu entfernen.
Bei XeLaTeX ist mir aufgefallen, dass das Problem weiterhin besteht.