2

I'm trying put many arrows-connections and dotted lines between events into calendar/timetable but I have problem with 'draw' statement:

This is a picture of my actual calendar and we see a wrong arrow overlapping lines:

enter image description here

and this is what I want:

enter image description here

This is my script and I tried to draw line between node (a) to (b):

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz}
\usepackage{amssymb, amsmath}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}

\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

\usetikzlibrary[positioning]
\usetikzlibrary{patterns}
\usepackage[french]{babel} % styles français

\title{A simple Timetable}
\author{Laurent Dutriaux}
\date{\today}
\newcommand{\daywidth}{2.2 cm}
\begin{document}
\maketitle

\begin{tikzpicture}[x=\daywidth, y=-1cm, node distance=0 cm,outer sep = 0pt]

% Style for Days
\tikzstyle{room}=[draw, rectangle,  minimum height=1cm, minimum width=\daywidth, fill=yellow!20,anchor=south west]

% Style for hours
\tikzstyle{timeslots}=[draw, rectangle, minimum height=1 cm, minimum width=1.5 cm, fill=yellow!30,anchor=north east]

% Styles for events
% Duration of sequences
\tikzstyle{events}=[rectangle,draw, minimum width=\daywidth, anchor=north west,text centered,text width=5 em]

\tikzstyle{1event}=[events,minimum height=1cm]
\tikzstyle{2events}=[events,minimum height=2cm]
\tikzstyle{3event2}=[events,minimum height=3cm]

%Style for type of sequence 
\tikzstyle{Ang2h}=[1event,fill=green!20]
\tikzstyle{Phys2h}=[1event,fill=red!20]
\tikzstyle{Math2h}=[1event,fill=blue!20]
\tikzstyle{TIPE2h}=[1event,fill=blue!10]
\tikzstyle{TP2h}=[2events, pattern=north east lines, pattern color=magenta]
\tikzstyle{G3h}=[3event2, pattern=north west lines, pattern color=magenta!60!white]
\tikzstyle{Planche}=[1event,fill=white]

% Positioning labels for days and hours
\node[room] (A) at (1,8) {$r_{1}$};
\node[room] (B) [right = of A] {$r_{2}$};
\node[room] (C) [right = of B] {$r_{3}$};
\node[room] (D) [right = of C] {$r_{4}$};

\node[timeslots] (AA) at (1,8) {$t_{1}$};
\node[timeslots] (BB) [below = of AA] {$t_{2}$};
\node[timeslots] (CC) [below= of BB] {$t_{3}$};
\node[timeslots] (DD) [below = of CC] {$t_{4}$};
\node[timeslots] (EE) [below  = of DD] {$t_{5}$};

%Position of sequences
\node[Phys2h] (a) at (1,8) {$e_{8}$};   %node a
\node[Phys2h] at (1,9) {};
\node[Phys2h] at (1,10) {};
\node[Phys2h] at (1,11) {$e_{16}$};
\node[Phys2h] at (1,12) {};

\node[Math2h] at (2,8) {};
\node[Math2h] (b) at (2,9) {$e_{7}$}; %node b
\node[Math2h] at (2,10) {};
\node[Math2h] at (2,11) {$e_{20}$};
\node[Math2h] at (2,12) {};


%Here my problem.......
\draw [-latex,thick] (a) --  node [anchor=135,outer sep=2pt] { } (b) ;

\node[TIPE2h] at (3,8) {};
\node[TIPE2h] at (3,9) {};
\node[TIPE2h] at (3,10) {$e_{11}$};
\node[TIPE2h] at (3,11) {};
\node[TIPE2h] at (3,12) {};

\node[TIPE2h] at (4,8) {};
\node[TIPE2h] at (4,9) {};
\node[TIPE2h] at (4,10) {};
\node[TIPE2h] at (4,11) {};
\node[TIPE2h] at (4,12) {};

\end{tikzpicture}
\end{document}

Is there an efficient way to connect events through arrows or dotted lines?

regards,

1 Answer 1

1

Nodes are extended objects. You may connect the centers and shorten the arrows a bit.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz}
\usepackage{amssymb, amsmath}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}

\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

\usetikzlibrary[positioning]
\usetikzlibrary{patterns}
\usepackage[french]{babel} % styles français

\title{A simple Timetable}
\author{Laurent Dutriaux}
\date{\today}
\newcommand{\daywidth}{2.2 cm}
\begin{document}
\maketitle

\begin{tikzpicture}[x=\daywidth, y=-1cm, node distance=0 cm,outer sep = 0pt]

% Style for Days
\tikzstyle{room}=[draw, rectangle,  minimum height=1cm, minimum width=\daywidth, fill=yellow!20,anchor=south west]

% Style for hours
\tikzstyle{timeslots}=[draw, rectangle, minimum height=1 cm, minimum width=1.5 cm, fill=yellow!30,anchor=north east]

% Styles for events
% Duration of sequences
\tikzstyle{events}=[rectangle,draw, minimum width=\daywidth, anchor=north west,text centered,text width=5 em]

\tikzstyle{1event}=[events,minimum height=1cm]
\tikzstyle{2events}=[events,minimum height=2cm]
\tikzstyle{3event2}=[events,minimum height=3cm]

%Style for type of sequence 
\tikzstyle{Ang2h}=[1event,fill=green!20]
\tikzstyle{Phys2h}=[1event,fill=red!20]
\tikzstyle{Math2h}=[1event,fill=blue!20]
\tikzstyle{TIPE2h}=[1event,fill=blue!10]
\tikzstyle{TP2h}=[2events, pattern=north east lines, pattern color=magenta]
\tikzstyle{G3h}=[3event2, pattern=north west lines, pattern color=magenta!60!white]
\tikzstyle{Planche}=[1event,fill=white]

% Positioning labels for days and hours
\node[room] (A) at (1,8) {$r_{1}$};
\node[room] (B) [right = of A] {$r_{2}$};
\node[room] (C) [right = of B] {$r_{3}$};
\node[room] (D) [right = of C] {$r_{4}$};

\node[timeslots] (AA) at (1,8) {$t_{1}$};
\node[timeslots] (BB) [below = of AA] {$t_{2}$};
\node[timeslots] (CC) [below= of BB] {$t_{3}$};
\node[timeslots] (DD) [below = of CC] {$t_{4}$};
\node[timeslots] (EE) [below  = of DD] {$t_{5}$};

%Position of sequences
\node[Phys2h] (a) at (1,8) {$e_{8}$};   %node a
\node[Phys2h] at (1,9) {};
\node[Phys2h] at (1,10) {};
\node[Phys2h] (e) at (1,11) {$e_{16}$};
\node[Phys2h] at (1,12) {};

\node[Math2h] at (2,8) {};
\node[Math2h] (b) at (2,9) {$e_{7}$}; %node b
\node[Math2h] at (2,10) {};
\node[Math2h] (c) at (2,11) {$e_{20}$};
\node[Math2h] at (2,12) {};



\node[TIPE2h] at (3,8) {};
\node[TIPE2h] at (3,9) {};
\node[TIPE2h] (d) at (3,10) {$e_{11}$};
\node[TIPE2h] at (3,11) {};
\node[TIPE2h] at (3,12) {};

\node[TIPE2h] at (4,8) {};
\node[TIPE2h] at (4,9) {};
\node[TIPE2h] at (4,10) {};
\node[TIPE2h] at (4,11) {};
\node[TIPE2h] at (4,12) {};

%Arrows
\draw [-latex,thick,shorten >=5pt,shorten <=5pt] (a.center) --  node [anchor=135,outer sep=2pt] { }
(b.center) ;
\draw [-latex,thick,shorten >=5pt,shorten <=5pt] (b.center) --  node [anchor=135,outer sep=2pt] { }
(c.center) ;
\draw [-latex,thick,shorten >=7pt,shorten <=7pt] (c.center) --  node [anchor=135,outer sep=2pt] { }
(e.center) ;
\draw [-latex,thick,shorten >=5pt,shorten <=7pt] (e.center) to[bend right=40]  node [anchor=135,outer sep=2pt] { }
(d.center) ;
% dotted line
\draw[very thick,dotted,shorten >=6pt] (EE.center) -- ++(0,-1.5cm);

\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks @marmot, its true about nodes are extended objects.
    – affernan
    Mar 25, 2018 at 17:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .