2

I want to connect "boxes" in a flow chart, with arrows starting from inside the box. Doing so with "hard-coded" coordinates after trial and error seems very burdensome. Is there an efficient way to produce:

original image

Currently I have:

current

produced from this:

%% PREAMBLE %%
\documentclass[11pt, twoside, openany]{memoir}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzstyle{block} = [rectangle, draw, fill=blue!0, text width=12em, text centered, rounded corners, minimum height=2em]
\tikzstyle{smallblock} = [rectangle, draw, fill=blue!0, text width=9em, text centered, rounded corners, minimum height=2em]
\begin{tikzpicture}[node distance = 2cm, auto]
    \node [block] at (0, 0) (init) {};
    \node [block] at (-2, -1.5) (identify) {};
    \node [smallblock] at (-1.5, -3.5) (excellence) {};
    \node [block] at (3, -1.5) (pass) {};
    \node [block] at (3, -3.5) (fail) {};
    \draw[->] (-0.2, -1.5) -- +(0, 1.1) [above];
    \draw[->] (-0.2, -1.5) -- +(1, 0) [above];
    \draw[||||||->] (-2.2, -3.2) -- +(0, 1.2) [above];
\end{tikzpicture}
\end{document}

Last, how can I have a little filled square as an arrow tail? (that is, instead of \draw[||||||->]).

1

Your desired figure you can obtain width:

\documentclass[11pt,tikz,border=3mm]{standalone}
    \usetikzlibrary{arrows.meta}

    \begin{document}
\tikzstyle{smallblock} = [rectangle, draw, fill=blue!0, text width=9em, text centered, rounded corners, minimum height=2em]
    \begin{tikzpicture}[
    node distance = 2cm, auto,
     block/.style = {draw, fill=blue!0,%rounded corners, 
                     text width=12em, minimum height=2em, align=center},
smallblock/.style = {draw, fill=blue!0,%rounded corners,  
                     text width=9em, minimum height=2em, align=center},
      Line/.style = {{Square[length=4pt,width=4pt]}-%
                     {Straight Barb[length=4pt]},
                     shorten <=-2pt},
                        ]
\node[block] at (0,    0) (init)                {init};
\node[block] at (-2,-1.5) (identify)            {identify};
\node[smallblock] at (-1.5,-3.5) (excellence)   {excelence};
\node[block] at (3.5, -1.5) (pass)                {pass};
\node[block] at (3.5, -3.0) (fail)                {fail};
\draw[Line] (excellence.north -| identify) -- (identify);
\draw[Line] ([yshift=5pt] fail.west) -| (init);
\draw[Line] (init |- pass) -- (pass);
%
\draw[{Square[length=4pt,width=4pt]}-]%is square this necessary?
            ([xshift=-2pt,yshift=5pt] init |- fail) -- + (2pt,0);
    \end{tikzpicture}
    \end{document}

enter image description here but better look you will achieve if you placed blocks as proposed @Gonzalo Medina in his answer. In this cases the code is more simple and logical:

\documentclass[11pt,tikz,border=3mm]{standalone}
    \usetikzlibrary{arrows.meta,positioning}

    \begin{document}
\tikzstyle{smallblock} = [rectangle, draw, fill=blue!0, text width=9em, text centered, rounded corners, minimum height=2em]
    \begin{tikzpicture}[
     block/.style = {draw, fill=blue!0,%rounded corners, 
                     text width=12em, minimum height=2em, align=center},
smallblock/.style = {draw, fill=blue!0,%rounded corners,  
                     text width=9em, minimum height=2em, align=center},
      Line/.style = {{Square[length=4pt,width=4pt]}-%
                     {Straight Barb[length=4pt]},
                     shorten <=-2pt},
                        ]
\node[block] at (0,0) (init) {init};
\node[block,below left=1cm and 0.5cm of init.south] (iden) {identify};
\node[smallblock,
      below left=1cm and 0cm of iden.south east] (excel) {excelence};
\node[block,below right=1cm and 0.5cm of init.south] (pass) {pass};
\node[block,below=of pass] (fail) {fail};
\draw[Line] (excel.north -| iden) -- (iden);
\draw[Line] (fail.west) -| (init);
\draw[Line] (init |- pass) -- (pass);
    \end{tikzpicture}
    \end{document}

enter image description here

3

enter image description here

The code:

\documentclass[11pt, twoside, openany]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,arrows,arrows.meta}
\begin{document}
\tikzset{
  block/.style={
    rectangle, 
    draw, 
    fill=blue!0, 
    text width=12em, 
    text centered, 
    rounded corners, 
    minimum height=2em
   },
  smallblock/.style={
    rectangle, 
    draw, 
    fill=blue!0, 
    text width=9em, 
    text centered, 
    rounded corners, 
    minimum height=2em
  },
  arro/.style={{Square[]->}}
}  
\begin{tikzpicture}[node distance = 1.2cm]
    \node [block] (init) {ini};
    \node [block,below=of init,anchor=east,xshift=-20pt] (identify) {iden};
    \node [smallblock,below=of identify.south east,anchor=east] (excellence) {exce};
    \node [block,below=of init,anchor=west,xshift=20pt] (pass) {pass};
    \node [block,below=of pass.south west,anchor=west] (fail) {fail};
    \draw[arro] (excellence.north) -- (excellence.north|-identify.south);
    \draw[arro] (fail.west) -| coordinate[near end] (aux) (init.south);
    \draw[arro] (aux|-pass.west) -- (pass.west);
\end{tikzpicture}
\end{document}

Remarks,

  • To place the nodes, use the features provided by the positioning library.

  • You can access the anchors of the nodes to place the arrows. For a node called A you can say A.north, or A.south west or using angular anchors: A.130, A.40.

  • Using the arrows.meta library you can produce the arrow you a re looking with Square[].

  • Change the old \tikzset syntax to the more appropriate \tikzset syntax.

  • Thank you very much for the intuitive remarks. This is what I will use for my own use, but I chose the other answer because it exactly replicates the graph in question. – Konstantinos Jun 24 '15 at 22:29

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.