2

enter image description here

How could I draw something like this in tikz ? Thanks

\documentclass{article} 
\usepackage{tikz} 
\usetikzlibrary{arrows} 
\newcommand{\midarrow}{\tikz \draw[-triangle 90] (0,0) -- +(.1,0);}

\begin{document} 
\begin{tikzpicture} 
\begin{scope}[very thick, every node/.style={sloped,allow upside down}] 
  \draw (0,0)-- node {\midarrow} (2,0); 
  \draw (2,0)-- node {\midarrow} (2,2); 
  \draw (2,0)-- node {\midarrow} (4,0); 
  \draw (4,2)-- node {\midarrow} (4,0); 
  \draw (4,0)-- node {\midarrow} (6,0); 
  \draw (4,0)-- node {\midarrow} (4,-2); 
  \draw (4,-2)-- node {\midarrow} (6,-2); 
  \draw (4,-2)-- node {\midarrow} (4,-4); 
\end{scope}
\end{tikzpicture} 
\end{document}

But how do I add the $\alpha$ and $\beta$ and arrow labels?

  • 5
    Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question. – cfr Aug 10 '14 at 20:55
  • 3
    Welcome to TeX.SX, by the way! You can have a look at our starter guide to familiarize yourself further with our format. Maybe the petri library for tikz is helpful? There is a section explaining how to use it in the manual. – cfr Aug 10 '14 at 20:56
  • A good start is that \draw[->](0,0)--(1,0); will draw an error between these coordinates. If you try and flesh this out a little people will help you. – Andrew Aug 10 '14 at 21:12
  • For a starting point, see this answers:tex.stackexchange.com/a/3165/31034 – ferahfeza Aug 10 '14 at 21:23
2

One way, using a matrix of nodes from the matrix library. Many adjustments are possible. See comments in the code for full explanations.

\documentclass[tikz]{standalone}
\usetikzlibrary{
  decorations.markings, % needed for arrows midway along paths
  matrix                % needed for "matrix of nodes"
}
\tikzset{
  mat/.style={                 % style for the matrix layout of the graph
    matrix of nodes,           % each cell contains the text of a node
    row sep=2cm,               % distance between rows
    column sep=2cm,            % distance between columns
    nodes=dot,                 % apply the `dot' style to each node in the matrix
    nodes in empty cells=false % do not draw empty cells in the matrix
  },
  dot/.style={    % style for the dots in the matrix
    fill,         % fill the node shape
    circle,       % circle node shape
    inner sep=0pt % tightly fitted to node text
  },
  con/.style={                              % style for the connecting lines
    postaction={decorate},                  % decorate path after drawing
    decoration={                            % specify the decoration
      markings,                             % mark the path
      mark=at position 0.5 with {\arrow{>}} % mark halfway along with arrow
    }
  },
  lab/.style={ % style for the path labels
    midway,    % label midway along path
    auto       % auto position, use `swap' to override
  }
}

\begin{document}
\begin{tikzpicture}
\matrix [mat] (m) { % enter the matrix :-)
  . & . & . &   \\
  . & . & . & . \\
    &   & . & . \\
    &   & . & . \\
};
\draw[con] (m-1-2) -- (m-1-1) node[lab,swap] {$b$};
\draw[con] (m-2-1) -- (m-2-2) node[lab,swap] {$a$};
\draw[con] (m-2-2) -- (m-1-2) node[lab,swap] {$b$};
\draw[con] (m-2-2) -- (m-2-3) node[lab,swap] {$a$};
\draw[con] (m-1-3) -- (m-2-3) node[lab] {$b$};
\draw[con] (m-2-3) -- (m-2-4) node[lab] {$a$};
\draw[con] (m-2-3) -- (m-3-3) node[lab] {$c$};
\draw[con] (m-3-3) -- (m-3-4) node[lab] {$c$};
\draw[con] (m-3-3) -- (m-4-3) node[lab] {$a$};
\draw[con] (m-4-3) -- (m-4-4) node[lab] {$b$};
\node[below] at (m-2-2) {$\alpha$};
\node[right] at (m-1-2) {$\beta$};
\end{tikzpicture}
\end{document}

enter image description here

0
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\newcommand{\midarrow}{\tikz \draw[-triangle 90] (0,0) -- +(.1,0);}

\begin{document}
\begin{tikzpicture}
\begin{scope}[very thick, every node/.style={sloped,allow upside down}]
  \draw (0,0)-- node {\midarrow} (2,0);
  \draw (2,0)-- node {\midarrow} (2,2);
  \draw (2,0)-- node {\midarrow} (4,0);
  \draw (4,2)-- node {\midarrow} (4,0);
  \draw (4,0)-- node {\midarrow} (6,0);
  \draw (4,0)-- node {\midarrow} (4,-2);
  \draw (4,-2)-- node {\midarrow} (6,-2);
  \draw (4,-2)-- node {\midarrow} (4,-4);
\end{scope}
\end{tikzpicture}
\end{document}

\end{document}

But how do I add the $\alpha$ and $\beta$ and arrow labels?

  • 1
    It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The StackExchange staff can merge them together for you. – Paul Gessler Aug 10 '14 at 21:45
  • @ogs: You obviously have two accounts. Ask one of the moderators to merge them and then add your answer to your original post. Please do not ask follow-up questions in an answer – user31729 Aug 10 '14 at 21:46
  • Wouldn't (1,0) node[label=60:$\alpha$] {} work? The 60 is a random angle. You could also try puttimg the alpha in the braces ans putting only an anchor=<> in the square brackets, where <> is a cardinal point. – MickG Aug 10 '14 at 22:03
  • Use \draw (-4,0)-- node {\midarrow} (4,0) node[midway, above] {$\alpha$}; – ferahfeza Aug 10 '14 at 22:23

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.