[Tex/LaTex] Indenting within table column

tables

I have the following table (using booktabs):

\begin{table}
\caption{Table}
\centering
\begin{tabular}{ccccc}
\toprule
& \multicolumn{4}{c}{Lags}\\[\defaultaddspace]
 & 5 & 10 & 15  & 20 \\[\defaultaddspace]
 EUR/USD &  &  &  &  \\[\defaultaddspace]
 Ljung-Box-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
\bottomrule
\end{tabular}
\end{table}

which results in the following table:

Result of above code

I would like to establish some hierarchy by indenting the "Ljung-Box-Test" text within the first column (I will be adding more currency pairs / categories below).

Any help would be much appreciated!

Thanks!

Best Answer

You can add the indent to all the cells in the first column (that should be left aligned) and remove the indent when you want it to:

\documentclass{article}
\usepackage{caption,booktabs,array}

\newcommand{\rowgroup}[1]{\hspace{-1em}#1}

\begin{document}

\begin{table}
\caption{Table}
\centering
\begin{tabular}{>{\quad}lcccc}
\toprule
& \multicolumn{4}{c}{Lags}\\
 & 5 & 10 & 15  & 20 \\
\midrule
\rowgroup{EUR/USD} \\
Ljung-Box-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
Foo-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
Foo-Box-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
\midrule
\rowgroup{USD/EUR} \\
Ljung-Box-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
Foo-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
Foo-Box-Test & 0,4936 & 0,7841 & 0,8457 & 0,8822 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here