1

How do I make a clear distinction between the $M_1$ and $M_2$ columns in this table. Also, if it is possible, how do I make the table slightly smaller?

MWE

\documentclass{article}

\begin{document}

\begin{table}[!]
\caption{Results} % title name of the table
\centering % centering table
\begin{tabular}{l rrr rrrrrr} % creating 10 columns
\hline\hline % inserting double-line
 &\multicolumn{3}{c}{$M_1$}  &\multicolumn{6}{c}{$M_2$}
\\ [0.5ex]
\hline 
$i$ & 1 & 2 & 3 & 1 & 2 & 3 & 4 & 5 & 6 \\ [0.5ex]
$r_i$ & 170 & 0 & 130 & 170 & 0 & 0 & 0 & 130 & 0 \\ [0.5ex]
$\int_0^T g_i(x(t))$ & 204178.8 & 580.7 & 580.7 & 45840.7 & 158338.1 & 580.7 & 0 & 580.7 & 0 \\
 [1ex] 
\hline 
\end{tabular}
\end{table}

\end{document}
2

like this?

enter image description here

(red lines show page layout). for this table i use packages booktabs for horizontal rules, makecell for more vertical space around cells' contents and siunitx for S columns which enable aligning numbers at decimal points.

table width is prescribed with tabular* to text width. separation between columns is automatically adjusted by @{\extracolsep{\fill}}.

\documentclass{article}
\usepackage{booktabs, makecell}
\setcellgapes{3pt}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}

\begin{document}
    \begin{table}[htb]
\caption{Results} % title name of the table
    \setlength\tabcolsep{0pt}
    \makegapedcells
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                    >{$}l<{$}
                        S[table-format=6.1]
                   *{2}{S[table-format=3.1]}
                        S[table-format=5.1]
                        S[table-format=6.1]
                   *{2}{S[table-format=3.1]
                        S[table-format=1.0]}
                    } % creating 10 columns
    \toprule
    & \multicolumn{3}{c}{$M_1$} & \multicolumn{6}{c}{$M_2$} \\
    \cmidrule{1-1}
    \cmidrule{2-4}
    \cmidrule{5-10}
i   & 1 & 2 & 3 & 1 & 2 & 3 & 4 & 5 & 6 \\
r_i & 170 & 0 & 130 & 170 & 0 & 0 & 0 & 130 & 0 \\
\int_0^T g_i(x(t))
    & 204 178.8 & 580.7 & 580.7 & 45 840.7 & 158 338.1 & 580.7 & 0 & 580.7 & 0 \\
    \bottomrule
\end{tabular*}
    \end{table}
\end{document}
  • Yes! That looks amazing – Gragbow Apr 23 '18 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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