3

Suppose we have this code

\begin{center}
        \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
            \node[state,initial, accepting] (q_0)   {$q_0$}; 
            \node[state] [right=of q_0] (q_1) {$q_1$};
            \path[->] 
            (q_0) edge node {$a,b$} (q_1)
            (q_1) edge [loop above] node {$a,b$} ();
         \end{tikzpicture}
         \captionof{figure}{This DFA represents $L_1 = \{\lambda\}$}
\end{center}

That produces: enter image description here

How do I get rid of the spacing between between the L_1 = and { }?

Is this because of the centering?

  • Apart from the linked answer I've mentioned in the comments to the answer provided, you could put the math in an \mbox. – A.Ellett Oct 11 '18 at 04:52

1 Answers1

6

This is not an answer but an extended comment that shows the importance of submitting a complete MWE. Without an MWE, one cannot reproduce your issue. If I compile

\documentclass{article}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{center}
        \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
            \node[state,initial, accepting] (q_0)   {$q_0$}; 
            \node[state] [right=of q_0] (q_1) {$q_1$};
            \path[->] 
            (q_0) edge node {$a,b$} (q_1)
            (q_1) edge [loop above] node {$a,b$} ();
         \end{tikzpicture}
         \captionof{figure}{This DFA represents $L_1 = \{\lambda\}$}
\end{center}
\end{document}

I get

enter image description here

That means that the weird behavior you are reporting does not come from the code piece that you are showing, but from something else. In many situations, when you try to write an MWE, you actually find the source of the problem yourself, and thus learn something. So

PLEASE SUMBIT A COMPLETE MWE!

The above code qualifies as an MWE: it starts with \documentclass, ends with \end{document} and can be compiled. It is also rather minimal in the sense that (as far as I can tell) no unnecessary packages are loaded.