# Table will not center (and it is spilling off the right side of the page)

I just generated this table using Excel2LaTeX:

Even though I enclosed the table in \begin{center} the table did not get centered. The table still sticks out the right side. Is there somehow that I can easily fix this?

This is the code for the table:

\begin{center}
\begin{tabular}{rrrrrrr}
&    MSRP & Vol. Disc. & Promo. Allow. & Discount/Sale & Promo/Sale & Income/Sale \\
{\bf All Round} & {\bf \$5.49} & {\bf 30.0\%} & {\bf 13.0\%} & {\bf \$1.65} & {\bf \$0.71} & {\bf \$2.36} \\
{\bf All Round (suggestion)} & {\bf \$5.49} & {\bf 25.0\%} & {\bf 20.0\%} & {\bf \$1.37} & {\bf \$1.10} & {\bf \$2.47} \\
Believe &  \$3.99 & 33.5\% & 15.6\% & \$1.34 &  \$0.62 & \$1.96 \\
Best Help &  \$4.59 & 34.5\% & 13.3\% & \$1.58 &  \$0.61 & \$2.19 \\
Coughcure &  \$4.69 & 28.5\% & 16.7\% & \$1.34 &  \$0.78 & \$2.12 \\
Defogg &  \$4.09 & 22.5\% & 11.1\% & \$0.92 &  \$0.45 & \$1.37 \\
Dripstop &  \$4.09 & 21.5\% & 13.3\% & \$0.88 &  \$0.54 & \$1.42 \\
{\bf Dryup} & {\bf \$4.79} & {\bf 21.5\%} & {\bf 15.6\%} & {\bf \$1.03} & {\bf \$0.75} & {\bf \$1.78} \\
Effective &  \$4.09 & 30.0\% & 14.4\% & \$1.23 &  \$0.59 & \$1.82 \\
End &  \$4.49 & 30.0\% & 14.4\% & \$1.35 &  \$0.65 & \$1.99 \\
Extra &  \$4.09 & 31.0\% & 12.5\% & \$1.27 &  \$0.51 & \$1.78 \\
\end{tabular}
\end{center}

• This is basically a duplicate of this question. – TH. Nov 5 '10 at 9:36

It might be more aesthetically pleasing and easier to maintain if you inserted some line breaks (\\) into your row and column headers that would reduce the overall width of the table. Trying to manually position the table with hspace or similar could wind up looking bad if your page formatting changes in the future.

Well your table is too large, so it will either stick out on the right, on the left or on both sides. You can move it to the left with \hspace*{-1cm}\begin{tabular}..., you can center it with e.g. \makebox[0pt]{tabular}

For my PhD-Thesis i've used the trick explained by Stefan Kottwitz. Here's the copied example from his website:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{tabularx}
\begin{document}

\blindtext

\bigskip

\noindent\makebox[\textwidth]{%
\begin{tabularx}{1.5\textwidth}{XX}
\blindtext & \blindtext
\end{tabularx}
}

\bigskip

\blindtext

\end{document}


The relevant thing is to include your large-ish float into

\noindent\makebox[\textwidth]{%
%Table or figure
}


Oh, and BTW: I also suggest you look at the booktabs package, it's great for enhancing the display of your tables...

• This is the best suggestion on this page. – gregmacfarlane Oct 18 '12 at 1:38
• Absolutely fantastic. – alexyorke May 14 '13 at 21:42
• +1 But I should note that a float within a makebox will fail, as I explain in this answer. I suspect in the above you meant %TABLE, not %FLOAT. – landroni Sep 11 '15 at 19:31
• Yes, it seems it is %TABLE, not %FLOAT. Nice if could be corrected in your nice answer? – Matifou Nov 3 '15 at 18:06
• I've successfully used this code to center large tables and pictures, so I just assumed it works for all floats. I've updated the answer. – Habi Nov 4 '15 at 9:05

You could surround the All Round (suggestion) with \llap. That will let it stick into the left margin a bit.

This may sound obvious to LaTeX experts, but to complete other answers...

If the table is within a float, then the \noindent\makebox[\textwidth]{%TABLE} construct must enclose only the tabular environment, and it must not contain the float nor the caption. In other words, the makebox must be inside the float and should not include the caption. Otherwise there will be an error.

Based on the OP's example (but shortened table):

\documentclass{article}
\usepackage{showframe}  %%display resulting placement on page
\begin{document}

\begin{table}  %%float environment

%%the makebox MUST be within the float
%%and should NOT contain the caption
\noindent\makebox[\textwidth]{
\begin{tabular}{rrrrrrr}

&    MSRP & Vol. Disc. & Promo. Allow. & Discount/Sale & Promo/Sale & Income/Sale \\

{\bf All Round} & {\bf \$5.49} & {\bf 30.0\%} & {\bf 13.0\%} & {\bf \$1.65} & {\bf \$0.71} & {\bf \$2.36} \\

{\bf All Round (suggestion)} & {\bf \$5.49} & {\bf 25.0\%} & {\bf 20.0\%} & {\bf \$1.37} & {\bf \$1.10} & {\bf \$2.47} \\

Believe &  \$3.99 & 33.5\% & 15.6\% & \$1.34 &  \$0.62 & \$1.96 \\

Best Help &  \$4.59 & 34.5\% & 13.3\% & \$1.58 &  \$0.61 & \$2.19 \\

\end{tabular}
}

\caption{Some caption}
\end{table}

\end{document}


Which will yield a table float centered according to page width:

See comments on why this solution may or may not be a good one.

• please add in your MWE immediately after \documentclass to show, what ones can expect. As others (years ago) mentioned in their comments, the table is to big to be nicely fitted on a page. So, I seconded for accepted answer as (only) right way to solve such problems. And by the way; \bf is deprecated form almost 20 years. – Zarko Sep 11 '15 at 20:00
• @Zarko I'm not sure I understand your first phrase: is the MWE incorrect? As for \bf, I simply reused the OP's example code... – landroni Sep 11 '15 at 20:56
• @landrony, your MWE work as such (doesn't gives errors), but for comparing of obtained result with page size I sugest to add showframe package. It will draw all page elements borders. With its is simple to see that the table is not limited to text width, but (as you like to show, if I understand correctly) that it is horizontally centered on a page. To my taste such appearing of table is ugly, better is to shrink table to text width with breaking column headers into more lines, etc. – Zarko Sep 11 '15 at 21:29
• @Zarko Good points. I edited my answer to include \usepackage{showframe}. I understand the philosophical objections to this solution, and why it may be considered ugly or wrong. At the same time if people have the latitude for such a solution in their documents and are OK with it, they should know how to do this. – landroni Sep 12 '15 at 10:06
• now can even OP see, what is wrong with his effort, table almost cross page border and that in similar situation he need to look for alternative solution, for example for sidewaytable or redesign column headers etc. – Zarko Sep 12 '15 at 11:36

As supplement to @Andrew Arnold answer (and for my exercise :-)) ...

\documentclass{article}
\usepackage{siunitx}
\usepackage{array,booktabs}
\usepackage{stackengine}
\usepackage{etoolbox}
\usepackage[margin=30mm,showframe]{geometry}

\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}} % non-extended bold font
\newcommand{\mybf}{\fontseries{b}\selectfont} % non-extended bold font
\robustify\mybf

\begin{document}
some text

\begin{center}\setlength{\tabcolsep}{8pt}
\begin{tabular}{r    >{\$}S[table-space-text-pre=\,, detect-weight,table-format=2.3] *{2}{ S[detect-weight,table-format=3.2]<{\%} } *{3}{>{\$}S[table-space-text-pre=\,,
detect-weight,table-format=2.3]}}
%%%%
& \mc{MSRP} & \mc{\stackon{Volume}{Discount}}
& \mc{\stackon{Allowed}{Promotion}} & \mc{\stackon{Sale}{Discoun}}
& \mc{\stackon{Sale}{Promotion}} & \mc{\stackon{Sale}{Income}}  \\
\midrule
\mybf All Round
&   \mybf 5.49   &   \mybf 30.0   &   \mybf 13.0
&   \mybf 1.65   &   \mybf 0.71   &   \mybf 2.36 \\
\mybf All Round (suggestion)
& \mybf 5.49  & \mybf 25.0  & \mybf 20.0
& \mybf 1.37  & \mybf 1.10  & \mybf 2.47         \\
Believe
& 3.99 &  33.5 &  15.6 & 1.34 & 0.62 & 1.96             \\
Best Help
& 4.59 &  34.5 &  13.3 & 1.58 & 0.61 & 2.19             \\
Coughcure
& 4.69 &  28.5 &  16.7 & 1.34 & 0.78 & 2.12             \\
Defogg  & 4.09 &  22.5 &  11.1 & 0.92 & 0.45 & 1.37             \\
Dripstop
& 4.09 &  21.5 &  13.3 & 0.88 & 0.54 & 1.42             \\
%
\mybf Dryup
& \mybf 4.79  & \mybf 21.5  & \mybf 15.6
& \mybf 1.03  & \mybf 0.75  & \mybf 1.78         \\
Effective
& 4.09 &  30.0 &  14.4 & 1.23 & 0.59 & 1.82             \\
End     & 4.49 &  30.0 &  14.4 & 1.35 & 0.65 & 1.99             \\
Extra   & 4.09 &  31.0 &  12.5 & 1.27 & 0.51 & 1.78             \\
\midrule
\end{tabular}
\end{center}
\end{document}


As can be seen, for I use '\stackon{}{}˙macro from package stackengine for settings column heads i two lines, midrule from booktabs package for horizontal lines in table and S column type from siunitx package. It allows to align cells content on decimal point and nicely add $and % symbols where they present. For shortness for \multicolumn{1}{c}{...} I define new command. It is necessary for elimination of$ and % symbols in column heads.

Since question nothing say about page layout, I us egeometry package for and select 30mm for margins width. With optionshowframe is to see where are text borders.

In picture show tables with 10pt fonts (default size for article, if it is not defined other size). This table also can be fit in text width with bigger fonts, however in this case it is necessary to reduce \tabcolsep accordingly. For example at 12pt font size the \tabcolsep should be 3pt.

Well, this answer is to late for questioner, however it my be informative to many who ask (quit often) similar questions still today.

Use the adjustbox package with the center argument, e.g.,

\documentclass{article}
\begin{document}
\begin{tabular}{rrrrrrr}
&    MSRP & Vol. Disc. & Promo. Allow. & Discount/Sale & Promo/Sale & Income/Sale \\
{\bf All Round} & {\bf \$5.49} & {\bf 30.0\%} & {\bf 13.0\%} & {\bf \$1.65} & {\bf \$0.71} & {\bf \$2.36} \\
{\bf All Round (suggestion)} & {\bf \$5.49} & {\bf 25.0\%} & {\bf 20.0\%} & {\bf \$1.37} & {\bf \$1.10} & {\bf \$2.47} \\
Believe &  \$3.99 & 33.5\% & 15.6\% & \$1.34 &  \$0.62 & \$1.96 \\
Best Help &  \$4.59 & 34.5\% & 13.3\% & \$1.58 &  \$0.61 & \$2.19 \\
Coughcure &  \$4.69 & 28.5\% & 16.7\% & \$1.34 &  \$0.78 & \$2.12 \\
Defogg &  \$4.09 & 22.5\% & 11.1\% & \$0.92 &  \$0.45 & \$1.37 \\
Dripstop &  \$4.09 & 21.5\% & 13.3\% & \$0.88 &  \$0.54 & \$1.42 \\
{\bf Dryup} & {\bf \$4.79} & {\bf 21.5\%} & {\bf 15.6\%} & {\bf \$1.03} & {\bf \$0.75} & {\bf \$1.78} \\
Effective &  \$4.09 & 30.0\% & 14.4\% & \$1.23 &  \$0.59 & \$1.82 \\
End &  \$4.49 & 30.0\% & 14.4\% & \$1.35 &  \$0.65 & \$1.99 \\
Extra &  \$4.09 & 31.0\% & 12.5\% & \$1.27 &  \$0.51 & \$1.78 \\
\end{tabular}
`