PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/nltk/doc/slides/synttree.sty

https://github.com/trunghlt/nltk
TeX | 438 lines | 391 code | 1 blank | 46 comment | 0 complexity | 0ae3ef3b2b0823cf89733b6befc6c3aa MD5 | raw file
  1. %%
  2. %% This is file `synttree.sty',
  3. %% generated with the docstrip utility.
  4. %%
  5. %% The original source files were:
  6. %%
  7. %% synttree.dtx
  8. %%
  9. %% IMPORTANT NOTICE:
  10. %%
  11. %% For the copyright see the source file.
  12. %%
  13. %% Any modified versions of this file must be renamed
  14. %% with new filenames distinct from synttree.sty.
  15. %%
  16. %% For distribution of the original source see the terms
  17. %% for copying and modification in the file synttree.dtx.
  18. %%
  19. %% This generated file may be distributed as long as the
  20. %% original source files, as listed above, are part of the
  21. %% same distribution. (The sources need not necessarily be
  22. %% in the same archive or directory.)
  23. %% \CheckSum{774}
  24. %% synttree.dtx
  25. %% Package `synttree' for use with LaTeX 2e
  26. %% Version 1.4
  27. %% \CharacterTable
  28. %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  29. %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  30. %% Digits \0\1\2\3\4\5\6\7\8\9
  31. %% Exclamation \! Double quote \" Hash (number) \#
  32. %% Dollar \$ Percent \% Ampersand \&
  33. %% Acute accent \' Left paren \( Right paren \)
  34. %% Asterisk \* Plus \+ Comma \,
  35. %% Minus \- Point \. Solidus \/
  36. %% Colon \: Semicolon \; Less than \<
  37. %% Equals \= Greater than \> Question mark \?
  38. %% Commercial at \@ Left bracket \[ Backslash \\
  39. %% Right bracket \] Circumflex \^ Underscore \_
  40. %% Grave accent \` Left brace \{ Vertical bar \|
  41. %% Right brace \} Tilde \~}
  42. %%
  43. \def\@AfterFi#1\fi{\fi#1}
  44. \def\@AfterElseFi#1\else#2\fi{\fi#1}
  45. \def\MTr@latexdrawline(#1,#2)(#3,#4){%
  46. {%
  47. \count0=#1 \advance\count0 by #3 \divide\count0 2
  48. \count1=#2 \advance\count1 by #4 \divide\count1 2
  49. \qbezier(#1,#2)(\count0,\count1)(#3,#4)%
  50. }%
  51. }
  52. \def\MTr@etexdrawline(#1,#2)(#3,#4){%
  53. {%
  54. \count0=\@wholewidth \divide\count0 by 4736
  55. \special{pn \the\count0}%
  56. \count0= #1\advance \count0 2368 \divide \count0 4736
  57. \count1=-#2\advance \count1 -2368 \divide \count1 4736
  58. \special{pa \the\count0 \space \the\count1}%
  59. \count0= #3\advance \count0 2368 \divide \count0 4736
  60. \count1=-#4\advance \count1 -2368 \divide \count1 4736
  61. \special{pa \the\count0 \space \the\count1}%
  62. \special{fp}%
  63. }%
  64. }
  65. \DeclareOption{specials}{
  66. \let\MTr@drawline\MTr@etexdrawline%
  67. }
  68. \DeclareOption{nospecials}{
  69. \let\MTr@drawline\MTr@latexdrawline%
  70. }
  71. \ExecuteOptions{nospecials}%
  72. \ProcessOptions%
  73. \newcount\MTr@level
  74. \newcount\MTr@numchildren
  75. \newcount\MTr@maxlevel
  76. \newcount\MTr@mybranchmult
  77. \newif\ifMTr@mytriangle
  78. \newif\ifMTr@uselabel
  79. \newbox\MTr@labelbox
  80. \newbox\MTr@treebox
  81. \def\MTr@makechildcounter#1{
  82. \expandafter\newcount\csname MTr@child#1\endcsname%
  83. }
  84. \def\MTr@makechildstoreage#1{
  85. \expandafter\newsavebox\csname MTr@child#1box\endcsname%
  86. \MTr@makechildcounter{#1x}
  87. \MTr@makechildcounter{#1y}
  88. \MTr@makechildcounter{#1v}
  89. \MTr@makechildcounter{#1w}
  90. \MTr@makechildcounter{#1height}
  91. \MTr@makechildcounter{#1depth}
  92. \MTr@makechildcounter{#1branchmult}
  93. \MTr@makechildcounter{#1picheight}
  94. \MTr@makechildcounter{#1triangle}
  95. }
  96. \def\MTr@childparam#1#2{\csname MTr@child#1#2\endcsname}
  97. \newcount\MTr@treev
  98. \newcount\MTr@treew
  99. \newcount\MTr@treeheight
  100. \newcount\MTr@treedepth
  101. \newcount\MTr@branchmult
  102. \MTr@branchmult 1
  103. \newif\ifMTr@triangle
  104. \newcount\MTr@labeldepth
  105. \newcount\MTr@labelheight
  106. \newcount\MTr@labelhalfwidth
  107. \newcount\MTr@morex
  108. \newcount\MTr@parenty
  109. \newcount\MTr@picwidth
  110. \newcount\MTr@picheight
  111. \newlength{\MTr@templength}
  112. \newcount\MTr@loopcnta
  113. \newcount\MTr@tempcnta
  114. \newcount\MTr@tempcntb
  115. \newcount\MTr@tempcntc
  116. \newcount\MTr@branchheight%
  117. \newcommand{\branchheight}[1]{%
  118. \setlength{\MTr@templength}{#1}%
  119. \MTr@branchheight\MTr@templength%
  120. }
  121. \branchheight{.5in}%
  122. \newcount\MTr@trianglemultright%
  123. \newcount\MTr@trianglemultleft%
  124. \newcommand{\trianglebalance}[1]{%
  125. \MTr@trianglemultleft100%
  126. \MTr@trianglemultright#1%
  127. \advance\MTr@trianglemultleft-#1%
  128. }
  129. \trianglebalance{50}%
  130. \newcount\MTr@lineoffset
  131. \setlength{\MTr@templength}{2pt}%
  132. \MTr@lineoffset\MTr@templength%
  133. \newlength{\MTr@minheight}
  134. \setlength{\MTr@minheight}{8pt}%
  135. \newcount\MTr@childsidesep
  136. \newcommand{\childsidesep}[1]{%
  137. \setlength{\MTr@templength}{#1}%
  138. \MTr@childsidesep\MTr@templength%
  139. \ignorespaces%
  140. }
  141. \childsidesep{1em}
  142. \newcount\MTr@childattachsep
  143. \newcommand{\childattachsep}[1]{%
  144. \setlength{\MTr@templength}{#1}%
  145. \MTr@childattachsep\MTr@templength%
  146. \ignorespaces%
  147. }
  148. \childattachsep{0.5in}
  149. \def\synttree{%
  150. \@ifnextchar[{\MTr@synttree{0}}{\MTr@synttree}%]
  151. }
  152. \def\MTr@synttree#1{%
  153. \MTr@maxlevel#1%
  154. \unitlength 1sp%
  155. \MTr@level=0%
  156. \MTr@numchildren=0%
  157. \MTr@uselabelfalse%
  158. \MTr@parserightbracket%
  159. }
  160. \def\MTr@parserightbracket#1]{%
  161. \MTr@parseleftbracket#1[:\END%
  162. \advance\MTr@level by -1%
  163. \MTr@dorightbracket%
  164. \ifnum\MTr@level=0%
  165. \unhbox\MTr@childibox%
  166. \else
  167. \@AfterFi{\MTr@parserightbracket}%
  168. \fi%
  169. }
  170. \def\MTr@parseleftbracket#1[#2\END{%
  171. \ifMTr@uselabel%
  172. \MTr@bottomnodefalse%
  173. \MTr@mytrianglefalse%
  174. \MTr@parsedot#1.: \END%
  175. \fi%
  176. \ifx:#2
  177. \else
  178. \MTr@doleftbracket%
  179. \advance\MTr@level by 1%
  180. \@AfterFi{\MTr@parseleftbracket#2\END}%
  181. \fi%
  182. }
  183. \def\MTr@parsedot#1.#2 #3\END{
  184. \ifx:#2
  185. \setbox\MTr@labelbox\hbox{}
  186. \MTr@setlabel #1 \END
  187. \else
  188. \ifx#2b\MTr@bottomnodetrue\else%
  189. \ifx#2x\MTr@bottomnodetrue\MTr@mytriangletrue\else%
  190. \ifx#2t\MTr@mytriangletrue\else%
  191. \typeout{synttree Warning: unknown dot option #1 in tree}%
  192. \fi\fi\fi%
  193. \MTr@parsedot#3\END
  194. \fi
  195. }
  196. \def\MTr@setlabel#1 #2\END{
  197. \if\space#1
  198. \else
  199. \setbox\MTr@labelbox\hbox{\unhbox\MTr@labelbox #1}
  200. \fi
  201. \if\space#2
  202. \else
  203. \if\space#1
  204. \else
  205. \setbox\MTr@labelbox\hbox{\unhbox\MTr@labelbox{} }
  206. \fi
  207. \MTr@setlabel#2\END
  208. \fi
  209. }
  210. \def\MTr@doleftbracket{%
  211. \bgroup%
  212. \MTr@numchildren=0%
  213. \MTr@uselabeltrue%
  214. }
  215. \def\MTr@dorightbracket{%
  216. \MTr@maketreebox%
  217. \egroup%
  218. \MTr@uselabelfalse%
  219. \MTr@savecurrentchildbox%
  220. }
  221. \def\MTr@savecurrentchildbox{%
  222. \advance\MTr@numchildren by 1
  223. \ifnum\MTr@numchildren<1%
  224. \typeout{synttree internal warning: There is no child box to save.}%
  225. \else
  226. \ifnum\MTr@numchildren>10%
  227. \typeout{synttree warning: More than 10 child boxes.
  228. Can this be true?}%
  229. \fi
  230. \MTr@savechildbox{\romannumeral\MTr@numchildren}%
  231. \fi
  232. }
  233. \def\MTr@savechildbox#1{%
  234. \expandafter
  235. \ifx\csname MTr@child#1box\endcsname\relax%
  236. \MTr@makechildstoreage{#1}%
  237. \fi%
  238. \setbox%
  239. \csname MTr@child#1box\endcsname%
  240. \hbox{\unhbox\MTr@treebox}%
  241. \csname MTr@child#1v\endcsname\MTr@treev%
  242. \csname MTr@child#1w\endcsname\MTr@treew%
  243. \csname MTr@child#1x\endcsname\MTr@treev%
  244. \csname MTr@child#1height\endcsname\MTr@treeheight%
  245. \csname MTr@child#1depth\endcsname\MTr@treedepth%
  246. \csname MTr@child#1branchmult\endcsname\MTr@branchmult%
  247. \ifMTr@triangle%
  248. \csname MTr@child#1triangle\endcsname 1%
  249. \else%
  250. \csname MTr@child#1triangle\endcsname 0%
  251. \fi
  252. }
  253. \def\MTr@bottomnodetrue{%
  254. \MTr@branchmult\MTr@maxlevel%
  255. \advance\MTr@branchmult-\MTr@level%
  256. \advance\MTr@branchmult 1%
  257. \ifnum\MTr@branchmult<1%
  258. \typeout{synttree Warning: Tree has more levels than indicated.}%
  259. \typeout{>> Indicated: \the\MTr@maxlevel.}%
  260. \typeout{>> Level now: \the\MTr@level.}%
  261. \MTr@branchmult1%
  262. \fi%
  263. \MTr@mybranchmult\MTr@branchmult%
  264. }
  265. \def\MTr@bottomnodefalse{%
  266. \MTr@mybranchmult1%
  267. }
  268. \def\MTr@setverticalchilddimens#1{%
  269. \MTr@tempcnta-\MTr@branchheight%
  270. \multiply\MTr@tempcnta\MTr@childparam{#1}{branchmult}%
  271. \MTr@tempcntb-\MTr@tempcnta%
  272. \advance\MTr@tempcntb\csname MTr@child#1depth\endcsname%
  273. \advance\MTr@tempcnta-\MTr@labelheight%
  274. \advance\MTr@tempcnta\csname MTr@child#1height\endcsname%
  275. \csname MTr@child#1y\endcsname\MTr@tempcnta%
  276. \csname MTr@child#1picheight\endcsname\MTr@tempcntb%
  277. }
  278. \def\MTr@adjustdistance#1#2{%
  279. \MTr@tempcnta\MTr@childparam{#1}{w}%
  280. \advance\MTr@tempcnta\MTr@childsidesep%
  281. \advance\MTr@tempcnta\csname MTr@child#2v\endcsname%
  282. \ifnum\MTr@tempcnta<\MTr@childattachsep%
  283. \MTr@tempcnta\MTr@childattachsep%
  284. \fi%
  285. \csname MTr@child#2x\endcsname\MTr@childparam{#1}{x}%
  286. \advance\csname MTr@child#2x\endcsname\MTr@tempcnta%
  287. }
  288. \def\MTr@setparentdimens#1#2{%
  289. \MTr@tempcnta\MTr@childparam{#2}{x}%
  290. \advance \MTr@tempcnta -\MTr@childparam{#1}{x}%
  291. \divide\MTr@tempcnta 2%
  292. \MTr@treev\MTr@tempcnta%
  293. \MTr@treew\MTr@treev%
  294. \advance \MTr@treev \csname MTr@child#1x\endcsname%
  295. \advance \MTr@treew \csname MTr@child#2w\endcsname%
  296. \MTr@morex\MTr@labelhalfwidth%
  297. \advance\MTr@morex-\MTr@treev%
  298. \ifnum\MTr@morex<0\MTr@morex0\fi%
  299. \ifnum\MTr@treew<\MTr@labelhalfwidth
  300. \MTr@treew\MTr@labelhalfwidth
  301. \fi%
  302. \ifnum\MTr@treev<\MTr@labelhalfwidth
  303. \MTr@treev\MTr@labelhalfwidth
  304. \fi%
  305. \MTr@picwidth\MTr@treev%
  306. \advance\MTr@picwidth\MTr@treew%
  307. }
  308. \def\MTr@setpictureparameters{%
  309. \global\MTr@treedepth\MTr@picheight%
  310. \advance\MTr@picheight\MTr@labelheight%
  311. \global\MTr@treeheight\MTr@labelheight%
  312. \MTr@parenty-\MTr@labelheight%
  313. \advance\MTr@parenty-\MTr@labeldepth%
  314. \advance\MTr@parenty-\MTr@lineoffset%
  315. \global\MTr@treev\MTr@treev%
  316. \global\MTr@treew\MTr@treew%
  317. }
  318. \def\MTr@drawlabel{%
  319. \put(\MTr@treev,0){%
  320. \makebox(0,0)[t]{%
  321. \rule{0pt}{\MTr@minheight}%
  322. \usebox{\MTr@labelbox}}}%
  323. }
  324. \def\MTr@drawchild#1{%
  325. \MTr@tempcnta\MTr@childparam{#1}{x}
  326. \advance\MTr@tempcnta-\MTr@childparam{#1}{v}
  327. \put(\MTr@tempcnta,\MTr@childparam{#1}{y}){%
  328. \makebox(0,0)[tl]{%
  329. \usebox{\csname MTr@child#1box\endcsname}}}%
  330. }
  331. \def\MTr@drawchildline#1{
  332. \MTr@tempcnta\MTr@childparam{#1}{y}
  333. \advance\MTr@tempcnta\MTr@lineoffset%
  334. \expandafter
  335. \ifnum\csname MTr@child#1triangle\endcsname=1%
  336. \MTr@tempcntb\MTr@childparam{#1}{x}%
  337. \MTr@tempcntc\MTr@tempcntb%
  338. \advance\MTr@tempcntb \MTr@childparam{#1}{w}%
  339. \advance\MTr@tempcntc -\MTr@childparam{#1}{v}%
  340. \put(0,0){\MTr@drawline%
  341. (\MTr@treev,\MTr@parenty)%
  342. (\MTr@tempcntc,\MTr@tempcnta)}%
  343. \put(0,0){\MTr@drawline%
  344. (\MTr@treev,\MTr@parenty)%
  345. (\MTr@tempcntb,\MTr@tempcnta)}%
  346. \put(0,0){\MTr@drawline%
  347. (\MTr@tempcntc,\MTr@tempcnta)%
  348. (\MTr@tempcntb,\MTr@tempcnta)}%
  349. \else%
  350. \put(0,0){\MTr@drawline%
  351. (\MTr@treev,\MTr@parenty)%
  352. (\MTr@childparam{#1}{x},\MTr@tempcnta)}%
  353. \fi%
  354. }
  355. \def\MTr@maketreebox{%
  356. \MTr@labelheight\ht\MTr@labelbox%
  357. \ifnum\MTr@labelheight<\MTr@minheight\MTr@labelheight\MTr@minheight\fi%%
  358. \MTr@labeldepth\dp\MTr@labelbox%
  359. \MTr@labelhalfwidth\wd\MTr@labelbox%
  360. \divide\MTr@labelhalfwidth 2%
  361. \ifnum\MTr@numchildren=0%
  362. \global\setbox\MTr@treebox\hbox{\MTr@outputlabel}
  363. \fi
  364. \ifnum\MTr@numchildren>0%
  365. \global\setbox\MTr@treebox\hbox{\MTr@outputchildren{\the\MTr@numchildren}}%
  366. \fi
  367. \global\MTr@branchmult\MTr@mybranchmult%
  368. \ifMTr@mytriangle%
  369. \global\MTr@triangletrue%
  370. \else%
  371. \global\MTr@trianglefalse%
  372. \fi%
  373. }
  374. \def\MTr@outputlabel{%
  375. \global\MTr@treeheight\MTr@labelheight%
  376. \global\MTr@treedepth\MTr@labeldepth%
  377. \ifMTr@mytriangle%
  378. \MTr@treew\MTr@labelhalfwidth%
  379. \MTr@treev\MTr@labelhalfwidth%
  380. \multiply\MTr@treew \MTr@trianglemultright%
  381. \multiply\MTr@treev \MTr@trianglemultleft%
  382. \divide\MTr@treew 50%
  383. \divide\MTr@treev 50%
  384. \global\MTr@treew\MTr@treew%
  385. \global\MTr@treev\MTr@treev%
  386. \else%
  387. \global\MTr@treew\MTr@labelhalfwidth%
  388. \global\MTr@treev\MTr@labelhalfwidth%
  389. \fi%
  390. \MTr@picwidth\wd\MTr@labelbox%
  391. \MTr@picheight\MTr@treeheight%
  392. \advance\MTr@picheight\MTr@treedepth%
  393. \begin{picture}%
  394. (\MTr@picwidth,\MTr@picheight)%
  395. (-\MTr@treev,-\MTr@picheight)%
  396. %\put(-\MTr@treev,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
  397. \put(-\MTr@treev,0){%
  398. \makebox(0,0)[tl]{%
  399. \rule{0pt}{\MTr@minheight}%
  400. \usebox{\MTr@labelbox}}}%
  401. \end{picture}%
  402. }
  403. \def\MTr@outputchildren#1{%
  404. \ifnum#1>1
  405. \MTr@loopcnta 1
  406. \loop
  407. \edef\MTr@temp{\romannumeral\MTr@loopcnta}%
  408. \ifnum\MTr@loopcnta<#1
  409. \advance \MTr@loopcnta by 1
  410. \MTr@adjustdistance{\MTr@temp}{\romannumeral\MTr@loopcnta}%
  411. \repeat
  412. \fi
  413. \MTr@setparentdimens{i}{\romannumeral#1}%
  414. \MTr@picheight 0%
  415. \MTr@loopcnta #1
  416. \loop
  417. \edef\MTr@temp{\romannumeral\MTr@loopcnta}%
  418. \advance\MTr@childparam{\MTr@temp}{x}\MTr@morex%
  419. \MTr@setverticalchilddimens{\romannumeral\MTr@loopcnta}%
  420. \ifnum\MTr@childparam{\MTr@temp}{picheight}>\MTr@picheight%
  421. \MTr@picheight\MTr@childparam{\MTr@temp}{picheight}%
  422. \fi%
  423. \advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat
  424. \MTr@setpictureparameters%
  425. \begin{picture}(\MTr@picwidth,\MTr@picheight)(0,-\MTr@picheight)%
  426. %\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
  427. \MTr@drawlabel%
  428. \MTr@loopcnta #1
  429. \loop
  430. \expandafter\MTr@drawchild{\romannumeral\MTr@loopcnta}%
  431. \expandafter\MTr@drawchildline{\romannumeral\MTr@loopcnta}
  432. \advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat
  433. \end{picture}%
  434. }
  435. \endinput
  436. %%
  437. %% End of file `synttree.sty'.