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. enter image description here

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.

  • 3
    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, 2017 at 12:20

5 Answers 5


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:

\usepackage{pst-node, pst-arrow, auto-pst-pdf}%


\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}%


enter image description here

  • Reading the & and `\\` sequence, I would have expected the a to be straight abouve the b. How is the (non-)alignment actually produced? Nov 5, 2017 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).

enter image description here


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.

Your example would be:



\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);


With the output: Finite State Machine example


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

A detailes PDF is: http://osl.ugr.es/CTAN/graphics/pstricks/contrib/pst-node/doc/pst-node-doc.pdf and code: http://osl.ugr.es/CTAN/graphics/pstricks/contrib/pst-node/doc/

On the next lines you can see a similar example:

enter image description here



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

 \rput(4.5,3){\circlenode{IL}{\textcolor{red}{I like}}}


 \nbput*{\small Yes}   % This line show error on compiling.

 \ncput*{\small No}   % This l





 \nbput*{\small 45 \euro}   % This line show error on compiling.

 \ncput*{\small 25 \euro }

 \ncput*{\small{\blue 15 \euro} }

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


With a tikz matrix:

\usetikzlibrary{matrix, arrows.meta, bending}

        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); 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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