Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
43

You can use options such as [midway], [near start] and [near end], [very near end] to specify the location of the label. (q_0) edge [bend left=15] node [red, near end] {$a$} (q_2) (q_2) edge [bend left=15] node [blue, near start]{$b$} (q_0) (q_0) edge [bend left=15] node [green, near end] {$c$} (q_5) (q_0) edge [bend left=15] node [red, very near end] {$k$} ...


43

You can influence the degree of bending using the optional parameter of bend left and bend right. The default is bend left=30, which means that the connecting line leaves and enters the nodes at an angle of 30 degrees to the direct connecting line. bend left=20 would be a more gentle curve. If you want all your curves to curve by the same amount without ...


38

To change the position of the labels use pos=0.25to specify the position along the path. To use a \\, you need to specify the alignment of the text, so something like align=center (or you can specify the text width). You should also reconsider how you are using $ to enter and exit math mode. So something like $\$$ $ \rightarrow $ [$x$ = $x.0.\$$] should ...


33

Based on Frédérics answer and Chans comment you can just do: \documentclass[]{minimal} \usepackage{amsmath,amsfonts,amssymb} \usepackage{tikz} \usetikzlibrary{automata,positioning} \begin{document} \begin{tikzpicture}[shorten >=1pt,node distance=5cm,on grid,auto] \node[state,initial] (q_0) {$q_0$}; \path[->] (q_0) edge[loop above] node[align=...


28

You can use a \coordinate instead of a \node: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{arrows,automata} \begin{document} \begin{tikzpicture}[shorten >=1pt,node distance=2cm,>=stealth',thick] \node[state] (1) {$1$}; \coordinate[left of=1] (d1); \draw [->] (1) to[loop above] node[auto] {} (1); ...


24

That could be done by means of the option accepting (see as reference 25 Automata Drawing Library in the pgfmanual version April 25, 2012). Code (I assumed s_1 and s_3 as final states): \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata,arrows} \begin{document} \begin{figure} \begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node ...


21

You can use options sloped, anchor=center: Code: \documentclass[12pt]{article} \usepackage{tikz} \usetikzlibrary{automata,positioning,arrows} \begin{document} \begin{tikzpicture}[shorten >=2pt,node distance=4cm,on grid,auto] \node[state] (Rd) {Ready}; \node[state] (Rn) [above right =of Rd] {Run}; \...


20

You can use [yshift=<distance>] to offset your arrows. This will only work if you specify a node anchor (so for instance something like ([yshift=1ex]A.center)). Here's your example with shifted arrows. Note that I removed the empty nodes you created with node {}, they're not necessary for drawing the arrows: \documentclass[10pt]{article} \usepackage{...


17

The following code compiles: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} %\usepackage{pgfplots} %% Using pgfplots package alone works as well. \begin{document} \begin{tikzpicture} \draw [->,decorate,decoration=snake] (0,0) -- (2,0); \end{tikzpicture} \end{document} This yields the output in the manual. But as ...


15

You just need to fix a minimum size large enough, but applied to state, not to the tikzpicutre: state/.style={circle, draw, minimum size=2cm} The symmetry can be obtained changing the drawing order: \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata,arrows,calc,positioning} \begin{document} \begin{figure}%[H] \centering \...


14

It is much simpler than you might think. For example replace your first edge with this: (q_0) edge [bend left=15] node[pos=0.8] {$a$} (q_2) And play around with 0.8 number between zero and one.


14

You can add bend left or bend right or bend left=<degree> or bend right=<degree> to the edges. Here is an example: \usetikzlibrary{positioning,automata} \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid] \node[state,initial] (q_0) {$q_0$}; \node[state] (q_1) [right=of q_0] {$q_1$}; \node[state,...


13

You can adjust the width of the loop drawn by loop above using the every loop style. With a bit of creativity you can use \foreach to draw a bunch of loops. You should wrap those paths in \begin{pgfinterruptboundingbox} to avoid the loops increasing your bounding box size too much due to their support points: \documentclass{report} \usepackage{tikz} \...


13

You could also use the ++ option to specify go left 2 centimeters from the last position : \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{arrows,automata} \begin{document} \begin{tikzpicture}[thick] \node[state] (1) {$1$}; \draw [->] (1) to[loop above] node[auto] {} (1); \draw [->] (1) to[bend left] node[...


12

Adding inner sep=0pt, minimum size=0pt does the job for me. Here is the full code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata,positioning} \begin{document} \begin{tikzpicture} [->,auto,node distance=0.6cm,line width=0.4mm] \node[state,initial,inner sep=1pt,minimum size=0pt] (q) {$q$}; \node[state,accepting,inner sep=1pt,minimum ...


12

On way would be to just add it to the \path: \path[->] (A) edge [] node [draw=black, text width=3.0cm, midway, yshift=2ex] {Label} (B); Code: \documentclass{article} \usepackage{tikz} \usepackage[margin=15mm]{geometry} \usepackage{calc} \usetikzlibrary{matrix,arrows} \usetikzlibrary{positioning,arrows} \usetikzlibrary{shapes,arrows,fit,calc,...


11

\documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes} \begin{document} \begin{tikzpicture}[shorten >=1pt, node distance=2.5cm, on grid, auto,thick,initial text=,scale=0.3] \node[state, initial] (0) {0}; \node[state] (1) [above right =of 0] ...


11

I have not seen that this feature is supported by the library automata. But the arrow with text can be disabled and the drawing can be done with usual TikZ means: \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata} \begin{document} \begin{tikzpicture}[>=latex] \node[state] (q_0) {$q_0$}; \draw[<-] (q_0) -- node[above] {start} ++(-...


10

It is possible to define a state elliptic, for example by means of: \tikzset{elliptic state/.style={draw,ellipse}} The ellipse requires the library shapes.geometric. Code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,} \begin{document} \tikzset{elliptic state/.style={draw,ellipse}...


10

You can use [bend left] option as suggested in a comment, and give it an angle, such as [bend left=70], then the curve will leave then start and ending nodes at that angle, and thus the resulting path is symmetric. (a0) edge[mystyle, bend left=70] node {$\varepsilon$} (b4); However, in this particular case, since the figure is assymetric, this way of ...


10

There are several ways of solving this, here is one using the |- path specification (meaning go first vertically, then horizontally, to the next coordinate) and one relative coordinate. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning,automata} \begin{document} \begin{tikzpicture} \node[state,initial,initial text=G] (1) {$1$}; ...


9

Key initial where sets the direction (above, below, left, right), see 24.3 Initial and Accepting States of the manual. \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata,positioning} \usepackage{amstext} \begin{document} \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] \node[state,initial,initial where=above,] (q_start) ...


9

EDIT: Added LuaTeX version Probably not what is exactly wanted. Also somewhat crude, and slow. Using LuaTeX or PSTricks would be very good choice to speed this up. But I'm old fashioned and stuck in my ways, so... \documentclass[tikz]{standalone} \usepackage{tikz} % Each cell is stored globally as a macro % for example \csname cell-glider-1-7\endcsname \...


9

Something like this? Code: \documentclass[border=3mm, tikz, preview ]{standalone} \usetikzlibrary{arrows.meta,chains,positioning} \usepackage{amsmath} \begin{document} %---------------------------------------------------------------% \begin{tikzpicture}[ line width = 1pt, on grid, ...


8

using xy-pic package available at ctan for automata diagrams. \documentclass[12pt]{article} \usepackage[all]{xy} \begin{document} \xymatrix@ur@!R=2pc{% *+<1pc>[o][F-]{q_0} \ar@(l,l)[]^<<<<{start} \ar@/^/[r]^0 \ar@/_/[d]_1 & *+<1pc>[o][F-]{q_1} \ar@(ul,ur)[]^{0} \ar@/^/[d]^1 \\ *+<1pc>[o][F-]{q_2} \ar@(dr,dl)[]^{1} \ar@/...


8

For this purpose you should play with the min distance option from topaths library and specify manually the starting and ending angle of the arrows with in=...,out=.... In the following example, for demonstration, there are two other paths starting and ending always in the same point, but you could reproduce your image simply changing in=...,out=.... \...


8

A way of doing this is to simply fill the node with white, which will cover the line: \path (0) edge[bend left] node[fill=white] {01} (1); (This doesn't actually create a gap in the line though, so it only works fine when the background actually is white.) Complete code: \documentclass{article} \usepackage{pgf} \usepackage{tikz} \usetikzlibrary{automata, ...


8

Choose your option. Code \documentclass[tikz]{standalone} \usetikzlibrary{automata,positioning} \begin{document} \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] \node[state,initial] (s_0) {Start 1}; \node[state] (s_1) [right=of s_0] {Start 2}; \node[state] (s_2) [right=of s_1] {Start 3}; \path[->] (s_0) edge [bend left]...


8

Are you looking for something like this? \documentclass{amsart} \usepackage{tikz} \usetikzlibrary{automata, positioning} \begin{document} \begin{tikzpicture}[node distance=2cm,auto] \node[state,initial] (q_0) {1}; \node[state, accepting, label = below right:return(a)] (q_1) at (3,0) {2}; \node[state, accepting, label = below right:return(b)] (q_2) at (1.5,-...


8

I tried to avoid crossing arrows, still some polishing on arrows to make them look like a circle arround. \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata,arrows,calc} \begin{document} \begin{figure} \hspace{-4cm} \begin{tikzpicture}[ ->,>=stealth', shorten >=1pt, auto, node distance=5cm, thick, transform shape, %main state/.style=...


Only top voted, non community-wiki answers of a minimum length are eligible