在森林节点周围的 Tikz 框之间绘制箭头(带 MWE + 截图)

在森林节点周围的 Tikz 框之间绘制箭头(带 MWE + 截图)

我正在使用 MacTeX/TeXLive 2021、最新版本的 TeXStudio 和 Latexmk。

我想在下图中从绿色框到紫色框画一个箭头。它将替换当前从绿色框代码所在的节点到紫色框代码所在的节点的粉色箭头。(我希望它从绿色框到紫色框到 -170:3 厘米。箭头不在任何一个框内 - 只是从绿色框到紫色框。)MWE 包含在图像下方。

MWE 当前结果的截图

梅威瑟:

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\setlength{\parindent}{0em}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pifont}
\usepackage{libertine}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{MnSymbol}
\usepackage[hidelinks]{hyperref}
\usepackage{ulem}

\newcommand{\xbar}[1]{\ensuremath{\overline{\textrm{#1}}}}

\usepackage[table,dvipsnames]{xcolor}

\usepackage{graphicx}

%%% Trees
\usepackage[linguistics]{forest}
\usepackage{tikz}
\usetikzlibrary{fit,arrows.meta,arrows,shapes.geometric,decorations.markings,decorations.pathreplacing,positioning}

\begin{document}
    
\hspace*{-4em}\scalebox{.7}{\begin{forest}
        for tree={s sep=7mm, inner sep=0, l*=1.75}
        [... \\ CP [VP,fit=band,name=frontedVP,tikz={\node (frontedVP) [draw,thick,RoyalPurple,inner sep=1.5mm,fit to=tree,name=frontedVP]{};} [VP [V \\ blah] [DP [D \\ $\varnothing$] [N \\ blahh]]] [VP [PP [blah blah,roof]] [VP [PP [\sout{blah blah blah blah},roof]] [VP [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]]]]] [CP [\xbar{C} [C \\ $\varnothing$] [TP [DP [D \\ blah] [N \\ $\varnothing$]] [\xbar{T} [T \\ abc \\ $+$\textsc{blah}] [$\langle$VP$\rangle$,fit=band,name=VPprefronting,tikz={\node (VPprefronting) [draw,thick,PineGreen,inner sep=1.5mm, fit to=tree,name=VPprefronting]{};} [VP,name=firstmovedvp [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]] [VP [PP [\sout{blah blah},roof]] [VP [$\langle$PP$\rangle$ [\sout{blah blah blah blah},roof,name=extraposedbase]] [VP,name=lowvp [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]]]]]]]] [PP [blah blah blah blah,roof,name=extraposedsurface]]]]
        \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},blue] (lowvp)..controls +(south east:14cm) and +(south west:11cm)..(firstmovedvp);
        \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},blue] (extraposedbase)..controls +(-60:9cm) and +(-35:22cm)..(extraposedsurface);
        \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},Magenta] (VPprefronting)..controls +(-160:12cm) and +(-95:15cm)..(frontedVP);
\end{forest}}
    
\end{document}

太感谢了!

答案1

向树前言中添加内容draw tree tikz processing order/.nodewalk style=tree children-first。为什么?森林首先绘制节点,然后是它们的边,然后是tikz附加到节点的任何附加命令;默认情况下,它通过深度优先、子节点优先的树遍历来完成此操作。但是,这意味着我们试图在fit创建这些框之前绘制 ted 框之间的箭头(即使箭头的代码最后给出,我们也会在根节点的上下文中绘制箭头;并且合适的框显然是在 VP 处绘制的)。建议在前言中添加的内容将顺序更改为子节点优先(对于添加tikz),因此框在箭头之前绘制,一切正常。(下面,我还删除了冗余的节点name。)

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\setlength{\parindent}{0em}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pifont}
\usepackage{libertine}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{MnSymbol}
\usepackage[hidelinks]{hyperref}
\usepackage{ulem}

\newcommand{\xbar}[1]{\ensuremath{\overline{\textrm{#1}}}}

\usepackage[table,dvipsnames]{xcolor}

\usepackage{graphicx}

%%% Trees
\usepackage[linguistics]{forest}
\usepackage{tikz}
\usetikzlibrary{fit,arrows.meta,arrows,shapes.geometric,decorations.markings,decorations.pathreplacing,positioning}

\begin{document}
    
\hspace*{-4em}\scalebox{.7}{\begin{forest}
    for tree={s sep=7mm, inner sep=0, l*=1.75},
    draw tree tikz processing order/.nodewalk style=tree children-first,
    [... \\ CP [VP,fit=band,tikz={\node (frontedVP) [draw,thick,RoyalPurple,inner sep=1.5mm,fit to=tree]{};} [VP [V \\ blah] [DP [D \\ $\varnothing$] [N \\ blahh]]] [VP [PP [blah blah,roof]] [VP [PP [\sout{blah blah blah blah},roof]] [VP [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]]]]] [CP [\xbar{C} [C \\ $\varnothing$] [TP [DP [D \\ blah] [N \\ $\varnothing$]] [\xbar{T} [T \\ abc \\ $+$\textsc{blah}] [$\langle$VP$\rangle$,fit=band,tikz={\node (VPprefronting) [draw,thick,PineGreen,inner sep=1.5mm, fit to=tree]{};} [VP,name=firstmovedvp [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]] [VP [PP [\sout{blah blah},roof]] [VP [$\langle$PP$\rangle$ [\sout{blah blah blah blah},roof,name=extraposedbase]] [VP,name=lowvp [V \\ \sout{blah}] [DP [D \\ $\varnothing$] [N \\ \sout{blahh}]]]]]]]]] [PP [blah blah blah blah,roof,name=extraposedsurface]]]]
    \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},blue] (lowvp)..controls +(south east:14cm) and +(south west:11cm)..(firstmovedvp);
    \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},blue] (extraposedbase)..controls +(-60:9cm) and +(-35:22cm)..(extraposedsurface);
    \draw[very thick,-{Stealth[length=2.5mm,width=2.5mm]},Magenta] (VPprefronting)..controls +(-160:12cm) and +(-95:15cm)..(frontedVP);
  \end{forest}}
    
\end{document}

相关内容