TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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$};
    (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} ();

(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?

share|improve this question

closed as unclear what you're asking by Torbjørn T., Joseph Wright Dec 7 '13 at 21:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

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 '13 at 18:37
On LyX 2.0.6 using MikTeX, using a copy-pasted code inside the ERT gave me no errors, and the appropriate image – Andrea L. Oct 20 '13 at 18:58
@KevinC: I didn't get any error message and the TikZ code is indeed inside an ERT box. – snakile Oct 20 '13 at 19:05
@AndreaL.: Could you please share the actual LyX file from which you have generated the pdf? – snakile Oct 20 '13 at 19:06
@snakile Yeah, no problem. Here is the main *.lyx file: This is the first document – Andrea L. Oct 20 '13 at 19:12

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}
\pgfplotsset{plot coordinates/math parser=false}
share|improve this answer
arrows isn't necessary for the code in the question. (And neither is pgfplots, backgrounds and plotmarks, for that matter.) – Torbjørn T. Nov 2 '13 at 12:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.