[Tex/LaTex] How to use dot2texi in Lyx

graphslyx

I am trying to use dot2texi package in Lyx to generate graphs, and I include the following in the preamble of the document:

\usepackage[all]{xy}
\usepackage{dot2texi}
\usepackage{tikz} 
\usetikzlibrary{shapes,arrows}
\usepackage{pgfplots}
% recommended as of Pgfplots 1.3:
\pgfplotsset{compat=newest}

And I insert a block of Tex code inside my Lyx document:

\begin{dot2tex}[neato,options=-tmath]
digraph G 
{
    node [shape="circle"]; 
    a_1 -> a_2 -> a_3 -> a_4 -> a_1;
}
\end{dot2tex}}

as taken from the example here: http://www.fauskes.net/code/dot2tex/documentation/#the-dot2texi-latex-package

However, when I view the document in PDF format, it doesn't show anything nor throw any error – nothing. Btw, I am using the latest Lyx 2.0.0. Any suggestion what could have gone wrong here. Thanks.

Best Answer

I also ran into this problem and managed to fix it in the following way: The preamble:

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{dot2texi}

Not sure if the load order matters, but you need to include both the tikz the pgf packages or specify that you explicitly want to use tikz in your graphs.

The latter is done like this:

\begin{dot2tex}[neato,tikz,options=-tmath]

I'm not sure if it possible to specify this somewhere global for your whole document.

Also don't forget to enable -shell-escape in the call to pdflatex, this can be done in Preferences > File Handlers > Converters by changing the LaTeX (pdflatex) -> PDF (pdflatex) to pdflatex -shell-escape $$i.

Related Question