6

Considering the following code:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\begin{document}
\pagestyle{empty}


% Define block styles
\tikzstyle{block} = [rectangle, draw, node distance=3cm,
    text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (A) {A};
    \node [block, right of=A] (B) {B}; 
    \node [block, below of=A] (C) {long text long text long text long
      text long text long text long text };
    % Draw edges
    \path [line] (A) -- (C);
    \path [line] (B) -- (C);
\end{tikzpicture}
\end{document}

Give as output:

enter image description here

How can I have the two arrow from A and B to be on the same side of the long text block?

Since it is a MWE, I want to keep the same code as possible (so no macro if able) and two straight lines.

6

You can use the anchors for the nodes (and shiftings if required); for example, <name>.north or <name>.<angle>, or something like

($(<name>.north)!0.5!(<name>.north east)$);

(requires the calc library).

An example showing some of these possibilities:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\begin{document}
\pagestyle{empty}


% Define block styles
\tikzstyle{block} = [rectangle, draw, node distance=3cm,
    text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (A) {A};
    \node [block, right of=A] (B) {B}; 
    \node [block, below of=A] (C) {long text long text long text long
      text long text long text long text };
    % Draw edges
    \path [line] (A) -- (C);
    \path [line] ([yshift=12pt]B.south west) -- (C.90);
    \path [line,blue] (B) -- ($(C.north)!0.5!(C.north east)$);
    \path [line,red] (B.south west) -- (C.62);
\end{tikzpicture}
\end{document}

enter image description here

  • Exactly what I need. Thank you :-) – Romain Picot Oct 16 '15 at 17:42
  • @RomainPicot You're welcome. :) – Gonzalo Medina Oct 16 '15 at 17:44

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.