How do I create a diagram that looks a little like this?

So I need to put some diagrams into my homework. And I have already created some of them on paper but I just can't get them into latex. Does anyone know how I'm able to get a diagram that looks a little like this into a .tex file.

I want to be able to determine on my own where the arrows go and such. I also only need 4 nodes (a, b, c and d). How can I do this in texmaker?

any help is appreciated.

• Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE). This isn't a "Please do my work for me" site! What do you have so far? - Maybe something like this?: Drawing graphs in LaTeX – Bobyandbob Nov 4 '17 at 12:20

The  psmatrix environment from pst-node can be used to make easily such diagrams. The loops are obtained with the \nccircle command, which links a node to itself counter-clockwise:

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pst-node, pst-arrow, auto-pst-pdf}%

\begin{document}

\sffamily
\def\psrowhooki{\hskip 4em}
\begin{psmatrix}[rowsep=1.2cm, colsep=1.2cm]
[name=a] a & [name=c] c \\
[name=b] b & [name=d] d & [name=e] e \\
%%%%% Arrows
\psset{nodesep=6pt, shortput =nab, arrows=->, arrowinset=0.12, arcangle=20}%
\nccircle[angle=80,]{<-}{a}{0.4cm}
\nccircle[angle=120]{b}{0.4cm}
\nccircle[angle=-40]{<-}{c}{0.4cm}
\nccircle[angle=120]{d}{0.45cm}
\nccircle[angle=-110]{<-}{e}{0.4cm}
\ncarc{c}{d}
\ncarc{d}{c}%
\ncline{d}{e}
\end{psmatrix}

\end{document}

• Reading the & and \\ sequence, I would have expected the a to be straight abouve the b. How is the (non-)alignment actually produced? – Hagen von Eitzen Nov 5 '17 at 11:35
• Have a look at package tikz-cd that builds on the famous package TikZ. tikz-cd provides commands that ease the type­setting of so-called com­mu­ta­tive di­a­grams what I guess you are trying to do.
• I attached a screenshot of the documentation (Version 0.9e).
• Your Texmaker comment has no meaning since the editor is not relevant (in this case).
• In addition, have a look at http://texample.net/tikz/examples/feature/automata-and-petri-nets/ (collection of examples).

If you want to make a Finite State Machine (such as a DFA), there is a web interface that you can use located at http://madebyevan.com/fsm/. It outputs LaTeX that uses the tikz package.

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=0.2]
\tikzstyle{every node}+=[inner sep=0pt]
\draw [black] (25.3,-12.8) circle (3);
\draw (25.3,-12.8) node {$a$};
\draw [black] (20.6,-26.9) circle (3);
\draw (20.6,-26.9) node {$b$};
\draw [black] (51,-13.4) circle (3);
\draw (51,-13.4) node {$c$};
\draw [black] (45.4,-28.1) circle (3);
\draw (45.4,-28.1) node {$d$};
\draw [black] (63.1,-26.9) circle (3);
\draw (63.1,-26.9) node {$e$};
\draw [black] (23.144,-10.731) arc (253.92142:-34.07858:2.25);
\fill [black] (25.63,-9.83) -- (26.33,-9.2) -- (25.37,-8.92);
\draw [black] (19.493,-29.676) arc (5.98721:-282.01279:2.25);
\fill [black] (17.72,-27.71) -- (16.88,-27.3) -- (16.98,-28.29);
\draw [black] (48.39,-27.9) -- (60.11,-27.1);
\fill [black] (60.11,-27.1) -- (59.27,-26.66) -- (59.34,-27.66);
\draw [black] (66.077,-26.639) arc (122.74949:-165.25051:2.25);
\fill [black] (65.12,-29.1) -- (65.13,-30.05) -- (65.97,-29.51);
\draw [black] (44.011,-30.746) arc (0.02737:-287.97263:2.25);
\fill [black] (42.45,-28.61) -- (41.65,-28.11) -- (41.66,-29.11);
\draw [black] (51.016,-10.412) arc (207.43495:-80.56505:2.25);
\fill [black] (53.38,-11.59) -- (54.32,-11.67) -- (53.86,-10.78);
\draw [black] (44.931,-25.143) arc (-177.46822:-224.2407:13.275);
\fill [black] (44.93,-25.14) -- (45.4,-24.32) -- (44.4,-24.37);
\draw [black] (50.753,-16.388) arc (-8.43582:-33.27309:23.182);
\fill [black] (50.75,-16.39) -- (50.14,-17.11) -- (51.13,-17.25);
\end{tikzpicture}
\end{center}

\end{document}

With the output:

For these kind of graphics I like very much PSTtricks package, with subpackage PST-node

On the next lines you can see a similar example:

\documentclass[pstricks,border=12pt]{standalone}
%
\usepackage[utf8]{inputenc}
\usepackage{eurosym}
\usepackage{pst-node}

\begin{document}

\begin{pspicture}(-2,-2)(12,6) %\malla

\rput(4.5,3){\circlenode{IL}{\textcolor{red}{I like}}}
\rput(8.5,3.5){\circlenode{L}{\textcolor{blue}{\LaTeX}}}
\rput(6.5,-0.5){\circlenode{G}{\textcolor{blue}{\footnotesize{Galicia(Spain)}}}}

\ncarc[arcangle=44]{->}{IL}{L}

\ncarc[arcangle=22]{->}{IL}{L}
\nbput*{\small Yes}   % This line show error on compiling.

\ncarc[arcangle=22]{->}{L}{IL}
\ncput*{\small No}   % This l

\ncarc[arcangle=8]{->}{L}{G}
\ncarc[arcangle=-22,linewidth=0.05,linecolor=red]{->}{G}{L}

\ncarc[arcangle=-22,linewidth=0.05,linecolor=red,linestyle=dashed]{->}{IL}{G}

\rput(1,2){\circlenode{V}{\textcolor{blue}{Vigo}}}
\rput(1,5){\circlenode{C}{\textcolor{magenta}{Coru\~na}}}

\rput(3,2){\circlenode{S}{\textcolor{red}{Scq}}}
\rput(3,5){\circlenode{P}{\textcolor{green}{Po}}}

\ncarc[arcangle=33]{->}{V}{C}
\nbput*{\small 45 \euro}   % This line show error on compiling.

\ncarc[arcangle=11]{->}{S}{P}
\ncput*{\small 25 \euro }

\ncarc[arcangle=75]{->}{S}{P}
\ncput*{\small{\blue 15 \euro} }

\rput(2,0){This is a test.}
\rput(8,-2){Esto é unha proba.}

\end{pspicture}
\end{document}

With a tikz matrix:

\documentclass[border=1cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{matrix, arrows.meta, bending}

\begin{document}
\begin{tikzpicture}[>=Latex]
\matrix[
column sep=0pt,
row sep=7ex,
matrix of nodes,
] (m) {
&|(a)| a &[3em]& |(c)| c &[3em]\\
|(b)| b && |(d)| d && |(e)| e \\
};
\draw[->] (a.south west) arc (290:10:1em);
\draw[->] (b.north west) arc (-290:-30:1em);
\draw[->] (c.north west) arc (180:-80:1em);
\draw[->] (d.north west) arc (-270:-30:1em);
\draw[->] (e.north east) arc (120:-160:1em);
\draw[->] (d) -- (e);
\draw[->] (d) to[bend left] (c);
\draw[->] (c) to[bend left] (d);
\end{tikzpicture}
\end{document}