Text wrapping with dot (graphviz)

前端 未结 2 1644
一整个雨季
一整个雨季 2021-02-05 00:42

I used the code below to create a graphic using dot (graphviz).

digraph
{
  node [color=Blue,shape=box]

  1.1 [label=\"Frequency of t exceeds upper threshold\"]         


        
相关标签:
2条回答
  • 2021-02-05 00:55

    Although graphviz does not support text wrapping by itself, dot2tex (latex+graphviz) does. The dot2texi latex package gives an all-in-one solution, with (from the users point of view) a single call to a single tool to build the graph.

    A short example:

    \documentclass{standalone}
    \usepackage{dot2texi}
    \usepackage{tikz}
    \usetikzlibrary{shapes,arrows}
    \begin{document}
    \begin{dot2tex}[dot]
    digraph G {                                             
    d2toptions ="--autosize"
    node    [lblstyle="text width=10em,align=center"]
    a       [texlbl="This text will be automatically wrapped, for example at a fixed width."]
    b       [texlbl="Manual linebreaks from past century can be avoided!"]
    a -> b
    }
    \end{dot2tex}                                               
    \end{document}
    

    This can be compiled invoking for example: pdflatex --shell-escape myFile.tex, the text will be automatically wrapped at the prescribed fixed width.

    As a side note, this tool seems a handy workaround for graphviz' limited typesetting control of the nodes contents.

    0 讨论(0)
  • 2021-02-05 01:08

    graphviz doesn't support automatic line breaks. You have to put the \n in manually.

    you can set a width and a height to a node and define it as fixedsized - this will limit the size of the node and draw only as much text as fits into the node

    0 讨论(0)
提交回复
热议问题