4

I'm trying to embed TiKZ code in my LyX document. When exporting the document to pdf (pdflatex) I get a blank area instead of the TiKZ output. Here's what I've done:

I've added the following two lines to LaTeX Preamble:

\usepackage{tikz}
\usetikzlibrary{automata,positioning}

I've added the following to a new TeX code:

\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto]
    \node[state, initial] (q_0) {$q_0$};
    \node[state] (q_1) [above right=of q_0] {$q_1$};
    \node[state] (q_2) [below right=of q_0] {$q_2$};
    \node[state, accepting] (q_3) [below right=of q_1] {$q_3$};
    \path[->]
    (q_0) edge node {0} (q_1)
          edge node [swap] {1} (q_2)
    (q_1) edge node {1} (q_3)
          edge [loop above] node {0} ()
    (q_2) edge node [swap] {0} (q_3)
          edge [loop below] node {1} ();
\end{tikzpicture}

(The code is copied from another tex.stackexchange answer: Which package can be used to draw automata?)

What's wrong with what I've done?

7
  • Did you get any error messages? Note also that the TikZ codes should be copied into the ERT box of LyX.
    – Herr K.
    Oct 20, 2013 at 18:37
  • 1
    On LyX 2.0.6 using MikTeX, using a copy-pasted code inside the ERT gave me no errors, and the appropriate image
    – TheVal
    Oct 20, 2013 at 18:58
  • @KevinC: I didn't get any error message and the TikZ code is indeed inside an ERT box.
    – snakile
    Oct 20, 2013 at 19:05
  • @AndreaL.: Could you please share the actual LyX file from which you have generated the pdf?
    – snakile
    Oct 20, 2013 at 19:06
  • 4
    @snakile Yeah, no problem. Here is the main *.lyx file: This is the first document
    – TheVal
    Oct 20, 2013 at 19:12

1 Answer 1

1

I've used this preamble and it works with lyx 2.0.6 and miktex. I suppose you must add the arrows tikzlibrary:

\usepackage{tikz, pgf, pgfplots}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{arrows,backgrounds,plotmarks}
\pgfplotsset{width=7cm,compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
1
  • arrows isn't necessary for the code in the question. (And neither is pgfplots, backgrounds and plotmarks, for that matter.) Nov 2, 2013 at 12:37

Not the answer you're looking for? Browse other questions tagged .