1. ## Help with tikz

I am new to tikz and would like some help. Because this comes back with an error of equation too long on MHF, I have attached an image of what it looks like, and have pasted the code below. There are two things I would like to know:
1) How can I compress this a bit so it doesn't fill up the whole page? Like maybe make the nodes smaller or get more fine-tuned control over the arrows and arrow text? Alternatively, is there someway I can put a ... in there, like have the nodes $\displaystyle q_0, q_1,\ldots,q_9$? (This would be helpful to know anyway.)
2) How can I write a loop to shorten the code?
If you can answer either or both of these, I would be very grateful.

Code:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\node[initial,accepting,state] (S) {$q_s$};
\node[accepting,state] (D) at (-2,-2) {$q_t$};
\node[state] (N4) at (5,0) {$q_4$};
\node[state] (N3) at (5,2) {$q_3$};
\node[state] (N2) at (5,4) {$q_2$};
\node[state] (N1) at (5,6) {$q_1$};
\node[state] (N0) at (5,8) {$q_0$};
\node[state] (N5) at (5,-2) {$q_5$};
\node[state] (N6) at (5,-4) {$q_6$};
\node[state] (N7) at (5,-6) {$q_7$};
\node[state] (N8) at (5,-8) {$q_8$};
\node[state] (N9) at (5,-10) {$q_9$};
\node[accepting,state] (W) at (10,0) {$q_w$};
\path (S)  edge node {$\Sigma$} (D)
edge [bend left]  node {\scriptsize$\Sigma-0$} (N0)
edge [bend left]  node {\scriptsize$\Sigma-1$} (N1)
edge              node {\scriptsize$\Sigma-2$} (N2)
edge              node {\scriptsize$\Sigma-3$} (N3)
edge              node {\scriptsize$\Sigma-4$} (N4)
edge              node {\scriptsize$\Sigma-5$} (N5)
edge              node {\scriptsize$\Sigma-6$} (N6)
edge [bend right] node {\scriptsize$\Sigma-7$} (N7)
edge [bend right] node {\scriptsize$\Sigma-8$} (N8)
edge [bend right] node {\scriptsize$\Sigma-9$} (N9)
(N0) edge [bend left]  node {\scriptsize$0$} (W)
edge [loop above] node {\scriptsize$\Sigma-0$} ()
(N1) edge [bend left]  node {\scriptsize$1$} (W)
edge [loop above] node {\scriptsize$\Sigma-1$} ()
(N2) edge              node {\scriptsize$2$} (W)
edge [loop above] node {\scriptsize$\Sigma-2$} ()
(N3) edge              node {\scriptsize$3$} (W)
edge [loop above] node {\scriptsize$\Sigma-3$} ()
(N4) edge              node {\scriptsize$4$} (W)
edge [loop above] node {\scriptsize$\Sigma-4$} ()
(N5) edge              node {\scriptsize$5$} (W)
edge [loop above] node {\scriptsize$\Sigma-5$} ()
(N6) edge              node {\scriptsize$6$} (W)
edge [loop above] node {\scriptsize$\Sigma-6$} ()
(N7) edge [bend right] node {\scriptsize$7$} (W)
edge [loop above] node {\scriptsize$\Sigma-7$} ()
(N8) edge [bend right] node {\scriptsize$8$} (W)
edge [loop above] node {\scriptsize$\Sigma-8$} ()
(N9) edge [bend right] node {\scriptsize$9$} (W)
edge [loop above] node {\scriptsize$\Sigma-9$} ();
\end{tikzpicture}
\end{center}

2. ## Re: Help with tikz

How can I compress this a bit so it doesn't fill up the whole page? Like maybe make the nodes smaller or get more fine-tuned control over the arrows and arrow text?
This is a creative question. Maybe there is a better layout for the nodes. I am also not sure how different you want the arrows and arrow text to be.

The size of the nodes is controled by the option "inner sep" (p. 175 of TikZ Manual v. 2.10), which can be negative, but it does not seem to work when the option "state" is given.

Alternatively, is there someway I can put a ... in there, like have the nodes $\displaystyle q_0, q_1,\ldots,q_9$?
The following code draws four nodes with dots between them.

Code:
\usetikzlibrary{arrows,automata,positioning}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,semithick,node distance=2cm,on grid]
\node[initial,accepting,state] (S) {$q_s$};
\node[accepting,state,below left=2 of S] (D) {$q_t$};
\node[right=5 of S,circle,fill,inner sep=1pt] (vdots) {};
\node[above=.3 of vdots,circle,fill,inner sep=1pt] {};
\node[below=.3 of vdots,circle,fill,inner sep=1pt] {};
\node[state,above=of vdots] (N1) {$q_1$};
\node[state,above=of N1] (N0) {$q_0$};
\node[state,below=of vdots] (Nn-1) {};
\node[state,below=of Nn-1] (Nn) {$q_n$};
\foreach \n/\l in {0, 1, n-1/(n-1), n}
\path (N\n) edge[loop above] node {\scriptsize$\Sigma-\l$} ();
\node[accepting,state,right=5 of vdots] (W) {$q_w$};
\path (S)  edge node {$\Sigma$} (D)
edge  node[near end] {\scriptsize$\Sigma-0$} (N0)
edge  node[near end] {\scriptsize$\Sigma-1$} (N1)
edge  node {\scriptsize$\Sigma-(n-1)$} (Nn-1)
edge  node {\scriptsize$\Sigma-n$} (Nn)
(N0) edge node {\scriptsize$0$} (W)
(N1) edge node {\scriptsize$1$} (W)
(Nn-1) edge node {\scriptsize$n-1$} (W)
(Nn) edge node {\scriptsize$n$} (W);
\end{tikzpicture}
The library "positioning" makes it possible to say "right=5 of ...".

How can I write a loop to shorten the code?
Here is how to draw the nodes N0 — N9. This works because some evaluation is done inside the coordinates.
Code:
\foreach \n in {0, ..., 9}
\node[state] (N\n) at (5,8-2*\n) {$q_\n$};
If you specify the options "node distance=2cm,on grid" after "\begin{tikzpicture}", you can do the following.
Code:
\node[state] (N0) at (5,8) {$q_0$};
\foreach \n [remember=\n as \m (initially 0)] in {1, ..., 9}
\node[state,below=of N\m] (N\n)  {$q_\n$};
You can also draw the loop arrows inside the for-loop.
Code:
\node[state] (N0) at (5,8) {$q_0$};
\foreach \n [remember=\n as \m (initially 0)] in {1, ..., 9} {
\node[state,below=of N\m] (N\n)  {$q_\n$};
\path (N\n) edge [loop above] node {\scriptsize$\Sigma-\n$} ();
}