2

Currently I have got the following code:

\documentclass[12pt, twoside]{scrartcl}

\usepackage{amsmath}

\begin{document}
    \centering
    \begin{tabular}{l|l|l|l|l|l}
    Weeks  & $t - \Delta t $   & $\dotsm$ & $t-2$ & $t-1$    & $t$    \\ 
    \hline
    Search Volume & $n(t - \Delta t $ & $\dotsm$ & $n(t-2)$ & $n(t-1)$ & $n(t)$ \\
    \end{tabular}
\end{document}

Which gives me the following table: enter image description here

Now I would like to add two curly brackets with some text as follows:

enter image description here

How can I do this in Latex?

dexteritas
  • 9,161
John
  • 643
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – dexteritas May 28 '18 at 12:58

1 Answers1

2

You can use tikZ for drawing curly brackets. For remembering the locations I defined the command \tikzmark, which is used inside the table cells.

In general, it is better to write table captions above the table (see Why should a table caption be placed above the table?). To have the table caption below without overlapping with the brackets you can add \vspace{15mm} manually. There may be a better (automatic) way.

Code:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{calc}

\newcommand{\tikzmark}[1]{\tikz[remember picture,overlay]\node[yshift=2pt](#1){};}

\begin{document}

\begin{table}
    \begin{tabular}{l|l|l|l|l|l}
        Weeks  & $t - \Delta t $   & $\dotsm$ & $t-2$ & $t-1$  & $t$    \\ 
        \hline
        Search Volume & \tikzmark{a1}$n(t - \Delta t $ & $\dotsm$ & \tikzmark{b1}$n(t-2)$ & $n(t-1)$\tikzmark{a2} & $n(t)$\tikzmark{b2} \\
    \end{tabular}

    \begin{tikzpicture}[overlay, remember picture]
        \draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt}] (a1.west) --node[below=14pt]{average = $N_{t-1, \Delta t}$} (a2.east);
        \draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt}] ($(b1.west) - (0,1)$) --node[below=14pt]{$\Delta n_{t, \Delta t} = n_t - N_{t-1}, \Delta_t$} ($(b2.east) - (0,1)$);
    \end{tikzpicture}

    \vspace{15mm}
    \caption{my caption}
\end{table}

\end{document}

Result:

enter image description here

dexteritas
  • 9,161
  • Thank you very much! Is it possible to give it a label like "Table 2 bla bla bla"? When I try to do it, the label text is at the same place as the brackets, so it's not readable. – John May 28 '18 at 13:54
  • @John I edited the answer and added a table caption. – dexteritas May 28 '18 at 15:45