구문 트리와 행렬 사이의 Tikzmark?

구문 트리와 행렬 사이의 Tikzmark?

S 노드와 행렬 사이에 선을 그리려고 하는데 작동하지 못했습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

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}

답변1

이는 작동 방식 때문입니다 tikz-qtree. 긴 설명은 다음에서 확인할 수 있습니다.내 대답에게\tikz-qtree를 사용하여 노드를 연결할 때 정렬 그리기, 선 중심 맞추기

해당 답변에서 내 코드를 잘라내어 붙여넣는 것이 여기서 해결 방법의 절반입니다. 나머지 절반은 \tikzmark나무에서 제거하는 것입니다. 불행히도 (해당 답변에 설명된 대로) \tikzmark동일한 문제가 있으므로 tikz-qtree비슷한 조정이 필요합니다. 다행히도 이것은 필요하지 않습니다. a는 환경 tikz-qtree내부에 있으므로 tikzpicture일반 tikz노드 레이블 지정 시스템을 사용하여 a의 노드를 참조 할 수 있습니다 tikzpicture. ( tikzmark개발되었습니다밖의a tikzpicture실제로 내부에서 사용하면 안 됩니다.중첩된 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를 사용하면 문제가 지속되는 것으로 나타났습니다.

관련 정보