### Install dot2tex from source Source: https://dot2tex.readthedocs.io/en/latest/installation_guide.html To install dot2tex from its source code, download the archive, unpack it, and run the setup script. This method is useful for installing specific versions or for development purposes. ```bash $ python setup.py install ``` -------------------------------- ### Install dot2tex using easy_install Source: https://dot2tex.readthedocs.io/en/latest/installation_guide.html Alternatively, you can use easy_install to install dot2tex. This command will download and install the package and its dependencies. ```bash $ easy_install dot2tex ``` -------------------------------- ### Graphviz Example with Node Size and Margin Attributes Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This Graphviz example demonstrates various ways to set node sizes and margins using attributes like 'width', 'height', and 'margin'. It is used to show the effect of preprocessing options. ```dot digraph G { node [shape=rectangle]; a_1 [margin="0"]; a_2 [margin="0.7,0.4"]; a_3 [width="2",height="1"]; a_1-> a_2 -> a_3 -> a_1; } ``` -------------------------------- ### Examples of dot2tex Function Calls Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Provides several examples of calling the `dot2tex` function with different keyword arguments to control the output format and processing. ```APIDOC ## Examples Here are a few examples: ```python import dot2tex as d2t texcode = d2t.dot2tex(testgraph, format='tikz', crop=True) texcode = d2t.dot2tex(testgraph, preproc=True,figonly=True) texcode = d2t.dot2tex(testgraph, debug=True) ``` Option values are either strings or booleans. Note that some of the command line options are not relevant when using dot2tex as a module. ``` -------------------------------- ### Install dot2tex using pip Source: https://dot2tex.readthedocs.io/en/latest/installation_guide.html Use this command to install dot2tex with pip, the recommended package installer for Python. This command will automatically download and install dot2tex and its dependencies. ```bash $ pip install dot2tex ``` -------------------------------- ### Module Usage Examples with Options Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Illustrates various ways to call the dot2tex function with different conversion options like format, preprocessing, figure-only output, and debugging. ```python import dot2tex as d2t texcode = d2t.dot2tex(testgraph, format='tikz', crop=True) texcode = d2t.dot2tex(testgraph, preproc=True,figonly=True) texcode = d2t.dot2tex(testgraph, debug=True) ``` -------------------------------- ### Basic Module Usage Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html A simple example demonstrating how to import the dot2tex module and convert a DOT graph string to TikZ LaTeX code. ```python import dot2tex testgraph = """ digraph G { a -> b -> c -> a; } """ texcode = dot2tex.dot2tex(testgraph, format='tikz', crop=True) ``` -------------------------------- ### Install dot2tex with sudo using pip Source: https://dot2tex.readthedocs.io/en/latest/installation_guide.html On Linux or Mac OS X, you may need to use sudo with pip to install dot2tex, especially if you do not have the necessary permissions to install packages globally. ```bash $ sudo pip install dot2tex ``` -------------------------------- ### Convert DOT to xdot and then to LaTeX Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This example demonstrates piping the xdot output from Graphviz's 'dot' command to dot2tex for conversion to LaTeX. Output is saved to 'test.tex'. ```bash $ dot -Txdot test.dot | dot2tex > test.tex ``` -------------------------------- ### Using dot2tex as a Library Source: https://dot2tex.readthedocs.io/en/latest/changelog.html Example of how to use dot2tex as a Python library to convert a DOT graph string to TikZ code. ```python import dot2tex testgraph="digraph G {a_1-> a_2 -> a_3 -> a_1;}" texcode = dot2tex.dot2tex(testgraph,format='tikz',crop=True) ``` -------------------------------- ### Positions Output Format Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Example of using the 'positions' format to get a dictionary of node names and their (x, y) coordinates from a DOT graph. ```python >>> import dot2tex >>> testgraph = """ ... digraph G { ... a -> b -> c -> a; ... } """ >>> dot2tex.dot2tex(testgraph, format='positions') {'a': [54, 162], 'b': [27, 90], 'c': [54, 18]} ``` -------------------------------- ### Convert DOT using neato and save to LaTeX Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This example uses the 'neato' layout program from Graphviz to generate xdot, which is then piped to dot2tex for conversion to LaTeX, saving the output to 'test.tex'. ```bash $ neato -Txdot -Gstart=rand test.dot | dot2tex > test.tex ``` -------------------------------- ### Convert DOT to TikZ using neato layout Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This example is similar to the previous one but explicitly specifies 'neato' as the Graphviz layout program for processing 'test.dot' before converting to TikZ format. ```bash $ dot2tex --prog=neato -ftikz test.dot > testtikz.tex ``` -------------------------------- ### PGF Output Code Example Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Example of PGF code generated by dot2tex for a simple graph. Note the explicit drawing commands for nodes and edges. ```tex % Edge: a -- b \draw [] (19bp,38bp) -- (19bp,60bp); % Edge: b -- c \draw [] (35bp,70bp) -- (55bp,58bp); % Edge: c -- a \draw [] (55bp,40bp) -- (35bp,28bp); % Node: a \begin{scope} \pgfsetstrokecolor{black} \draw (19bp,19bp) ellipse (18bp and 19bp); \draw (19bp,19bp) node {$a$}; \end{scope} % Node: b \begin{scope} \pgfsetstrokecolor{black} \draw (19bp,79bp) ellipse (18bp and 19bp); \draw (19bp,79bp) node {$b$}; \end{scope} % Node: c \begin{scope} \pgfsetstrokecolor{black} \draw (71bp,49bp) ellipse (18bp and 19bp); \draw (71bp,49bp) node {$c$}; \end{scope} ``` -------------------------------- ### Command to Generate Graph with To Paths Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Example command for processing a DOT file with 'topath' attributes using dot2tex to generate TikZ output. ```bash $ circo -Txdot topaths1.dot | dot2tex -ftikz > topaths1.tex ``` -------------------------------- ### TikZ Output Code Example Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Example of TikZ code generated by dot2tex for the same graph. This format is more concise and uses node references. ```tex \node (a) at (19bp,19bp) [draw,circle,] {$a$}; \node (b) at (19bp,79bp) [draw,circle,] {$b$}; \node (c) at (71bp,49bp) [draw,circle,] {$c$}; \draw [] (a) -- (b); \draw [] (b) -- (c); \draw [] (c) -- (a); ``` -------------------------------- ### Extracting LaTeX Labels for Graphviz Nodes and Edges Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This example demonstrates a Graphviz graph with LaTeX labels for nodes and edges. It is used to illustrate the preprocessing capabilities of dot2tex. ```dot digraph G { node [shape=circle]; a_1 [texlbl="$x^2+\frac{\sin y}{y^2+\cos \beta}+\gamma_3$"]; a_1 -> a_2 [label=" ", texlbl="$x_1+x_3^2+z+c+v~~"]; a_2 -> a_1; } ``` -------------------------------- ### Graph with Record Node for Vertical Alignment Example Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Defines a graph with a record-shaped node and a rectangle node to demonstrate vertical label alignment issues. ```dot digraph G { node0 [label="{left|right}", shape=record]; node1 [shape=rectangle, label="node 1"]; node0 -> node1; rankdir=LR; } ``` -------------------------------- ### Changing Arrow Types with PSTricks Styles Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Example of customizing arrow types for PSTricks output using the 'style' attribute and specifying a preamble for LaTeX packages. ```dot digraph G { d2tdocpreamble="\usepackage{pstricks-add}"; graph [mindist=0.5]; node [texmode="math", fixedsize=true, shape=circle, width=0.4]; c -> n_1 [style="arrows=->"]; c -> n_2 [style="arrows=->>"]; c -> n_3 [style="arrows=-<"]; c -> n_4 [style="arrows=-*"]; c -> n_5 [style="arrows=-{]}"]; c -> n_6 [style="arrows=-o"]; c -> n_7 [style="arrows=-H"]; } ``` -------------------------------- ### Annotate DOT Graph in LaTeX with dot2tex and TikZ Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Embed and annotate DOT graphs using dot2tex with the 'codeonly' and 'tikz' options. This example demonstrates advanced styling and path highlighting. ```latex \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows,shapes} \usepackage{dot2texi} \begin{document} % Define layers \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} % The scale option is useful for adjusting spacing between nodes. % Note that this works best when straight lines are used to connect % the nodes. \begin{tikzpicture}[>=latex',scale=0.8] % set node style \tikzstyle{n} = [draw,shape=circle,minimum size=2em, inner sep=0pt,fill=red!20] \begin{dot2tex}[dot,tikz,codeonly,styleonly,options=-s -tmath] digraph G { node [style="n"]; A_1 -> B_1; A_1 -> B_2; A_1 -> B_3; B_1 -> C_1; B_1 -> C_2; B_2 -> C_2; B_2 -> C_3; B_3 -> C_3; B_3 -> C_4; } \end{dot2tex} % annotations \node[left=1em] at (C_1.west) (l3) {Level 3}; \node at (l3 |- B_1) (l2){Level 2}; \node at (l3 |- A_1) (l1) {Level 1}; % Draw lines to separate the levels. First we need to calculate % where the middle is. \path (l3) -- coordinate (l32) (l2) -- coordinate (l21) (l1); \draw[dashed] (C_1 |- l32) -- (l32 -| C_4); \draw[dashed] (C_1 |- l21) -- (l21 -| C_4); \draw[<->,red] (A_1) to[out=-120,in=90] (C_2); % Highlight the A_1 -> B_1 -> C_2 path. Use layers to draw % behind everything. \begin{pgfonlayer}{background} \draw[rounded corners=2em,line width=3em,blue!20,cap=round] (A_1.center) -- (B_1.west) -- (C_2.center); \end{pgfonlayer} \end{tikzpicture} \end{document} ``` -------------------------------- ### Applying Figure Preamble After Preprocessing Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html After preprocessing, apply specific figure preamble settings like font size adjustments. This example applies a \Huge font size to the preprocessed file. ```bash $ dot2tex --figpreamble="\Huge" ex1tmp.dot > ex1huge.tex ``` -------------------------------- ### Dot Parser with Quoted Strings Source: https://dot2tex.readthedocs.io/en/latest/changelog.html Examples of how the dot parser handles quoted strings, including escaped quotes and newline characters within strings. ```dot label="A \"quote\"" label="\n\nA" ``` -------------------------------- ### Customizing Graph Appearance with Styles Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Use the 'style' attribute in DOT language to modify graph, node, and edge appearance. This example demonstrates PGF/TikZ specific styles for nodes and edges. ```dot graph G { node [shape=circle, fixedsize=True, width="0.2", style="ball color =green", label=""]; edge [style="snake=zigzag, green"]; a_1 -- c -- a_2; c [style="ball color=black"]; edge [style="snake=snake, blue"]; node [style="ball color = red", label=""]; a_3 -- c -- a_4 --a_3; } ``` -------------------------------- ### Using Autosize Option Source: https://dot2tex.readthedocs.io/en/latest/changelog.html Demonstrates how to use the --autosize option for preprocessing graph commands. ```bash > dot2tex --preproc ex.dot | dot2tex ``` -------------------------------- ### Run dot2tex with Preprocessing and Graphviz Layout Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command demonstrates a common workflow where the graph is first preprocessed using LaTeX and the preview package, and then piped to dot2tex again for layout using Graphviz. This is equivalent to using the --autosize option. ```bash $ dot2tex --preproc ex1.dot | dot2tex ``` -------------------------------- ### Using a Custom Template Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Illustrates how to specify a custom LaTeX template for the output using the `template` keyword argument. ```APIDOC ## Custom Template To specify a template you can use the `template` option like this: ```python import dot2tex mytemplate = "<>" texcode = dot2tex.dot2tex(graph, template = mytemplate) ``` ``` -------------------------------- ### Set dot2tex Options with d2toptions Attribute Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Use the 'd2toptions' attribute within your dot source to specify command-line options. This avoids repeatedly typing them. ```dot digraph G { d2toptions ="-tikz -tmath --tikzedgelabels"; ... } ``` -------------------------------- ### Basic dot2tex Command Line Syntax Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This shows the general syntax for invoking dot2tex from the command line. Input is read from stdin if no file is specified, and output goes to stdout unless redirected. ```bash dot2tex [options] [inputfile] ``` -------------------------------- ### Applying Styles with fdp and dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Command-line usage for applying styles to a DOT file using 'fdp' for layout and 'dot2tex' for conversion to TikZ, with the '-s' option to force straight lines. ```bash $ fdp -Txdot ball.dot | dot2tex -ftikz -s > balls.tex ``` -------------------------------- ### Basic Usage of dot2tex Module Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Demonstrates the fundamental way to use the dot2tex function from the module to convert a DOT graph string into LaTeX code. ```APIDOC ## Basic Usage It is possible to load dot2tex as a module for use in other Python programs. Here is a basic example: ```python import dot2tex testgraph = """ digraph G { a -> b -> c -> a; } """ texcode = dot2tex.dot2tex(testgraph, format='tikz', crop=True) ``` ``` -------------------------------- ### Chaining Preprocessing and Conversion Commands Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command chains the preprocessing and conversion steps of dot2tex into a single pipeline, improving efficiency. ```bash $ dot2tex -tmath --preproc example.dot | dot2tex > example.tex ``` -------------------------------- ### Preprocessing for Consistent Output Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Use the --preproc option to preprocess the DOT file, ensuring consistency between preprocessing and final output. This is crucial when using --figonly to include code in a master document, preventing font size mismatches. ```bash $ dot2tex --preproc -tmath --nominsize ex1.dot > ex1tmp.dot ``` -------------------------------- ### Debugging and Log Retrieval Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Demonstrates how to enable debugging in dot2tex and retrieve the generated log output using get_logstream. ```python import dot2tex texcode = dot2tex.dot2tex(testgraph, debug=True) logstream = dot2tex.get_logstream() print logstream.getvalue() ``` -------------------------------- ### Debugging with `get_logstream` Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Explains how to enable debugging output using `debug=True` and retrieve the log content using the `get_logstream` function. ```APIDOC ## Debugging You can set `debug=True` to create a detailed log useful for debugging. To retrieve the content of the log you can use the `get_logstream` function. It will return a `StringIO` instance. You can then use the `getvalue()` class method to get the actual text. Example: ```python import dot2tex texcode = dot2tex.dot2tex(testgraph, debug=True) logstream = dot2tex.get_logstream() print logstream.getvalue() ``` ``` -------------------------------- ### dot2tex Function Signature and Arguments Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Explains the signature of the main `dot2tex` function and its input arguments, including the DOT source and keyword arguments for conversion options. ```APIDOC ## `dot2tex` Function The `dot2tex` function is the main interface: ```python dot2tex(dotsource,**kwargs) ``` It takes the following input arguments: Argument | Description ---|--- `dotsource` | A string containing a DOT or XDOT graph. `**kwargs` | An arbitrary number of conversion options passed as keyword arguments The function returns the resulting LaTeX code as a string. ``` -------------------------------- ### Specifying a Custom Template Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Shows how to use the 'template' option to provide a custom LaTeX template for the graph output. ```python import dot2tex mytemplate = "<>" texcode = dot2tex.dot2tex(graph, template = mytemplate) ``` -------------------------------- ### Basic Dot2tex Conversion to Math LaTeX Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command converts a Graphviz dot file to a math LaTeX file using dot2tex. It assumes the input dot file contains LaTeX labels. ```bash $ dot2tex -tmath example.dot > example.tex ``` -------------------------------- ### Specifying Document Preamble with dot2tex Option Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Includes a LaTeX document preamble using the '--docpreamble' option with dot2tex, useful for loading packages like 'pstricks-add'. ```bash $ ... | dot2tex -fpst --docpreamble="\usepackage{pstricks-add}" ... ``` -------------------------------- ### Rendering PSTricks Arrows with dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Command to render a DOT file with PSTricks arrow styles to a PSTricks output using 'circo' and 'dot2tex'. ```bash $ circo -Txdot pstarrows.dot | dot2tex -fpst > pstarrows.tex ``` -------------------------------- ### Generate PGF Output with dot2tex Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html This command renders a graph using the 'pgf' output format. The generated code is more verbose. ```bash $ circo -Txdot simple.dot | dot2tex -tmath -fpgf -s ``` -------------------------------- ### Using the `positions` Output Format Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html Describes the special `positions` output format available when using the module, which returns node positions as a dictionary. ```APIDOC ## `positions` Output Format When you use dot2tex as a module you have access to the special `positions` output format if you use `format=positions`. The `dot2tex` function will then return dictionary with node name as key and a (x, y) tuple with the center position of the node as value: ```python >>> import dot2tex >>> testgraph = """ digraph G { a -> b -> c -> a; } """ >>> dot2tex.dot2tex(testgraph, format='positions') {'a': [54, 162], 'b': [27, 90], 'c': [54, 18]} ``` ``` -------------------------------- ### Rendering PGF Arrows with dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Command to render a DOT file with PGF arrow styles to a math-formatted TikZ output using 'circo' and 'dot2tex'. ```bash $ circo -Txdot pgfarrows.dot | dot2tex -tmath > pgfarrows.tex ``` -------------------------------- ### Clone dot2tex development version from GitHub Source: https://dot2tex.readthedocs.io/en/latest/installation_guide.html To obtain the latest development version of dot2tex, clone the repository from GitHub using the git clone command. This is suitable for developers who want to work with the most recent code. ```bash git clone https://github.com/kjellmf/dot2tex.git ``` -------------------------------- ### Graph with Mixed TeX Modes and Attributes Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Demonstrates using texlbl for a specific node and setting texmode attribute for nodes and edges. Note the escaping of backslashes in the label attribute. ```dot digraph G { a_1 [texlbl="$\\frac{\\gamma}{2x^2+y^3}$"]; a_1 -> a_2 -> a_3 -> a_1 node [texmode="math"]; a_1 -> b_1 -> b_2 -> a_3; b_1 [label="\\frac{\\gamma}{x^2}"]; node [texmode="verbatim"] b_4 [label="\\beta"] a_3 -> b_4 -> a_1; } ``` -------------------------------- ### Command to Generate State Machine with TikZ Edge Labels Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Command to generate TikZ output for a state machine graph, incorporating 'tikzedgelabels' and style options. ```bash neato -Txdot fsm1.dot | dot2tex -ftikz --tikzedgelabels --styleonly ``` -------------------------------- ### Parsing Output Format Source: https://dot2tex.readthedocs.io/en/latest/changelog.html This snippet demonstrates how to pipe the output of one dot2tex command to another for parsing the output format. It was used to fix a parsing bug. ```bash dot2tex --preproc example.dot | dot2tex ``` -------------------------------- ### Preprocess and Convert Graph for Correct Sizing Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Uses the --preproc option to preprocess the graph before conversion, ensuring correctly sized nodes when using LaTeX markup in labels. ```bash $ dot2tex --preproc ex4.dot | dot2tex > ex4.tex ``` -------------------------------- ### Include External Dot File Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html This command allows dot2tex to load and convert an external .dot file, which is useful when integrating with the dot2texi package without embedding dot code directly into the document. ```latex \input{filename.dot} ``` -------------------------------- ### Preprocessing Graph for Accurate LaTeX Label Sizing Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command preprocesses the graph using dot2tex to accurately size nodes and edges based on their LaTeX labels. The output is then processed by dot2tex again. ```bash $ dot2tex -tmath --preproc example.dot > exampletmp.dot $ dot2tex exampletmp.dot > example.tex ``` -------------------------------- ### Changing Arrow Types with PGF/TikZ Styles Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Demonstrates changing arrow types in PGF/TikZ output using the 'style' attribute on edges. Requires 'circo' for layout and 'dot2tex' for conversion. ```dot digraph G { graph [mindist=0.5]; node [fixedsize=true, shape=circle, width=0.4, style="fill=green!20"]; c -> n_1 [style="-stealth"]; c -> n_2 [style="-to"]; c -> n_3 [style="-latex"]; c -> n_4 [style="-diamond"]; c -> n_5 [style="-o"]; c -> n_6 [style="{-]}"]; c -> n_7 [style="-triangle 90"]; c -> n_8 [style="-hooks"]; c -> n_9 [style="->>"]; c [style="fill=red!80"]; } ``` -------------------------------- ### Convert DOT to TikZ format using dot2tex Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command reads 'test.dot', converts it to xdot, and then uses dot2tex to output the graph in TikZ format to 'testtikz.tex'. ```bash $ dot2tex -ftikz test.dot > testtikz.tex ``` -------------------------------- ### Convert Graph to LaTeX with Math Mode Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Converts a DOT graph file to a LaTeX file using the 'math' TeX mode for labels. ```bash $ dot2tex -tmath ex1.dot > ex1.tex ``` -------------------------------- ### Generate TikZ Output with dot2tex Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html This command renders a graph using the 'tikz' output format. The generated code is more compact and easier to modify. ```bash $ circo -Txdot simple.dot | dot2tex -tmath -ftikz -s ``` -------------------------------- ### Edge Compass Points in TikZ Source: https://dot2tex.readthedocs.io/en/latest/changelog.html Illustrates the translation of edge compass points in dot notation to TikZ drawing commands. ```dot a.n -> b.e ``` -------------------------------- ### Enable Debugging for Template Errors Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html When developing custom templates, use the --debug option to generate a dot2tex.log file. This file contains detailed information, including the generated LaTeX code and compilation logs, to help identify errors. ```bash $ dot2tex --preproc --debug test.dot ``` -------------------------------- ### Setting Default Arrow Style with dot2tex Option Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Sets a default arrow style for the entire graph using the '--graphstyle' command-line option with dot2tex. ```bash $ dot2tex -tmath --graphstyle=">=diamond" ex1.dot > ex1gstyle.tex ``` -------------------------------- ### State Machine Graph Definition with Automata Library Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html A state machine graph definition utilizing the 'automata' TikZ library and 'topath' for edge routing, including custom styles. ```dot digraph G { d2tdocpreamble = "\usetikzlibrary{automata}"; d2tfigpreamble = "\tikzstyle{every state}= \ [draw=blue!50,very thick,fill=blue!20]"; node [style="state"]; edge [lblstyle="auto",topath="bend left"]; A [style="state, initial"]; A -> B [label=2]; A -> D [label=7]; B -> A [label=1]; B -> B [label=3,topath="loop above"]; B -> C [label=4]; C -> F [label=5]; F -> B [label=8]; F -> D [label=7]; D -> E [label=2]; E -> A [label="1,6"]; F [style="state,accepting"]; } ``` -------------------------------- ### Preprocessing Graph with --nominsize Option Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command preprocesses the graph using dot2tex with the --nominsize option, which disables minimum node sizes and allows label widths and margins to solely determine node dimensions. ```bash $ dot2tex -tmath --preproc --nominsize example.dot | dot2tex > example.tex ``` -------------------------------- ### Automatic Sizing with Autosize Option Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html This command uses the --autosize option in dot2tex to automatically adjust node and edge sizes based on their LaTeX labels, simplifying the preprocessing workflow. ```bash $ dot2tex -tmath --autosize example.dot > example.tex ``` -------------------------------- ### Convert Graph with Dot Vertical Alignment and PGF Anchor Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Converts a DOT graph file to LaTeX using --valignmode=dot and --graphstyle="anchor=base" for PGF/TikZ, setting the alignment point to the baseline for better vertical alignment. ```bash $ dot2tex --valignmode=dot --graphstyle="anchor=base" valign.dot ``` -------------------------------- ### Convert Graph with Dot Vertical Alignment and PSTricks Anchor Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Converts a DOT graph file to LaTeX using --valignmode=dot and --alignstr=B for PSTricks, setting the alignment string to 'B' (bottom) for better vertical alignment. ```bash $ dot2tex --valignmode=dot --alignstr=B valign.dot ``` -------------------------------- ### Using Node and Edge Options in TikZ Output Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Customizes TikZ output by wrapping node and edge drawing code in 'scope' environments using '--nodeoptions' and '--edgeoptions' or corresponding graph attributes. ```dot ... \begin{scope}[nodeoptions] % code for drawing nodes \end{scope} \begin{scope}[edgeoptions] % code for drawing edges \end{scope} ... ``` -------------------------------- ### Graph with Raw TeX Label using texlbl Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Defines a graph where a node's label is specified as a raw TeX string using the texlbl attribute, allowing for LaTeX math expressions. ```dot digraph G { a_1 [texlbl="$\\frac{\\gamma}{x^2}$"]; a_1-> a_2 -> a_3 -> a_1; } ``` -------------------------------- ### Crop Code for PGF/TikZ Preview in dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html This snippet is used with the `--preview` option in dot2tex for PGF/TikZ output. It configures the preview environment to tightly crop the generated image. ```latex \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{<>} ``` -------------------------------- ### Graph Definition for To Paths Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Defines a directed graph with specific 'topath' attributes to control edge routing and appearance. ```dot digraph G { mindist = 0.5; node [shape="circle"]; a -> b [topath="bend right"]; c -> b [topath="bend left"]; c -> a [topath="out=10,in=-90"]; b -> b [topath="loop above"]; } ``` -------------------------------- ### Default pstricks Template for dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html This is the default template used by dot2tex for generating pstricks output. It includes necessary LaTeX packages and defines sections for preprocessing, output, and figure-only modes. ```latex \documentclass{article} % <> \usepackage[x11names]{xcolor} \usepackage[<>]{inputenc} \usepackage{graphicx} \usepackage{pstricks} \usepackage{amsmath} <>% \usepackage[active,auctex]{preview} <>% <>% <>% \begin{document} \pagestyle{empty} <>% <>% <>% <>% \enlargethispage{100cm} % Start of code \begin{pspicture}[linewidth=1bp<>]<> \pstVerb{2 setlinejoin} % set line join style to 'mitre' <>% <> <>% \end{pspicture} % End of code <>% \end{document} % <> \begin{pspicture}[linewidth=1bp<>]<> \pstVerb{2 setlinejoin} % set line join style to 'mitre' <>% <> <>% \end{pspicture} <> ``` -------------------------------- ### Basic Graph Definition Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Defines a simple directed graph with three nodes and cyclic edges. ```dot digraph G { a_1-> a_2 -> a_3 -> a_1; } ``` -------------------------------- ### Generated TikZ Code for To Paths Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html The resulting TikZ code generated from a DOT file using 'topath' attributes, demonstrating custom edge routing. ```tex \draw [->] (a) to[bend right] (b); \draw [->] (c) to[bend left] (b); \draw [->] (c) to[out=10,in=-90] (a); \draw [->] (b) to[loop above] (b); ``` -------------------------------- ### Convert Graph with Dot Vertical Alignment Mode Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Converts a DOT graph file to LaTeX using the --valignmode=dot option to improve vertical label alignment by using Graphviz coordinates. ```bash $ dot2tex --valignmode=dot valign.dot ``` -------------------------------- ### Convert Graph with Default Vertical Alignment Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Converts a DOT graph file to LaTeX using default settings, which may result in misaligned labels for certain node shapes. ```bash $ dot2tex valign.dot ``` -------------------------------- ### Styling Labels with lblstyle Attribute Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Applies styles to node, edge, and graph labels using the 'lblstyle' attribute, specifically for PGF/TikZ output. Styles are passed as parameters to the TikZ node drawing command. ```dot digraph G { node [shape=circle]; a -> b [label="label",lblstyle="draw=red,cross out"]; b -> c [label="test",lblstyle="below=0.5cm,rotate=20,fill=blue!20"]; a [label="aa",lblstyle="blue"]; b [lblstyle="font=\\Huge"]; c [label="ccc", lblstyle="red,rotate=90"]; label="Graph label"; lblstyle="draw,fill=red!20"; rankdir=LR; } ``` -------------------------------- ### Default PGF/TikZ Template for dot2tex Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html This is the default template used by dot2tex for generating PGF/TikZ output. It includes necessary LaTeX packages and defines sections for preprocessing, output, and figure-only modes. ```latex \documentclass{article} \usepackage[x11names, rgb]{xcolor} \usepackage[<>]{inputenc} \usepackage{tikz} \usetikzlibrary{snakes,arrows,shapes} \usepackage{amsmath} <>% \usepackage[active,auctex]{preview} <>% <>% <>% <>% \begin{document} \pagestyle{empty} % <>% <> <>% % <> \enlargethispage{100cm} % Start of code % \begin{tikzpicture}[anchor=mid,>=latex',join=bevel,<>] \begin{tikzpicture}[>=latex',join=bevel,<>] \pgfsetlinewidth{1bp} <>% <> <>% \end{tikzpicture} % End of code <> % \end{document} % <> \begin{tikzpicture}[>=latex,join=bevel,<>] \pgfsetlinewidth{1bp} <>% <> <>% \end{tikzpicture} <> ``` -------------------------------- ### Default Edge Drawing Code (Without TikZ Edge Labels) Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Illustrates the PGF/TikZ code generated for drawing edges and their labels without the --tikzedgelabel option. ```tex % Edge: a -- b \draw [] (28bp,55bp) -- (28bp,75bp); \draw (40bp,65bp) node[mystyle] {ab}; % Edge: b -- c \draw [] (51bp,88bp) -- (68bp,78bp); \draw (66bp,96bp) node[mystyle] {bc}; % Edge: c -- a \draw [] (69bp,51bp) -- (52bp,41bp); \draw (53bp,57bp) node[mystyle] {ca}; ``` -------------------------------- ### PSTricks rput Alignment String Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html This attribute is used to pass a default alignment string to the PSTricks \rput command for custom alignment in diagrams. ```latex \rput[d2talignstr] ... ``` -------------------------------- ### Dot Parser String Concatenation Source: https://dot2tex.readthedocs.io/en/latest/changelog.html Demonstrates the dot parser's support for concatenating double-quoted strings using the '+' character. ```dot a [label="partA" + "partB" + "partC"]; ``` -------------------------------- ### Graph with Adjusted Font Size for Better Alignment Source: https://dot2tex.readthedocs.io/en/latest/usage_guide.html Defines a graph with a node font size set to 10pt to achieve better vertical label alignment with LaTeX, compensating for default font size differences. ```dot digraph G { node [fontsize=10]; node0 [label="{left|right}", shape=record]; node1 [shape=rectangle, label="node 1"]; node0 -> node1; rankdir=LR; } ``` -------------------------------- ### Edge Drawing Code With TikZ Edge Labels Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Shows the simplified PGF/TikZ code generated for edges when the --tikzedgelabels option is enabled. ```tex \draw [] (a) -- node[mystyle] {ab} (b); \draw [] (b) -- node[mystyle] {bc} (c); \draw [] (c) -- node[mystyle] {ca} (a); ``` -------------------------------- ### Embed DOT Graph in LaTeX with dot2tex Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html Use the dot2tex package to automatically process DOT graphs within your LaTeX document. Ensure shell escape is enabled for automatic execution of dot2tex. ```latex \documentclass{article} \usepackage{dot2texi} \usepackage{tikz} \usetikzlibrary{shapes,arrows} \begin{document} \begin{dot2tex}[neato,options=-tmath] digraph G { node [shape="circle"]; a_1 -> a_2 -> a_3 -> a_4 -> a_1; } \end{dot2tex} \end{document} ``` -------------------------------- ### Increase Font Size with Figure Preamble Source: https://dot2tex.readthedocs.io/en/latest/tipsandtricks.html To increase the font size of labels in the generated LaTeX, insert a \Huge command in the figure preamble. This is useful for making labels more prominent. ```bash $ dot2tex -tmath --figpreamble="\Huge" ex1.dot > ex1huge.tex ``` -------------------------------- ### dot2tex Function Signature Source: https://dot2tex.readthedocs.io/en/latest/module_guide.html The main interface function for the dot2tex module. It accepts a DOT/XDOT source string and various keyword arguments for conversion options. ```python dot2tex(dotsource,**kwargs) ``` -------------------------------- ### Graph Definition for TikZ Edge Labels Source: https://dot2tex.readthedocs.io/en/latest/customization_guide.html Defines a simple graph structure with nodes and edges, intended for use with the --tikzedgelabel option. ```dot graph G { mindist = 0.5; node [shape="circle"]; edge [lblstyle="mystyle"]; a -- b [label="ab"]; b -- c [label="bc"]; c -- a [label="ca"]; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.