-
Notifications
You must be signed in to change notification settings - Fork 17
/
deptree.sty
156 lines (134 loc) · 4.97 KB
/
deptree.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
\ProvidesPackage{deptree}[2019/10/04, v1.10 simple dependency trees]
\NeedsTeXFormat{LaTeX2e}[2016/02/01]
\RequirePackage{ifthen}
\RequirePackage{tikz}
\usetikzlibrary{arrows,positioning,calc}
\def\@deprelcolor{black} % line
\def\@depreltextcolor{black} % text
\def\@deprellabelcolor{gray} % frame
\def\@mwtlabelcolor{black!7} % frame
\def\@deprelbgcolor{black!5}
\def\@depreltextfont{\footnotesize}
\def\@wordfont{}
\def\@wordcolor{black}
\def\@bottomwordfont{\small}
\def\@posfont{}
\def\@mwtfont{\scriptsize}
% define styles for arrows, words and dep labels
\tikzstyle{dottedline} = [draw, dashed, color=gray]
\tikzstyle{line} = [draw, very thick, color=\@deprelcolor, -latex']
\tikzstyle{wort} = [rectangle, %draw=blue, fill=blue!60,
inner sep=1pt,
color=\@wordcolor,
font=\@wordfont,
align=center, %% needed to make \\ work
% text width=5em,
text centered%, rounded corners%, minimum height=\minheight
]
\tikzstyle{bottomwort} = [rectangle, %draw=blue, %fill=blue!60,
align=center, %% needed to make \\ work
anchor=south,
font=\@bottomwordfont,
%text centered,% rounded corners,
text depth=.25ex
%minimum height=4ex
]
% label with background color on the dependency line
\tikzstyle{deplabel} = [rectangle,line width=0.2pt,
draw=\@deprellabelcolor,
text=\@depreltextcolor,
fill=\@deprelbgcolor, %violet!10,
inner sep=2pt,
%inner sep=0pt,
align=center, %% needed to make \\ work
font=\@depreltextfont,
% text width=5em,
text centered,
rounded corners %, minimum height=\minheight
]
% if background color is empty, we do not draw neither fill nor border
% printed next to the dependency line
\tikzstyle{deplabel2} = [rectangle,line width=0.2pt, above,
text=\@depreltextcolor,
inner sep=2pt,
%inner sep=0pt,
align=center, %% needed to make \\ work
font=\@depreltextfont,
% text width=5em,
text centered,
rounded corners %, minimum height=\minheight
]
\tikzstyle{wg} = [%fill=yellow,
draw=black,
rounded corners]
\tikzstyle{wglabel} = [draw=black,
font=\@mwtfont,
fill=\@mwtlabelcolor,
rounded corners]
\def\setdeprelcolor#1{\def\@deprelcolor{#1}}
\def\setdeprellabelcolor#1{\def\@deprellabelcolor{#1}}
\def\setdepreltextcolor#1{\def\@depreltextcolor{#1}}
\def\setdeprelbgcolor#1{\def\@deprelbgcolor{#1}}
\def\setdepreltextfont#1{\def\@depreltextfont{#1}}
\def\setwordfont#1{\def\@wordfont{#1}}
\def\setwordcolor#1{\def\@wordcolor{#1}}
\def\setbottomwordfont#1{\def\@bottomwordfont{#1}}
\def\setposfont#1{\def\@posfont{#1}}
\def\setmwtfont#1{\def\@mwtfont{#1}}
\def\setmwtlabelcolor#1{\def\@mwtlabelcolor{#1}}
\def\@bottom{0}
\def\setbottom#1{\def\@bottom{#1}}
% x_pos form,pos
\def\root#1#2#3{
\def\@@pos{#3}%
\ifx\@@pos\@empty%
\node [wort] (#1) at(#1,0) {#2};
\else
\node [wort] (#1) at(#1,0) {#2\\\@posfont #3};
\fi
\ifthenelse{\NOT 0 =\@bottom}{
\node [bottomwort] (bottom_#1) at(#1,-\@bottom) {#2};
\path [dottedline] (#1) -- (bottom_#1);
}{}
}
% headpos,xpos,ypos,form,pos,label
\def\dep#1#2#3#4#5#6{
\depX{#1}{#2}{#3}{#4}{#5}{#6}{0}
}
% add some horizontal space to xpos
% headpos,xpos,ypos,form,pos,label, addtoxpos
\def\depX#1#2#3#4#5#6#7{
\def\@@pos{#5}%
\ifx\@@pos\@empty%
\node [wort] (#2) at(#2.#7,-#3) {#4};
\else
\node [wort] (#2) at(#2.#7,-#3) {#4\\\@posfont #5};
\fi
\ifx\@deprelbgcolor\@empty
\path [line] (#1) -> node [deplabel2,sloped,midway] {#6} (#2);
\else
\path [line] (#1) -> node [deplabel,sloped,midway] {#6} (#2);
\fi
\ifthenelse{\NOT 0 =\@bottom}{
\node [bottomwort] (bottom_#2) at(#2.#7,-\@bottom) {#4};
\path [dottedline] (#2) -- (bottom_#2);
}{}
}
% first,last,form
\def\mwt#1#2#3{
\ifthenelse{\NOT 0 =\@bottom}{
%\draw[draw=black,rounded corners] (#1-.4, -\@bottom.1) rectangle ++(#2-#1+1, .5);
\draw[wg] ($(bottom_#1.north west) + (0, 0)$) rectangle ($(bottom_#2.south east) + (0, 0)$);
%\node[bottomwort] (b#1) at ($(bottom_#1.south)$) {???}; % how to access label of existing node?
\node[wglabel] (#1#2) at ($(bottom_#1.south) + (.5*#2-.5*#1, 0)$) {#3};
}{}
}
% xposdelta,headid,id,text,label
%\def\depl#1#2#3#4#5{
% \node [wort, below left=1 and #1 of #2] (#3) {#4};
% \path [line] (#2) -> node [sloped,midway,above] {#5} (#3);
%}
%\def\depr#1#2#3#4#5{
% \node [wort, below right=1 and #1 of #2] (#3) {#4};
% \path [line] (#2) -> node [sloped,midway,above] {#5} (#3);
%}