Take the 2-minute tour ×
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.

If I add syntax package, the compiler will generate errors:

Minimal Example

\documentclass[10pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{tikz}
\usetikzlibrary{arrows,shapes,automata,backgrounds,petri,positioning}

\usepackage{syntax}

\begin{document}

    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
        \node[state,initial]    (q_1)                           {$q_1$}; 
        \node[state,accepting]  (q_2)   [right=of q_1]          {$q_2$}; 
        \node[state]            (q_3)   [below right=of q_1]    {$q_3$}; 

        \path[->]
        (q_1) edge  [bend left]     node {a}            (q_2)
        (q_1) edge  [loop above]    node {b}            (q_1)
        (q_2) edge  [bend left]     node {a,b}          (q_3)
        (q_3) edge  [bend left]     node {a}            (q_2)
        (q_3) edge  [bend left]     node {b}            (q_1);

        \node [below=1cm, align=flush center,text width=8cm] at (q_3)
        {
            $M_1$
        };
    \end{tikzpicture}
\end{document}

But if I delete \usepackage{syntax}, it compiles successfully. I wonder is there a way to get around this issue? Thank you.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

This issue arises because the syntax package makes the underscore (_) active in order to improve the typesetting of code with underscores. This messes with your node name q_1, and leads to the error.

Two ways around this:

  1. Avoid using underscores in node names (and file names).
  2. Load the syntax package with the option nounderscore. You can still get the nice underscore typesetting by using \_ in your code samples.
share|improve this answer
    
Thanks a lot. But I really don't want to get rid of the _, I will go with your second solution. –  Chan Aug 5 '11 at 5:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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