3

I am trying to add two orange braces as shown in the picture below:
desired output

I am struggling to place them (in orange) on my diagram. Below is my MWE:

\documentclass{standalone}
\newcommand{\ImageWidth}{11cm}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,positioning, arrows.meta}

\begin{document}         
    \begin{tikzpicture}
        % draw horizontal line   
        \draw[thick, -Triangle] (0,0) -- (15,0) node[font={\normalsize},below left=4pt and -8pt]{years};
        
        % draw vertical lines
        \foreach \x in {0,4,8,10,12,14}
        \draw (\x cm,5pt) -- (\x cm,-5pt);
        
        \foreach \x/\descr in {4/t-2\Delta t_I,8/t-\Delta t_I,12/t}
        \node[font=\normalsize, text height=1.75ex,
        text depth=.5ex] at (\x,-.5) {$\descr$};
        
        \foreach \x/\descr in {10/(t-\Delta t_I)+\Delta t_X}
        \node[blue,font=\normalsize, text height=1.75ex,
        text depth=.5ex] at (\x,.5) {$\descr$};
        
        \foreach \x/\descr in {14/t+\Delta t_X}
        \node[blue,font=\normalsize, text height=1.75ex,
        text depth=.5ex] at (\x,.5) {$\descr$};
        
        % braces
        \draw [blue,thick ,decorate,decoration={brace,amplitude=8pt}] (8,0.7)  -- +(2,0) 
        node [blue,midway,above=6pt, font=\normalsize] {$\Delta X_{current}$};
        \draw [blue,thick ,decorate,decoration={brace,amplitude=8pt}] (12,0.7)  -- +(2,0) 
        node [blue,midway,above=6pt, font=\normalsize] {$\Delta X_{future}$};
        \draw [thick,decorate,decoration={brace,amplitude=8pt}] (8,-.9) -- +(-4,0)
        node [black,midway,font=\normalsize, below=6pt] {$\rho_{current}$};
        \draw [thick,decorate,decoration={brace,amplitude=8pt}] (12,-.9) -- +(-4,0)
        node [black,midway,font=\normalsize, below=6pt] {$\rho_{previous}$};
        
    \end{tikzpicture}
    
\end{document}
1
  • 1
    Draw them on the same ways as you draw blue one with difference that increase their distances from the timeline.
    – Zarko
    Commented Mar 17, 2023 at 19:33

1 Answer 1

3

See, iif the following MWE produce what you after:

Edit:

  • color of text above/ below braces are not the same colors as braces
  • added / after number 13 in the first loop
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                decorations.pathreplacing,
                    calligraphy,% had to be after decorations.pathreplacing
                positioning}

\begin{document}
    \begin{tikzpicture}[
BC/.style args = {#1/#2/#3}{
        decorate,
        decoration={calligraphic brace, amplitude=6pt,
        pre =moveto, pre  length=1pt,
        post=moveto, post length=1pt,
        raise=#1,
              #2},% for mirroring of brace
        ultra thick,
        pen colour={#3}, text=#3
        },              ]
% timeline
\draw[thick,-Triangle] (0,0) -- (15,0) node[below=12pt, left] {years};
% draw ticks
\foreach \x/\i [count=\j] in {0, 
                              3/t-2\Delta t_I, 
                              7/t-\Delta t_I, 
                              9/,
                              11/t, 
                              13/}  % <--- corrected, added is /
    \draw (\x,5pt) -- ++ (0,-10pt) node (b\j) [below] {$\i$};
% braces below
\draw [BC=1mm/mirror/black] 
    (b2.south) -- node[below=2ex] {$\rho_{\mathrm{previous}}$} (b3.south);
\draw[BC=1mm/mirror/black]
    (b3.south) -- 
            node[below=2ex] {$\rho_{\mathrm{current}}$} (b5.south);
% blue braces above
\foreach \m/\i [count=\j] in {7/ ,
                              9/(t-\Delta t_I)+\Delta t_S,
                              11/ ,
                              13/t+\Delta t_S}
    \node (a\j) [above] at (\m,5pt) {$\i$};
\draw [BC=1mm/ /blue]
    (b3 |- a2.north) --
            node (s1) [above=2ex] {$\Delta S_{\mathrm{current}}$} (a2.north);
\draw [BC=1mm/ /blue]
    (a3 |- a4.north) --
        node (s2) [above=2ex] {$\Delta S_{\mathrm{future}}$} (a4.north);
% orange braces above
\draw [BC=1mm/ /orange]
    (b2 |- s1.north) --
            node [above=2ex] {$\varphi=i$} (s1.north east);
\draw [BC=5mm/ /orange]
    (a1 |- s2.north) --
            node [above=4ex] {$\varphi=j$} (s2.north east);
    \end{tikzpicture}
\end{document}
  • As you can observe, the main difference of above MWE in comparison to yours, are:
    • for brace's style is used calligraphy library
    • braces' style is defined in the tikzpicture option
    • for positioning of braces are used relative coordinates defined by nodes' names at ticks on the timelines and brace style option raise=#1.
    • used are only two loops (I try to merge all in one loop, but I didn't succeed)

enter image description here

2
  • I have tried to remove 13 under t+Delta_S. I there a way of removing it without disturbing the overall tikz diagram?
    – itc
    Commented Mar 18, 2023 at 1:30
  • @itc, ups, I overlooked this. :-). Apparently I lost / after 13 in the first loop. Corrected now. See edited answer.
    – Zarko
    Commented Mar 18, 2023 at 1:50

You must log in to answer this question.

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