tikz-qtree 中的自動分段表示

tikz-qtree 中的自動分段表示

這就是我想要實現的目標

從“mu”連結到“a”

和這個:

從“O”連結到“l”

但我能用 tikz-qtree 所做的一切如下:

\documentclass[12pt,a4]{article}
\usepackage[utf8]{inputenc}
\usepackage{tipa,tikz,tikz-qtree}
\begin{document}

\begin{tikzpicture} [baseline]
\tikzset{frontier/.style={distance from root=90pt}}
\Tree
[.$\sigma$ [.O [ p ] ]
[.R [.$\mu$ a ] [.$\mu$ : ] ] ]
\end{tikzpicture}
\begin{tikzpicture} [baseline]
\tikzset{frontier/.style={distance from root=90pt}}
\Tree
[.$\sigma$ [.O [ p ] ]
[.R [.$\mu$ a ]  ] ]
\end{tikzpicture}

和這個:

\begin{tikzpicture}[baseline]
\tikzset{frontier/.style={distance from root=90pt}}
\Tree
[.$\sigma$ [.O [ l ] ]
[.R [.$\mu$ a ] [.$\mu$ l ] ] ]
\end{tikzpicture}
\begin{tikzpicture} [baseline]
\tikzset{frontier/.style={distance from root=90pt}}
\Tree
[.$\sigma$ [.O [ : ] ]
[.R [.$\mu$ a ] [ l ] ] ]
\end{tikzpicture}
\end{document}

其呈現:

在此輸入影像描述

在此輸入影像描述

這裡重要的部分是從葉子到多個父級的連結(如果我也可以選擇將線設為虛線,那就太好了)。現在,pst-asr 並沒有完全達到我想要的效果。重要的是我有moras('mu's)。 (它也是一個 pstricks 包,這意味著我必須在 DVIPSPDF 中排版它。)我嘗試了一些森林包(特別是森林-GP1),但我也無法按照我想要的方式工作。最後,有些人推薦了xyling,但我發現那個包很難使用。

有什麼建議嗎?

謝謝。

答案1

實際上,您絕對走在正確的軌道上:對程式碼進行一些小的添加可以很好地工作。這是建立在tikz-qtree.sty可以使用s 的事實之上的\node,s 可以被命名,並且名稱可以用作\drawing 的座標。第二個範例稍微複雜一些,因為在兩棵樹之間繪製了一條線,需要\begin{scope}...\end{scope}兩棵樹才能相鄰出現。您可以透過更改數量來調整第二棵樹的位置xshift

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture} [baseline]
\begin{scope}
\Tree
[.$\sigma$ [.O [ p ] ]
[.R [.$\mu$ \node[red](a){a}; ] \node(m){$\mu$}; ] ]
\draw (m.south) -- (a.north);
\end{scope}
\begin{scope}[xshift=0.65in]
\tikzset{frontier/.style={distance from root=90pt}}
\Tree
[.$\sigma$ [.O [ p ] ]
[.R [.$\mu$ a ]  ] ]
\end{scope}
\end{tikzpicture}

\begin{tikzpicture}[baseline]
\begin{scope}
\Tree
[.$\sigma$ [.O [ l ] ]
[.R [.$\mu$ a ] [.$\mu$ \node(l){l}; ] ] ]
\end{scope}
\begin{scope}[xshift=0.75in]
\Tree
[.$\sigma$ [.\node(O){O};  ]
[.R [.$\mu$ a ] [ l ] ] ]
\draw[dashed] (O.south) -- (l.north);
\end{scope}
\end{tikzpicture}

\end{document}

這會產生這樣的結果:

最新的輸出。

答案2

使用 來做到這一點要容易得多forest。您可以使用該phantom選項將樹並排放置,並且由於每個音節都是幻影節點的子代,因此您可以為多域分支命名節點。由於這些線條是使用常規 TikZ 指令繪製的,因此您也需要製作相關的子代幻像。您可以[dashed]使用常規 TiKZ 選項向該行添加任何裝飾(例如)。這是你的兩個例子。

首先,我設定了一種名為 的樣式syll,它使節點連接緊密,就像我們在語言學中看到的那樣。此外,因為我們希望段彼此對齊並且分支延伸到段層,所以我已將所有無子節點分配到該seg層。我還為音節和音節創建了幾個宏。

\documentclass{article}
\usepackage{forest}
\newcommand{\syl}{$\sigma$}
\newcommand{\mor}{$\mu$}
\forestset{syll/.style=
   {for tree={parent anchor=south,child anchor=north,
              align=center,inner sep=0pt,
              where n children=0{tier=seg}{}}}}
\begin{document}
\begin{forest}syll
[,phantom, s sep=1em
[\syl [O [p,tier=seg ]]
      [R [\mor [a,name=aa] ] [\mor,name=M [,phantom] ]]]
[\syl [O [p,tier=seg ]]
      [R [\mor [a] ]]]
]
\draw (M.south) -- (aa.north);
\end{forest}

\begin{forest}syll
[,phantom, s sep=1em
[\syl [O [l ]]
      [R [\mor [a]] [\mor [l,name=LL]]]]
[\syl [O,name=O [,phantom] ]
      [R [\mor [a] [l]]]]
]
\draw[dashed] (O.south) -- (LL.north);
\end{forest}


\end{document}

程式碼的輸出

答案3

你可以在 pst-asr 中實現你想要的,如果你使用 XeTeX 就可以了(無論如何推薦用於語言學)。我現在不在電腦前,所以稍後編碼並輸出!

編輯

這是代碼。

\documentclass{article}

\usepackage{pst-asr}
    \psset{everyasr=\tiershortcuts}
    \newpsstyle{dashed}{linestyle=dashed,dash=3pt 2pt}

\begin{document}

\newtier{con}
\psset{con=7ex (O)}
\newtier{sig}
\psset{sig=13ex (O)}
\asr[reptype=nots, sy=2ex ($\mu$)] |
    \@(0,ph){p}
    \@(1,ph){a}
    \@(3,ph){p}
    \@(4,ph){a}
    \@(1,sy){$\mu$}\-(1,ph)
    \@(2,sy){$\mu$}\-(1,ph)
    \@(4,sy){$\mu$}\-(4,ph)
    \@(0,con){O}\-(0,ph)
    \@(1,con){R}\-(1,sy)\-(2,sy)
    \@(3,con){O}\-(3,ph)
    \@(4,con){R}\-(4,sy)
    \@(.5,sig){$\sigma$}\-(0,con)\-(1,con)
    \@(3.5,sig){$\sigma$}\-(3,con)\-(4,con)
\endasr

\bigskip

\asr[reptype=nots, sy=2ex ($\mu$)] |
    \@(0,ph){l}
    \@(1,ph){a}
    \@(2,ph){l}
    \@(4,ph){a}
    \@(5,ph){l}
    \@(1,sy){$\mu$}\-(1,ph)
    \@(2,sy){$\mu$}\-(2,ph)
    \@(4,sy){$\mu$}\-(4,ph)
    \@(0,con){O}\-(0,ph)
    \@(1,con){R}\-(1,sy)\-(2,sy)
    \@(3,con){O}\-[style=dashed](2,ph)
    \@(4,con){R}\-(4,sy)\-(5,ph)
    \@(.5,sig){$\sigma$}\-(0,con)\-(1,con)
    \@(3.5,sig){$\sigma$}\-(3,con)\-(4,con)
\endasr

\end{document}

和輸出。

輸出

相關內容