5

I am novice guy in LaTeX. Tikz is completely new to me.

I have gone through the post How to zoom a portion of TiKZ picture?

  1. Let's say I want to write $a=(b,c)$ at the beginning of the arrow which enters S. How to do that?(according to the above question)

As per my picture, I am having a problem to put an arrow before the block A.

My try: I did the following modification to the code:

    initial text= $a=(b,c)$

It was working until I put the '=' sign between a and (b,c).

  1. Next, I want to put an arrow and text over it after the end node (D according to my picture). How to do it?

My Target is to create a picture like below-

enter image description here

Rajat
  • 235

2 Answers2

5

In the absence of a minimal working example, it is hard to be terribly helpful. (Where is S? Where did you try that code?) This is, of course, especially frustrating when it is obvious from your question that you do, in fact, have code and have simply chosen not to share it so that people have to start from scratch. This is less likely to be helpful, of course, since we can only guess what the problem might be.

That said, the image you posted can be easily drawn using the chains library and a simple loop, with a couple of tweaks to accommodate the start and end of the chain. The quotes library is used for the labelling. scopes is not really needed here but it is useful when using chains so I've included it in case your diagram grows in complexity.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{chains,scopes,quotes,arrows.meta}
\begin{document}
\begin{tikzpicture}
  [
    start chain=main going right,
    every on chain/.append style={minimum width=25mm, minimum height=10mm, draw=green!50!yellow!60, thick, text centered},
    every join/.append style={-{Triangle[]}, draw=blue!50!cyan, thick},
    node distance=20mm
  ]
  \node (in) [shape=coordinate] {};
  {
    \chainin (in);
    \foreach \i/\j in {A/{$a=(b,c)$},B/{$x$},C/{$y$},D/{$z$}}
    \node (\i) [on chain, join=by {"\j"}] {\i};
    \node (out) [every on chain/.append style={draw=none, minimum width=0pt, minimum height=0pt}, on chain, join=by {"a"} ] {};
  }
\end{tikzpicture}
\end{document}

chained nodes

cfr
  • 198,882
1

I have created a minimal, working example based on your previously mentioned post: latex4technics.com/?note=y917ox

MWE:

\documentclass[10pt,letterpaper]{article}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\thispagestyle{empty}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}

\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,automata,backgrounds,petri,positioning}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.fractals}
\usetikzlibrary{decorations.footprints}
\usetikzlibrary{shadows}

\begin{document}
    \begin{center}
        \begin{tikzpicture}[shorten >=1pt, node distance=3cm, auto, on grid, initial text={$a=(b,c)$},font=\small,>=stealth',
            every state/.style={minimum size=7mm,draw=black!50,very thick,fill=red!50}]

        \node[state,initial]        (S)                 {S};
        \node[state]                (A) [right=of S]    {A};
        \node[state]                (B) [below=of S]    {B};
        \node[state,accepting]      (C) [right=of B]    {C};

        \path[->]
        (S) edge[bend right]    node{a} (A)
        (S) edge[bend right]    node[xshift=-4mm]{$\lambda$} (B)
        (A) edge[bend right]    node[yshift=5mm]{a,b} (S)
        (A) edge[]              node{$\lambda$} (C)
        (A) edge[]              node[yshift=7mm]{b} (B)
        (B) edge[bend left]     node{b, $\lambda$} (C)
        (B) edge[bend right]    node[xshift=4mm]{a} (S)
        (C) edge[bend left]     node{a,b} (B)

        ; 
        \end{tikzpicture}
    \end{center}
\end{document}

Also you could read state machine in tikz on texample as introduction.

Can you specify your second question? Do you want to draw an arrow from the node C to the right? A sketch would help!

  • Welcome to TeX.SE! Please avoid link-only answers since the information at the link may not always be available. Also, please ask for clarification in the comments rather than in an answer (you will need to earn some reputation in order to comment). Please see the [help] for more information. – Null Dec 23 '15 at 15:04
  • Thanks for the MWE. I have uploaded a picture according to my need. Please check it out. – Rajat Dec 24 '15 at 04:07