13

I created a timeline with TikZ. The problem is, that there is a little gap between the ends of the braces that end at the same node. gap between curly braces

And here is my code:

\begin{tikzpicture}[y=1cm, x=1cm, thick, font=\footnotesize]    

% axis  
\draw[line width=1.2pt, ->, >=latex'](0,0) -- coordinate (x axis) (10,0);       

% time points
\draw (3,-4pt) node(t_k){} -- 
    (3,4pt) node[anchor=south] {$t_{k}$};
\draw (5,-4pt) node(t_k_opt) {} -- 
    (5,4pt) node[anchor=south] {};      
\draw (7,-4pt) node(t_k_opt_impl) {} -- 
    (7,4pt) node[anchor=south] {$t_{k}+\triangle^{\text{opt}}+\triangle^{\text{impl}}$};


% curly braces
\draw[decorate,decoration={brace,amplitude=3pt,mirror}] 
    (3,-2.5) node(t_k_unten){} -- 
    (5,-2.5) node(t_k_opt_unten){}; 
\node at (4,-3){$\triangle^{\text{opt}}$};
\draw[decorate,decoration={brace,amplitude=3pt,mirror}] 
    (t_k_opt_unten) -- 
    (7,-2.5) node(t_k_opt_impl_unten){}; 
\node at (6,-3){$\triangle^{\text{impl}}$};

% vertical dotted lines
\draw[dotted] (t_k)--(t_k_unten);
\draw[dotted] (t_k_opt)--(t_k_opt_unten);
\draw[dotted] (t_k_opt_impl)--(t_k_opt_impl_unten);

\end{tikzpicture}

I'd be glad, if someone could help!

Christian
  • 503
  • 5
    Use coordinates instead of nodes to mark coordinates on your path for later use (all starting with t_k). Use nodes=draw as a option to the TikZ picture to see what nodes do to the placement. – Qrrbrbirlbel Feb 12 '13 at 15:40

1 Answers1

14

You need to use coordinates instead of nodes to mark coordinates on your path for later use). I added the style draw=green to every node which looks like this:

enter image description here

The dashed line end at the nodes and the right brace also starts at right border of the node. (You could consequently use the .center anchor but coordinates are more comfortable.)

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,decorations.pathreplacing}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[y=1cm, x=1cm, thick, font=\footnotesize]    
% axis
\draw[line width=1.2pt, ->, >=latex'](0,0) -- coordinate (x axis) (10,0);       

% time points
\draw (3,-4pt) coordinate (t_k)          -- (3,4pt) node[anchor=south] {$t_{k}$};
\draw (5,-4pt) coordinate (t_k_opt)      -- (5,4pt) node[anchor=south] {};
\draw (7,-4pt) coordinate (t_k_opt_impl) -- (7,4pt) node[anchor=south]
                                {$t_{k}+\triangle^{\text{opt}}+\triangle^{\text{impl}}$};

% curly braces
\draw[decorate,decoration={brace,amplitude=3pt,mirror}] 
    (3,-2.5) coordinate (t_k_unten) -- (5,-2.5) coordinate (t_k_opt_unten); 
\node at (4,-3){$\triangle^{\text{opt}}$};
\draw[decorate,decoration={brace,amplitude=3pt,mirror}] 
    (t_k_opt_unten) -- (7,-2.5) coordinate (t_k_opt_impl_unten); 
\node at (6,-3){$\triangle^{\text{impl}}$};

% vertical dotted lines
\draw[dotted] (t_k)          -- (t_k_unten);
\draw[dotted] (t_k_opt)      -- (t_k_opt_unten);
\draw[dotted] (t_k_opt_impl) -- (t_k_opt_impl_unten);
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821