udapi.block.write.tikz module¶
Tikz class is a writer for LaTeX with tikz-dependency.
- class udapi.block.write.tikz.Tikz(print_sent_id=True, print_text=True, print_preambule=True, attributes=None, as_tree=False, comment_attribute=None, enhanced=False, **kwargs)[source]¶
Bases:
BaseWriter
A writer of files in the LaTeX with tikz-dependency format.
Usage:
udapy write.Tikz < my.conllu > my.tex # or for 2D tree-like rendering udapy write.Tikz as_tree=1 < my.conllu > my.tex pdflatex my.tex xdg-open my.pdf
Long sentences may result in too large pictures. You can tune the width (in addition to changing fontsize or using minipage and rescaling) with
\begin{deptext}[column sep=0.2cm]
or individually for each word:My \&[.5cm] dog \& etc.
By default, the height of the horizontal segment of a dependency edge is proportional to the distance between the linked words. You can tune the height with:\depedge[edge unit distance=1.5ex]{9}{1}{deprel}
See tikz-dependency documentation for details.
With
as_tree=1
, there are two options how to visualize deprels: either as labels positioned on the edges by uncommenting the relevant style definition, or by addingdeprel
to the list of attributes, so deprels are above/below the words. The latter is the default because the edge labels need manual tweaks to prevent overlapping.Alternatives: * use write.TextModeTrees and include it in verbatim environment in LaTeX. * use write.Html, press “Save as SVG” button, convert to pdf and include in LaTeX.