1

Why this code is not working, my tables are not fully shown after running,

\usepackage{booktabs}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\begin{table*}\centering
\ra{1.3}
\begin{tabular}{@{}rrrrcrrrcrrr@{}}\toprule
& \multicolumn{3}{c}{$w = 8$} & \phantom{abc}& \multicolumn{3}{c}{$w = 16$} &
\phantom{abc} & \multicolumn{3}{c}{$w = 32$}\\
\cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12}
& $t=0$ & $t=1$ & $t=2$ && $t=0$ & $t=1$ & $t=2$ && $t=0$ & $t=1$ & $t=2$\\ \midrule
$dir=1$\\
$c$ & 0.0790 & 0.1692 & 0.2945 && 0.3670 & 0.7187 & 3.1815 && -1.0032 & -1.7104 & -21.7969\\
$c$ & -0.8651& 50.0476& 5.9384&& -9.0714& 297.0923& 46.2143&& 4.3590& 34.5809& 76.9167\\
$c$ & 124.2756& -50.9612& -14.2721&& 128.2265& -630.5455& -381.0930&& -121.0518& -137.1210& -220.2500\\
$dir=0$\\
$c$ & 0.0357& 1.2473& 0.2119&& 0.3593& -0.2755& 2.1764&& -1.2998& -3.8202& -1.2784\\
$c$ & -17.9048& -37.1111& 8.8591&& -30.7381& -9.5952& -3.0000&& -11.1631& -5.7108& -15.6728\\
$c$ & 105.5518& 232.1160& -94.7351&& 100.2497& 141.2778& -259.7326&& 52.5745& 10.1098& -140.2130\\
\bottomrule
\end{tabular}
\caption{Caption}
\end{table*}
Bernard
  • 271,350
JSS11
  • 11
  • 2
    Welcome to TeX.SE! Please make your code snippet compilable. – Mensch Feb 26 '18 at 01:20
  • 1
    It misses many things like \begin and \end{document} and possibly have more errors that we will check after you fix it (See here what I mean https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-example-what-is-that). Also to make code seen as supposed, select it and press {} button – koleygr Feb 26 '18 at 01:20
  • I already added \begin and \end{document} – JSS11 Feb 26 '18 at 01:38
  • @JSS11 we both mean that you have to edit your post and make the code compilable (There is not \begin and \end{document} here). Also when you want to someone to see your comment you have to "call his name with a @ before it like: @koleygr" – koleygr Feb 26 '18 at 03:01
  • The table code works fine, but the table is likely too wide, making it go out of the page on the right side. For general tips about such a problem, see https://tex.stackexchange.com/q/332902 You have a lot to go on, for example you can remove the \phantom{abc}s, and you can perhaps use e.g. \multicolumn{2}{l}{$dir=1$} instead of just $dir=1$. And you can reduce space between columns with \addtolength\tabcolsep{-2pt}. If you want more specific advice, please edit your example to include \documentclass and any margin settings, so that we can see how narrow the table has to be. – Torbjørn T. Feb 27 '18 at 10:12

2 Answers2

2

You can make your table fit on a standard text width:

\documentclass[twocolumn]{article}
\usepackage{booktabs,siunitx}

\newcommand{\mc}[3]{\multicolumn{#1}{#2}{#3}}

\begin{document}

\begin{table*}
\centering
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  c
  S[table-format=-2.4]
  S[table-format=-2.4]
  S[table-format=-2.4]
  S[table-format=-2.4]
  S[table-format=-3.4]
  S[table-format=-3.4]
  S[table-format=-3.4]
  S[table-format=-3.4]
  S[table-format=-3.4]
}
\toprule
& \mc{3}{c}{$w = 8$} & \mc{3}{c}{$w = 16$} & \mc{3}{c}{$w = 32$}\\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10}
& {$t=0$} & {$t=1$} & {$t=2$}
& {$t=0$} & {$t=1$} & {$t=2$}
& {$t=0$} & {$t=1$} & {$t=2$} \\
\midrule
\mc{10}{@{}l}{$\mathit{dir}=1$} \\
$c$ &   0.0790 &   0.1692 &   0.2945 &   0.3670 &    0.7187 &    3.1815 &   -1.0032 &   -1.7104 &  -21.7969\\
$c$ &  -0.8651 &  50.0476 &   5.9384 &  -9.0714 &  297.0923 &   46.2143 &    4.3590 &   34.5809 &   76.9167\\
$c$ & 124.2756 & -50.9612 & -14.2721 & 128.2265 & -630.5455 & -381.0930 & -121.0518 & -137.1210 & -220.2500\\
\midrule
\mc{10}{@{}l}{$\mathit{dir}=0$}\\
$c$ &   0.0357 &   1.2473 &   0.2119 &   0.3593 &   -0.2755 &    2.1764 &   -1.2998 &   -3.8202 &   -1.2784\\
$c$ & -17.9048 & -37.1111 &   8.8591 & -30.7381 &   -9.5952 &   -3.0000 &  -11.1631 &   -5.7108 &  -15.6728\\
$c$ & 105.5518 & 232.1160 & -94.7351 & 100.2497 &  141.2778 & -259.7326 &   52.5745 &   10.1098 & -140.2130\\
\bottomrule
\end{tabular*}
\caption{Caption}
\end{table*}

\end{document}

In the first four numeric columns, the format is -2.4 because the minus sign is wider than the additional digit.

If the table doesn't fit, add \small in front of it or, in tough cases, \footnotesize.

enter image description here

egreg
  • 1,121,712
1

Your table has two main problems:

  1. you don't need to add a fictitious column to separate the \cmidrules, there are the options (lr) for that (l = line shorter on the left and r = line shorter on the right)
  2. your table is too wide to fit a page, I suggest to use sideways and print it landscape. (Since you didn't post a complete MWE, I don't know which documentclass you are using, I used book.)

Moreover, I added the dcolumn package for a better alignment of your numbers to the decimal point (this is optional, of course).

\documentclass{book}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{rotating}
\usepackage{dcolumn} 
\newcolumntype{d}{D{.}{.}{4}} 

\begin{document}
\begin{sidewaystable}
\centering
\ra{1.3}
\begin{tabular}{@{}r*9{d}@{}}\toprule
& \multicolumn{3}{c}{$w = 8$} & \multicolumn{3}{c}{$w = 16$}  & \multicolumn{3}{c}{$w = 32$}\\
\cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
& \multicolumn{1}{r}{$t=0$} & \multicolumn{1}{r}{$t=1$} & \multicolumn{1}{r}{$t=2$} & \multicolumn{1}{r}{$t=0$} & \multicolumn{1}{r}{$t=1$} & \multicolumn{1}{r}{$t=2$} & \multicolumn{1}{r}{$t=0$} & \multicolumn{1}{r}{$t=1$} & \multicolumn{1}{r@{}}{$t=2$}\\ \midrule
$dir=1$\\
$c$ & 0.0790 & 0.1692 & 0.2945 & 0.3670 & 0.7187 & 3.1815 & -1.0032 & -1.7104 & -21.7969\\
$c$ & -0.8651& 50.0476& 5.9384& -9.0714& 297.0923& 46.2143& 4.3590& 34.5809& 76.9167\\
$c$ & 124.2756& -50.9612& -14.2721& 128.2265& -630.5455& -381.0930& -121.0518& -137.1210& -220.2500\\
$dir=0$\\
$c$ & 0.0357& 1.2473& 0.2119& 0.3593& -0.2755& 2.1764& -1.2998& -3.8202& -1.2784\\
$c$ & -17.9048& -37.1111& 8.8591& -30.7381& -9.5952& -3.0000& -11.1631& -5.7108& -15.6728\\
$c$ & 105.5518& 232.1160& -94.7351& 100.2497& 141.2778& -259.7326& 52.5745& 10.1098& -140.2130\\
\bottomrule
\end{tabular}
\caption{Caption}
\end{sidewaystable}
\end{document}

enter image description here

CarLaTeX
  • 62,716