Information and discussion about graphics, figures & tables in LaTeX documents.
olegkomarov
Posts: 10 Joined: Tue Jul 26, 2011 4:24 am
Post
by olegkomarov » Tue Sep 20, 2011 1:55 am
I can't make the the column equally spaced in this MWE (the last is off):
Code: Select all
\documentclass{article}
\usepackage{mathtools,booktabs,xspace}
\newcommand{\avgrm}[2]{\ensuremath{\mathrm{\overline{#1}}_{#2}}\xspace}
\newcommand{\avgcj}[2]{\ensuremath{\overline{#1}_{#2}}\xspace}
\begin{document}
\begin{table}[h]\footnotesize
\caption{}
\begin{center}
\begin{tabular*}{\textwidth}{l*{8}{@{\extracolsep{\fill}}r@{\extracolsep{\fill}}}}
\midrule\addlinespace[.15em]\midrule
\multicolumn{9}{c}{$\mathrm{HAR\text{-}C \Delta J}: \quad \mathrm{RV}_t = \beta_0 + \beta_{d \Delta J}\avgcj{\Delta J}{1}+\beta_{d}\avgrm{BPV}{1}+\beta_w\avgrm{RV}{5}+\beta_m\avgrm{RV}{22}+\varepsilon_t$}\\
\midrule
& 1 min & 1 min & 1 min & 1 min & 5 min & 5 min & 5 min & 5 min \\
& & & bus & bus & & & bus & bus \\
& & ss & & ss & & ss & & ss \\
\cmidrule{2-9}
\cmidrule{2-9}
$\beta_0$& 0.079& 0.114& 0.047& 0.098& 0.167& 0.142& 0.163& 0.151 \\
&(1.493)& (3.328)& (0.947)& (3.243)& (2.185)& (3.230)& (2.366)& (3.252) \\
$\beta_d$& 0.930& 0.706& 0.858& 0.618& 0.627& 0.500& 0.657& 0.604 \\
&(4.024)& (5.251)& (4.203)& (5.372)& (5.480)& (5.477)& (4.890)& (4.689) \\
$\beta_w$& 0.108& 0.171& 0.142& 0.220& 0.150& 0.266& 0.145& 0.172 \\
&(1.039)& (1.915)& (1.115)& (2.380)& (1.337)& (2.443)& (1.117)& (1.808) \\
$\beta_m$& 0.213& 0.085& 0.199& 0.037& 0.243& 0.092& 0.228& 0.122 \\
&(2.112)& (0.828)& (2.001)& (0.350)& (1.923)& (0.800)& (2.033)& (1.087) \\
$\beta_{\Delta J}$& 0.004& -0.191& -0.057& -0.418& -0.063& -0.268& -0.132& -0.329 \\
&(0.075)&(-1.694)&(-1.001)&(-3.139)&(-1.165)&(-1.703)&(-2.710)&(-3.065) \\[.5em]
$R^2$& 0.462& 0.543& 0.472& 0.535& 0.379& 0.450& 0.452& 0.513 \\
$\rm{MSE}$& 0.496& 0.200& 0.433& 0.161& 0.529& 0.252& 0.469& 0.244 \\
$\rm{QLIKE}$& 0.776& 0.471& 0.660& 0.306& 0.845& 0.536& 0.853& 0.625 \\
\midrule\addlinespace[.16em]\midrule
\end{tabular*}
\end{center}
\end{table}
\end{document}
I noticed it depends on the length of the equation in \multicolumn.
Is there a workaround to keep the equation centered and the columns containing the numbers equally equispaced (with right alignment)?
Thanks in advance
Last edited by
olegkomarov on Wed Sep 21, 2011 1:32 am, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
justdeath
Posts: 69 Joined: Mon Sep 05, 2011 10:27 am
Post
by justdeath » Tue Sep 20, 2011 7:01 pm
Replace your tabular with this one:
Code: Select all
\begin{tabular*}{\textwidth}{l@{} *{8}{r}@{}}
But the first column is slightly indented (same as on your example).
We may try this:
Code: Select all
\begin{tabular*}{\textwidth}{@{}l@{} *{8}{r}@{}}
But then the last column is slightly indented.
Pick your choice.
Nikolay
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Tue Sep 20, 2011 7:34 pm
It works very nice with the quite new
tabu package.
Code: Select all
\documentclass{article}
\usepackage[tableposition=top]{caption}
\usepackage{mathtools}
\usepackage{booktabs,tabu}
\usepackage{xspace}
\newcommand{\avgrm}[2]{\ensuremath{\mathrm{\overline{#1}}_{#2}}\xspace}
\newcommand{\avgcj}[2]{\ensuremath{\overline{#1}_{#2}}\xspace}
\begin{document}
\begin{table}[!ht]
\caption{Table caption}\label{tab:table}
\centering
\footnotesize
\begin{tabu} to \textwidth {l*{8}{X[r]}} \midrule\addlinespace[.15em]\midrule
\multicolumn{9}{c}{$\mathrm{HAR\text{-}C\Delta J}: \quad \mathrm{RV}_t = \beta_0+\beta_{d\Delta J}\avgcj{\Delta J}{1}+\beta_{d}\avgrm{BPV}{1}+\beta_w\avgrm{RV}{5}+\beta_m\avgrm{RV}{22}+\varepsilon_t$} \\ \midrule
& 1 min & 1 min & 1 min & 1 min & 5 min & 5 min & 5 min & 5 min \\
& & & bus & bus & & & bus & bus \\
& & ss & & ss & & ss & & ss \\ \cmidrule[1pt](lr){2-9}
$\beta_0$ & 0.079& 0.114& 0.047& 0.098& 0.167& 0.142& 0.163& 0.151 \\
&(1.493)& (3.328)& (0.947)& (3.243)& (2.185)& (3.230)& (2.366)& (3.252) \\
$\beta_d$ & 0.930& 0.706& 0.858& 0.618& 0.627& 0.500& 0.657& 0.604 \\
&(4.024)& (5.251)& (4.203)& (5.372)& (5.480)& (5.477)& (4.890)& (4.689) \\
$\beta_w$ & 0.108& 0.171& 0.142& 0.220& 0.150& 0.266& 0.145& 0.172 \\
&(1.039)& (1.915)& (1.115)& (2.380)& (1.337)& (2.443)& (1.117)& (1.808) \\
$\beta_m$ & 0.213& 0.085& 0.199& 0.037& 0.243& 0.092& 0.228& 0.122 \\
&(2.112)& (0.828)& (2.001)& (0.350)& (1.923)& (0.800)& (2.033)& (1.087) \\
$\beta_{\Delta J}$& 0.004& -0.191& -0.057& -0.418& -0.063& -0.268& -0.132& -0.329 \\
&(0.075)&(-1.694)&(-1.001)&(-3.139)&(-1.165)&(-1.703)&(-2.710)&(-3.065) \\ \addlinespace[1em]
$R^2$ & 0.462& 0.543& 0.472& 0.535& 0.379& 0.450& 0.452& 0.513 \\
$\rm{MSE}$ & 0.496& 0.200& 0.433& 0.161& 0.529& 0.252& 0.469& 0.244 \\
$\rm{QLIKE}$ & 0.776& 0.471& 0.660& 0.306& 0.845& 0.536& 0.853& 0.625 \\ \midrule\addlinespace[.15em]\midrule
\end{tabu}
\end{table}
\end{document}
For details refer to the package manual.
P.S.: Good minimal example.
Thorsten
olegkomarov
Posts: 10 Joined: Tue Jul 26, 2011 4:24 am
Post
by olegkomarov » Wed Sep 21, 2011 1:40 am
Thanks for both answers, equally precious.
@Nikolay: I was sure I tried that solution, thanks a lot (but still do not understand the interaction between \mcolumn and @{extracolsep{\fill}}.
@Thorsten: I wish I knew about tabu! Lifesaver.