
我正在嘗試使用該套件製作語言學樹forest
,如第二個範例所示這個線程。我能夠在很大程度上生成樹,但由於某種原因我無法繪製三角形。
這是我的 MWE:
\documentclass{article}
\usepackage{forest}
\usepackage{amsmath,amsfonts,amssymb}
\begin{document}
\begin{forest}
for tree={
if n children =0{
font=\itshape,
tier=terminal
}{},
}
[TP
[NP
[Det
[The]
]
[$\bar{N}$
[N
[ice]
]
]
]
[$\bar{T}$
[T
[+pst,font=\scshape]
]
[VP
[$\bar{V}$
[V
[melt]
]
]
[AdvP
[quickly,triangle]
]
]
]
]
\end{forest}
\end{document}
當我運行這個時,我收到以下錯誤:
! Package pgfkeys Error: I do not know the key '/tikz/triangle' and I am going to ignore it. Perhaps you misspelled it. See the pgfkeys package documentation for explanation. Type H for immediate help.... \end{forest}
我在 MiKTeX 2.9 上運行 Texmaker 4.4.1。我的pgf
版本是3.0.1a,我使用的是pdfTeX版本3.1415926-2.5-1.40.14。 redditor 能夠在 pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) 上執行程式碼。
奇怪的是,我在 MacBook 上也成功使用了 Texmaker 4.2、TeX Live 2014、3.0.0 pgf
. 和 pdfTeX 3.1415926-2.6-1.40.15。
是否有某種方法可以降級我的版本pgf
?或有其他錯誤嗎?
答案1
您應該檢查的第一件事是版本森林你有。如果如果您有版本 2,則適用以下答案。如果您仍然擁有版本 1,那麼它就無關緊要了。
假設你有版本 2...
新版本的森林引入了一些向後不相容的變更。在這種情況下,我們關心其中兩個問題:
某些選項群集現在被組織到庫中,並且必須單獨載入。
某些選項已被重新命名或不再存在。
triangle
根本不再作為一種選擇存在。新選項是roof
.但是,要訪問roof
,您需要加載該linguistics
庫。
從文件中看,該過程不是很清楚。第一個問題是
texdoc forest
現在為您提供記錄的代碼,但不提供使用手冊。
texdoc -l forest
讓您可以選擇查看用戶手冊,該手冊現在位於forest-doc.pdf
.
第 20 頁解釋了載入庫的機制。
本質上,
\useforestlibrary{<list of libraries>}
載入庫列表並
\forestapplylibrarydefaults{<list of libraries>}
應用其預設設置,使任何附加選項等可用。
\useforestlibrary{}
,與\usepackage{}
和類似\usetikzlibrary{}
,僅在序言中使用。
\forestapplylibrarydefaults{}
可以在序言或文件中使用,並適用於目前的 TeX 範圍。
另一種方法是在載入時將庫的名稱作為選項傳遞森林
\usepackage[<list of libraries>]{forest}
其作用是載入庫並在整個文件範圍內套用預設值。
注意
\forestapplylibrarydefaults{<libraries>}
<libraries>
除非已加載,否則沒有任何效果。然而,令人困惑的是,它並沒有給出錯誤。
無論如何,這樣做的結果是我們需要加載並應用該linguistics
庫並更改triangle
為roof
:
\documentclass[tikz, border=10pt, multi]{standalone}
\usepackage{forest}
\usepackage{amsmath,amsfonts,amssymb}
\useforestlibrary{linguistics}
\forestapplylibrarydefaults{linguistics}
\begin{document}
\begin{forest}
for tree={
if n children =0{
font=\itshape,
tier=terminal
}{},
}
[TP
[NP
[Det
[The]
]
[$\bar{N}$
[N
[ice]
]
]
]
[$\bar{T}$
[T
[+pst,font=\scshape]
]
[VP
[$\bar{V}$
[V
[melt]
]
]
[AdvP
[quickly,roof]
]
]
]
]
\end{forest}
\end{document}
請注意,這也會改變錨點以及邊緣的外觀。希望這就是您想要的,因為我相信這種風格在語言學中是正常的。然而,這確實意味著如果您之前使用錨點和邊緣的預設樣式,您的樹看起來會有點不同。