How can one make the following table with columns within columns?
3 Answers
There's nothing particularly special about your table. Just use a couple of \multicolumn directives for the cells that span two columns.
To have the decimal markers show up as \cdot (raised dot) symbols and to align the numbers in the four data columns on the decimal markers, I suggest you load the siunitx package, employ its S column type instead of basic-LaTeX c column type, and run \sisetup{output-decimal-marker=\cdot}.
Observe that non-numeric cell contents such as \alpha and \beta are encased in curly braces; this informs the siunitx package that the cell contents shouldn't be processed further and just be centered horizontally.
\documentclass[pra]{revtex4} \usepackage{siunitx} % for 'S' column type \begin{document} \begin{table} \sisetup{output-decimal-marker=\cdot} % optional \caption{A 5-column table} \begin{tabular}{ | l | *{4}{S[table-format=1.2]|} } \hline Class & \multicolumn{2}{c|}{Action 1} & \multicolumn{2}{c|}{Action 2} \\ \cline{2-5} & {$\alpha$} & {$\beta$} & {$\alpha$} & {$\beta$} \\ \hline C1 & 1.01 & 0.1 & 1.3 & 1.5 \\ \hline C2 & 0.1 & 1.3 & 1.5 & 1.01 \\ \hline C3 & 3.0 & 3.1 & 0.4 & 1.2 \\ \hline \end{tabular} \end{table} \the\tabcolsep \end{document} Let me spell out my comment, but now with considering tabularray package and its syntax for multirow and multicolumn cells:
\documentclass{revtex4-2} \usepackage{tabularray} \UseTblrLibrary{siunitx} % for 'S' column type \begin{document} \begin{tblr}{hlines, vlines, colspec={c Q[c, si={table-format=1.2}, wd=2em] % S column type *{2}{Q[c, si={table-format=1.1}, wd=2em]} Q[c, si={table-format=1.2}, wd=2em] }, } \SetCell[r=2]{c} Class % <--- multi row cell & \SetCell[c=2]{c} {{{Action 1}}} % <--- multi column cell in S column type & & \SetCell[c=2]{c} {{{Action 2}}} & \\ & $\alpha$ & $\beta$ & $\alpha$ & $\beta$ \\ C1 & 1.01 & 0.1 & 1.3 & 1.5 \\ C2 & 0.1 & 1.3 & 1.5 & 1.01 \\ C3 & 3.0 & 3.1 & 0.4 & 1.2 \\ \end{tblr} \end{document} With {NiceTabular} of nicematrix. However, nicematrix is not compatible with the class revtex4. I have used the class revtex4-1 (which is also obsolete...).
\documentclass[pra]{revtex4-1} \usepackage{siunitx} % for 'S' column type \usepackage{nicematrix} \usepackage{caption} \begin{document} \begin{table} \sisetup{output-decimal-marker=\cdot} % optional \caption{A 5-column table} \centering \begin{NiceTabular}{l*{4}{S[table-format=1.2]}}[hvlines] \Block{2-1}{} Class & \Block{1-2}{Action 1} && \Block{1-2}{Action 2} \\ & {$\alpha$} & {$\beta$} & {$\alpha$} & {$\beta$} \\ C1 & 1.01 & 0.1 & 1.3 & 1.5 \\ C2 & 0.1 & 1.3 & 1.5 & 1.01 \\ C3 & 3.0 & 3.1 & 0.4 & 1.2 \\ \end{NiceTabular} \end{table} \end{document} You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).
However, I would recommend a tabular in the style of booktabs.




Action 1andAction 2into\multicolumn{2}{c}{ <content> }. BTW, columns cannpot be split to "sub" columns, but cells in adjacent columns can be merged.