1

I want to change a few things in the following picture: enter image description here
(1) Aligning the bullet (d) vertically upwards from where the picture starts.
(2) Changing direction of the arrow at q4 from right to left (in this picture, the direction is from left to right)
(3) The stretched self loops at q3 and q4 like at q2.

\documentclass[12pt,a4paper]{article}
\usepackage{enumerate}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\tikzset{every state/.style}
\begin{document}
  \begin{enumerate}[(a)]
    \item
    \item
    \item
    \item
      \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,semithick]
    \node[initial,state] (q0)                    {$q_0$};
    \node[state]         (q1) [above right of=q0]      {$q_1$};
    \node[state,accepting]         (q2) [right of=q1]      {$q_2$};
    \node[state]         (q3) [below right of=q0] {$q_3$};
    \node[state]         (q4) [above right of=q3] {$q_4$};
    \node[state,accepting]         (q5) [right of=q3,xshift=1cm] {$q_5$};
\path (q0) edge    node {0} (q1)
           edge    node[left,xshift=-0.2cm] {1} (q3)
      (q1) edge    node {1} (q2)
           edge    node[right,xshift=0.1cm] {0} (q4)
      (q2) edge [loop]        node[above] {0,1} (q2)
      (q3) edge [loop below]        node[below] {1} (q3)
           edge    node[right,xshift=0.1cm] {0} (q4)
      (q4) edge [loop right]        node {0} (q4)
           edge [bend left]        node[below] {1} (q5)
      (q5) edge [bend left]        node[above] {0} (q4)
           edge    node {1} (q3);
\end{tikzpicture}

\end{enumerate} \end{document}

I tried this to align bullets but this did not work out for me.

Manjoy Das
  • 779
  • 4
  • 15
  • Please make your code compilable. From your use of \begin{enumerate}[(a)], I guess, you use the enumerate package in your actual document. This package is missing in your MWE causing the document to not compile properly. – leandriis May 13 '21 at 08:43
  • @leandriis i have edited my post – Manjoy Das May 13 '21 at 08:48

1 Answers1

1

Like this?

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{enumerate}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,automata,
                positioning,
                quotes}

\begin{document} \begin{enumerate}[(a)] \item \item \item \item \begin{tikzpicture}[baseline={([yshift=-0.6\baselineskip] current bounding box.north)}, auto, node distance=12mm and 12mm, every edge/.style = {draw, semithick, -Stealth, shorten >=1pt}, every edge quotes/.style = {font=\small, inner sep=2pt}, every loop/.style = {looseness=12} ] \node (q0) [state, initial] {$q_0$}; \begin{scope}[nodes=state] \node (q1) [above right=of q0] {$q_1$}; \node (q2) [state, accepting, right=of q1] {$q_2$}; \node (q3) [below right=of q0] {$q_3$}; \node (q4) [above right=of q3] {$q_4$}; \node (q5) [accepting, right=of q3] {$q_5$}; \end{scope} \path (q0) edge ["0" '] (q1) edge ["1"] (q3) (q1) edge ["1"] (q2) edge ["0" '] (q4) (q2) edge [loop above, "{0,1}"] (q2) (q3) edge [loop below, "1"] ()
(q4) edge ["0" '] (q3) (q4) edge [loop right, "0"] () edge [bend left, "1"] (q5) (q5) edge [bend left, "0"] (q4) edge ["1"] (q3); \end{tikzpicture} \end{enumerate} \end{document}

  • used are positioning and quotes package
  • syntax of positioning is in this case right=of q0 etc (observe interchange of = and of in comparison in your MWE)
  • defined are styles for edges and edges quotes and loops

Edit: or by use node distance=24mm and 24mm, on grid, in above MWE, the diagram is:

enter image description here

Edit: According to OP comment, image should be aligned with word start in diagram. This can be obtained by

\begin{tikzpicture}[baseline={([yshift=-0.5ex] q0.base)},

With id the result of above MWE is:

enter image description here

Zarko
  • 296,517
  • perfect for me. just two things I want to know. what is current bounding box.north and how to put value for looseness? – Manjoy Das May 14 '21 at 06:39
  • 1
    @ManjoyDas, current bounding box is invisible box around image. Anchor north means, that image baseline is at north (top) of box, however as I understood you, you like to have aligned item and top simbol in image, so I shift image up for0.6 \baselineskip. Size of theloosenessis determined inevery loop/.style = {looseness=}intikzpicture` options. Its default value is 8, In MWE in answer it is increased to 12. if you like to have even bigger loop, just increase number. More details you can find in section 74.3 Curves, page 841, TikZ & PGF manual, version 3.1.8b. – Zarko May 14 '21 at 07:31
  • actually I wanted to align item and start at same level. – Manjoy Das May 14 '21 at 08:11
  • @ManjoyDas, that is not clear from your question. You only need to change baseline to:baseline={([yshift=-0.5ex] q0.base)},`. See addendum to answer (hopefully now answer deserve to be upvoted too :-) ) – Zarko May 14 '21 at 09:07