Flowchart diagram for a sample Turing Machine

I would like to create a flowchart/chains diagram for turing machines in the style as shown in the picture above. I am still relatively new to LaTeX, but I am assuming that I will have to use TikZ.

Does anyone have an idea how to draw something like this?

  • Welcome to TeX.SE. You can see, for example, this site texample.net/tikz/examples/tag/flowcharts, texample.net/tikz/examples/labeled-chain or texample.net/tikz/examples/feature/chains.
    – Sebastiano
    Jan 12, 2017 at 13:16
  • 2
    There are actually several packages for drawing diagrams, so you don't have to use TikZ. But TikZ is perhaps the most popular package (around here at least), and it is fairly easy to use. That said, with the exception of the up-left-down arrows on top, you can do that with amsmath alone, e.g. \documentclass{article} \usepackage{amsmath} \begin{document} \[ >\underset{\substack{\downarrow_{\#}\\\#}}{L} \overset{|}{\to} L \overset{\#}{\to} \mid R \overset{\#}{\to} L\# \] \end{document} Jan 12, 2017 at 13:30
  • I think, thats worth an answear, as the OP didn't insist on TikZ!
    – Jan
    Jan 12, 2017 at 14:05

1 Answer 1


As I mentioned in a comment, you can do most of that with the features of amsmath alone. In particular, I used \overset{a}{b} (which places a above b) and \underset{a}{b}, which you can probably guess what does.

In the comment I also used \substack which is intended for stacking subscripts, but in the code below that is replaced with an array.

To make the up-left-down arrow I defined a new macro \ULDarrow that uses the standard picture environment to create the arrow. It's not the best looking arrow, but I wanted to keep to the basics.

I also use mathtools instead of amsmath. mathtools loads and extends amsmath a bit. The feature from mathtools I use here is \mathrlap, which is a macro that places its argument in math mode, in a zero width box, extending to the right.

enter image description here

\newcommand\ULDarrow{% up-left-down arrow
\put(5,0){\line(0,1){7.7}}% draw a line 7.7 units up, the "extra" 0.2 (half the linewidth) is to get a better corner
\put(5,7.5){\line(-1,0){5.2}}% draw a line 5.2 units left
\put(0,7.5){\vector(0,-11){7.5}}% draw an arrow 7.5 units down

  \begin{array}{@{}c@{}}% the @{} remove spacing around column
     \downarrow^{\#} \\
  \overset{\#}{\to} \mid 
  • Thanks, that's exactly what I wanted! Surprised to see how simple it actually is without TikZ though. But yeah, thanks again for the help!
    – user122881
    Jan 13, 2017 at 10:30
  • But say, I am trying to figure out right now how I would go about defining a loop over multiple symbols. \overset{\mathrlap{\overset{\#}{\ULDarrow}}}{more than 1 symbol} doesn't do the trick. How could I go about it?
    – user122881
    Jan 15, 2017 at 10:48
  • @Rednaxel59 Do you mean that the ULDarrow should be much wider? Jan 15, 2017 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .