Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a very wide table (wider than textwidth) generated with Hmisc. The table is so wide that when centering is used it is automatically left aligned. However, everything that I have tried gives an error or just keeps the table left alligned.

\documentclass[a4paper,12pt]{report}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\linespread{2}
\usepackage{setspace}
\usepackage{booktabs,caption,fixltx2e}
\usepackage{subfig}
\usepackage{adjustbox}
\captionsetup{belowskip=12pt,aboveskip=4pt}

\begin{document}


\begin{table}[h!]
\footnotesize
\begin{center}
\begin{tabular}{lrrrcrrrcrrrcrrr}
\hline\hline
\multicolumn{1}{l}{\bfseries Trans}&\multicolumn{3}{c}{\bfseries 50}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 100}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 200}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 400}\tabularnewline
\cline{2-4} \cline{6-8} \cline{10-12} \cline{14-16}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}\tabularnewline
\hline
{\bfseries No}&&&&&&&&&&&&&&&\tabularnewline
~~fw&$0.83$&$$&$-0.0017$&&$0.90$&$ 0.01018$&$-1.2e-03$&&$0.94$&$$&$$&&$0.97$&$$&$-0.00042$\tabularnewline
~~bw&$0.88$&$$&$$&&$0.94$&$$&$$&&$$&$$&$$&&$0.98$&$$&$$\tabularnewline
~~sp&$0.81$&$0.0031$&$$&&$$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
\hline
{\bfseries Blom}&&&&&&&&&&&&&&&\tabularnewline
~~fw&$1.00$&$$&$$&&$1.00$&$-0.00024$&$ 2.3e-05$&&$1.00$&$$&$$&&$1.00$&$$&$$\tabularnewline
~~bw&$0.90$&$$&$-0.0667$&&$0.95$&$$&$-9.1e-02$&&$0.97$&$$&$$&&$0.99$&$$&$$\tabularnewline
~~sp&$0.81$&$$&$$&&$0.90$&$-0.07838$&$-9.6e-02$&&$0.95$&$$&$$&&$0.98$&$$&$$\tabularnewline
\hline
{\bfseries Log}&&&&&&&&&&&&&&&\tabularnewline
~~fw&$0.86$&$$&$$&&$0.92$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
~~bw&$$&$$&$$&&$$&$$&$-9.4e-03$&&$$&$$&$$&&$$&$$&$$\tabularnewline
~~sp&$$&$$&$$&&$$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}


\end{document}

I have tried everything that could find on this site and on other sites, but can not find a solution that works for me.

share|improve this question
1  
What about putting it in a appendix and then rotate the page? –  Svend Tveskæg Sep 30 '13 at 12:59

3 Answers 3

up vote 3 down vote accepted

use \resizebox:

\documentclass[a4paper,12pt]{report}
\usepackage{graphicx}
\usepackage{booktabs,caption,fixltx2e}
\usepackage{subfig}
\captionsetup{belowskip=12pt,aboveskip=4pt}

\begin{document}

\begin{table}[htb!]
\resizebox{\linewidth}{!}{\def\arraystretch{1.5}%
\begin{tabular}{lrrrcrrrcrrrcrrr}
\hline\hline
\multicolumn{1}{l}{\bfseries Trans}&\multicolumn{3}{c}{\bfseries 50}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 100}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 200}&\multicolumn{1}{c}{\bfseries }&\multicolumn{3}{c}{\bfseries 400}\tabularnewline
\cline{2-4} \cline{6-8} \cline{10-12} \cline{14-16}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{b0}&\multicolumn{1}{c}{b1}&\multicolumn{1}{c}{b2}\tabularnewline
\hline
\bfseries No&&&&&&&&&&&&&&&\tabularnewline
~~fw&$0.83$&$$&$-0.0017$&&$0.90$&$ 0.01018$&$-1.2e-03$&&$0.94$&$$&$$&&$0.97$&$$&$-0.00042$\tabularnewline
~~bw&$0.88$&$$&$$&&$0.94$&$$&$$&&$$&$$&$$&&$0.98$&$$&$$\tabularnewline
~~sp&$0.81$&$0.0031$&$$&&$$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
\hline
\bfseries Blom&&&&&&&&&&&&&&&\tabularnewline
~~fw&$1.00$&$$&$$&&$1.00$&$-0.00024$&$ 2.3e-05$&&$1.00$&$$&$$&&$1.00$&$$&$$\tabularnewline
~~bw&$0.90$&$$&$-0.0667$&&$0.95$&$$&$-9.1e-02$&&$0.97$&$$&$$&&$0.99$&$$&$$\tabularnewline
~~sp&$0.81$&$$&$$&&$0.90$&$-0.07838$&$-9.6e-02$&&$0.95$&$$&$$&&$0.98$&$$&$$\tabularnewline
\hline
\bfseries Log&&&&&&&&&&&&&&&\tabularnewline
~~fw&$0.86$&$$&$$&&$0.92$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
~~bw&$$&$$&$$&&$$&$$&$-9.4e-03$&&$$&$$&$$&&$$&$$&$$\tabularnewline
~~sp&$$&$$&$$&&$$&$$&$$&&$$&$$&$$&&$$&$$&$$\tabularnewline
\hline
\end{tabular}}
\end{table}

\end{document}

and if you want it wider than the linewidth but centered use:

[...]
\begin{table}[htb!]
\makebox[\textwidth]{\resizebox{1.1\linewidth}{!}{\def\arraystretch{1.5}%
\begin{tabular}{lrrrcrrrcrrrcrrr}
[...]
\end{tabular}}}

the first one is 1.1\textwidth and the second \textwidth:

enter image description here

share|improve this answer
 \hspace*{-\textwidth}\begin{tabular}
 ...
 \end{tabular}\hspace*{-\textwidth}

will hide the width so it centers in the text block and bleeds into the margin/

share|improve this answer

You're not using properly booktabs; you don't need to add dummy columns, for instance. Then, with siunitx you can ensure uniform appearance of the data. Finally, adjustbox makes it easy to rescale the table to fit.

\documentclass[a4paper,12pt]{report}
\usepackage{booktabs,siunitx}
\usepackage{adjustbox}

\begin{document}


\begin{table}[!htp]
\centering
\begin{adjustbox}{max width=\columnwidth}
\begin{tabular}{@{}
 l
 S[table-format=1.2]
 S[table-format=1.4]
 S[table-format=-1.4]
 %
 S[table-format=1.2]
 S[table-format=-1.5]
 S[table-format=-1.1e-1]
 %
 S[table-format=1.2]
 S[table-format=1.2]% actually empty
 S[table-format=1.2]% actually empty
 %
 S[table-format=1.2]
 S[table-format=1.2]% actually empty
 S[table-format=-1.5]
@{}}
\toprule
\multicolumn{1}{l}{\bfseries Trans}&
  \multicolumn{3}{c}{\bfseries 50}&
  \multicolumn{3}{c}{\bfseries 100}&
  \multicolumn{3}{c}{\bfseries 200}&
  \multicolumn{3}{c}{\bfseries 400}\\
\cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10} \cmidrule(l){11-13}
& {b0} & {b1} & {b2} & {b0} & {b1} & {b2} & {b0} & {b1} & {b2} & {b0} & {b1} & {b2} \\
\midrule
{\bfseries No}\\
fw & 0.83 &        & -0.0017 & 0.90 & 0.01018 & -1.2e-03 & 0.94 & & & 0.97 & & -0.00042 \\
bw & 0.88 &        &         & 0.94 &         &          &          & 0.98 & &          \\
sp & 0.81 & 0.0031 &         &      &         &          &          &      & &          \\
\midrule
{\bfseries Blom}\\
fw & 1.00 &        &         & 1.00 &-0.00024 & 2.3e-05  & 1.00 & & & 1.00 & &          \\
bw & 0.90 &        & -0.0667 & 0.95 &         &-9.1e-02  & 0.97 & & & 0.99 & &          \\
sp & 0.81 &        &         & 0.90 &-0.07838 &-9.6e-02  & 0.95 & & & 0.98 & &          \\
\midrule
{\bfseries Log}\\
fw & 0.86 &        &         & 0.92 &         &          &      & & &      & &          \\
bw &      &        &         &      &         &-9.4e-03  &      & & &      & &          \\
sp &      &        &         &      &         &          &      & & &      & &          \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{table}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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