2

This question already has an answer here:

I'm creating a flowchart in Tikz, and I would like to connect two shapes using an arrow. The thing is, the arrow needs to end not at the centre, but rather around 80% from the left. Consider the following minimal example:

\documentclass[a4paper, 12pt]{report} % a4paper option recommended
\usepackage{tikz}
\usepackage[latin1]{inputenc}
\usetikzlibrary{shapes,arrows}

\tikzstyle{start} = [diamond, draw, fill=blue!20, 
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
    text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\tikzstyle{arrow} = [thick,->,>=stealth]


\tikzstyle{assignment} = [trapezium, trapezium left angle=80, trapezium right angle=100, minimum height=1cm, text centered, draw=black, fill=blue!30, text width=4.5cm]

\begin{document}


    \begin{center}
        \begin{tikzpicture}[node distance = 1.75cm]
            % Place nodes

            \node [start] (somedecision) {Yes/No?};

            \node [assignment, above of=somedecision,yshift=2cm, xshift=-2.25cm] (someblock) {Var $\gets$ \textit{something}};

            \node [block, below of = someblock, yshift=-2cm, xshift=-1.5cm] (someaction) {Do something};

            \draw [arrow] (somedecision.north) -- node {no} (someblock.south);

            \draw [arrow] (someblock) -- (someaction);

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

The arrow from the decision box goes to the bottom center of the upper box, but I would like it to simply go up (shortest route). Similarly, I would like the left arrow (from the upper box to the left box) to start to the left so it can go down (shortest route) to the designated box.

Is there any way of getting this done? I tried looking for it but I cannot seem to find it.

Thanks.

marked as duplicate by LaRiFaRi, Paul Gessler, Svend Tveskæg, user13907, Andrew Swann Jun 5 '15 at 13:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Please see Q52372 and Q8386. For your actual question, see Q87454. – Qrrbrbirlbel Jun 5 '15 at 12:30
  • @Qrrbrbirlbel oh yes, that is a dupe. I will mark it for closure. – LaRiFaRi Jun 5 '15 at 12:42
  • You are correct, I did not know how to search for that! Thank you. – lennyklb Jun 5 '15 at 13:16
3

The syntax for such a connection is \draw (nodeA.north) -- (nodeA|-nodeB.south);

% arara: pdflatex

\documentclass[a4paper, 12pt]{report} % a4paper option recommended
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\tikzset{%
    ,start/.style = {diamond, draw, fill=blue!20, text width=4.5em, text badly centered, inner sep=0pt}
    ,block/.style = {rectangle, draw, fill=blue!20, text width=5em, text centered, rounded corners, minimum height=4em}
    ,arrow/.style = {thick, -stealth}
    ,assignment/.style = {trapezium, trapezium left angle=80, trapezium right angle=100, minimum height=1cm, text centered, draw=black, fill=blue!30, text width=4.5cm}
}

\begin{document}    
    \begin{center}
        \begin{tikzpicture}[node distance = 3cm]
        \node [start] (somedecision) {Yes/No?};     
        \node [assignment, above left = of somedecision] (someblock) {Var $\gets$ \textit{something}};      
        \node [block, below left = 2.5cm of someblock] (someaction) {Do something};     
        \draw [arrow] (somedecision.north) -- node[fill=white]{no} (somedecision|-someblock.south);     
        \draw [arrow] (someblock) -- (someaction);      
        \end{tikzpicture}
    \end{center}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.