3

I try to draw an LTS instead of an automata, but I don't know whether TikZ has any specific options for LTS, so I tried to draw an automata, but in LTS you don't have usually circles around the states, so now I need to remove the circles in the states. I have the following code segment:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,arrows,positioning}

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 1, transform shape]

    \node[initial,state,initial text=]  (1A)                    {$1A$};
    \node[state]                        (1B)    [below of=1A]   {$1B$};
    \node[state]                        (2A)    [right of=1A]   {$2A$};

    \path[->] (1A) edge [loop above]    node    {$a$}           (1A)
              (1A) edge [bend left=10]  node    {$b$}           (1B)
              (1A) edge [bend left=10]  node    {$c$}           (2A);

    \end{tikzpicture}
\end{figure}
\end{document}

How can I draw an LTS in TikZ, or just remove the circles from the states of the automata above? Also, is it possible to change the placement of the text on edges? For example, the transition value is always written at the middle of the edge, is it possible to somehow push it closer to one state or the other (only for certain edges, not all of them)?

3

The style of a state node is determined by the state without output style, so you could add draw=none to that style in order to remove the node border for all state nodes, i.e. state without output/.append style={draw=none}. To reduce the size, you will also have to set the minimum size, and adjust the inner sep, e.g. state without output/.append style={draw=none,inner sep=2pt,minimum size=0pt}. The inner sep value defines the distance from the node content to its border, i.e. the whitespace you refer to.

However, it's actually a bit less work to just redefine the state style, i.e. state/.style={circle,inner sep=2pt}, where you can adjust the inner sep to your liking.

To shift a node along a path, use the pos=<fraction> as an option to the node, where <fraction> is a number between 0 and 1. See example below, for the $a$ and $b$ edge labels.

Note that the right of= syntax is deprecated in favor of right=of defined by the positioning library (which you have loaded), see Difference between "right of=" and "right=of" in PGF/TikZ.

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,arrows.meta,positioning}

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}[
      >=Stealth,
      shorten >=1pt,
      auto,
      node distance=5 cm,
      scale = 1,
      transform shape,
      state/.style={circle,inner sep=2pt}
      ]

    \node[initial,state,initial text=]  (1A)                    {$1A$};
    \node[state]                        (1B)    [below=of 1A]   {$1B$};
    \node[state]                        (2A)    [right=of 1A]   {$2A$};

    \path[->] (1A) edge [loop above]    node    {$a$}           (1A)
              (1A) edge [bend left=10]  node[pos=0.2]    {$b$}           (1B)
              (1A) edge [bend left=10]  node[pos=0.75]    {$c$}           (2A);

    \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

  • Thanks for the beautiful and informative answer. One quick question, as you can see after removing the circles there is plenty of free space between the beginning of the edge and the state name. Is it possible to somehow make the ends of the edges closer to the states, so that the actual empty space is not that large? – typos Dec 31 '16 at 14:33
  • @typos Of course, will update in a bit. – Torbjørn T. Dec 31 '16 at 14:34
  • @typos By the way, will there ever be an "output" in those "states"? I.e. a value or something placed right below the node text? – Torbjørn T. Dec 31 '16 at 14:39
  • Nope, there won't be any output. – typos Dec 31 '16 at 14:41
  • @typos Just updated. – Torbjørn T. Dec 31 '16 at 14:47

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.