我正在嘗試使用forest-GP1,它是Zivanovic的forest-package(用於語音表示)中的一種樣式在 github 上。
我已將該.sty
文件添加到與相關文件相同的目錄中.tex
(我也嘗試通過在 中定義路徑來鏈接到它\usepackage{/path/forest-GP1}
,但無論如何我最終都會得到缺少\begin{文檔}錯誤。
這是我使用過的程式碼:
\documentclass{article}
\usepackage{forest-GP1}
\begin{document}
\begin{forest} GP1 [
[O[x[f ] ][x[r ] ] ]
[R[N[x[o ] ] ][x[s ] ] ]
[O[x[t ] ] ]
[R[N[x ] ] ]
]\end{forest}
\end{document}
我正在 TeXWorks 中使用 PDFLaTeX 進行排版(使用 MiKTeX)
答案1
原因是你失蹤了森林-GP1包,並且不會自動下載。您確定將其包含在正確的資料夾中嗎?
你可以從github並將其包含在您的工作資料夾中森林-GP1.sty它會起作用的。
\documentclass{article}
\usepackage{forest-GP1}
\begin{document}
\begin{forest} GP1 [
[O[x[f ] ][x[r ] ] ]
[R[N[x[o ] ] ][x[s ] ] ]
[O[x[t ] ] ]
[R[N[x ] ] ]
]\end{forest}
\end{document}
答案2
forest
您可以依照手冊第 49 頁所示定義樣式:
\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\newbox\standardnodestrutbox
\setbox\standardnodestrutbox=\hbox to 0pt{\phantom{\forestOve{standard node}{content}}}
\def\standardnodestrut{\copy\standardnodestrutbox}
\forestset{% from page 49 of forest's manual
GP1/.style 2 args={
for n={1}{baseline},
s sep=0pt, l sep=0pt,
for descendants={
l sep=0pt, l={#1},
anchor=base,calign=first,child anchor=north,
inner xsep=1pt,inner ysep=2pt,outer sep=0pt,s sep=0pt,
},
delay={
if content={}{phantom}{for children={no edge}},
for tree={
if content={O}{tier=OR}{},
if content={R}{tier=OR}{},
if content={N}{tier=N}{},
if content={x}{
tier=x,content={$\times$},outer xsep={#2},
for tree={calign=center},
for descendants={content format={\standardnodestrut\forestoption{content}}},
before drawing tree={outer xsep=0pt,delay={typeset node}},
s sep=4pt
}{},
},
},
before drawing tree={where content={}{parent anchor=center,child anchor=center}{}},
},
GP1/.default={5ex}{8.0pt},
associate/.style={%
tikz+={\draw[densely dotted](!)--(!#1);}},
spread/.style={
before drawing tree={tikz+={\draw[dotted](!)--(!#1);}}},
govern/.style={
before drawing tree={tikz+={\draw[->](!)--(!#1);}}},
p-govern/.style={
before drawing tree={tikz+={\draw[->](.north) to[out=150,in=30] (!#1.north);}}},
no p-govern/.style={
before drawing tree={tikz+={\draw[->,loosely dashed](.north) to[out=150,in=30] (!#1.north);}}},
encircle/.style={before drawing tree={circle,draw,inner sep=0pt}},
fen/.style={pin={[font=\footnotesize,inner sep=1pt,pin edge=<-]10:\textsc{Fen}}},
el/.style={content=\textsc{\textbf{##1}}},
head/.style={content=\textsc{\textbf{\underline{##1}}}}
}
\begin{document}
\begin{forest} GP1 [
[O[x[f ] ][x[r ] ] ]
[R[N[x[o ] ] ][x[s ] ] ]
[O[x[t ] ] ]
[R[N[x ] ] ]
]\end{forest}
\end{document}