Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question

migrated from stackoverflow.com Feb 12 '13 at 15:30

This question came from our site for professional and enthusiast programmers.

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 Answer 1

up vote 11 down vote accepted

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

share|improve this answer
    
The differences between a node and a coordinate can also be seen in another answer of mine, although the topic is very much different. –  Qrrbrbirlbel Mar 12 '13 at 1:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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