# How to center a big table in LaTeX?

I have a relatively large table composed the following way

\begin{table}[ht]
\caption{Backtesting - CFM $\alpha=5\%$, $confidence \ interval = 95\%$ }

\centering
\begin{tabular}{rrrrrrr}
\hline
Bond & Expected Exceedances & Actual Exceedances & Test Statistic & Critical Value &  p-Value & Decision \\
\hline
1 & 42.00 & 287.00 & 686.63 & 3.84 & 0.00 & Reject H0 \\
2 & 20.00 & 103.00 & 189.78 & 3.84 & 0.00 & Reject H0 \\
3 & 20.00 & 101.00 & 182.33 & 3.84 & 0.00 & Reject H0 \\
4 & 20.00 & 173.00 & 509.53 & 3.84 & 0.00 & Reject H0 \\
5 & 20.00 & 125.00 & 278.35 & 3.84 & 0.00 & Reject H0 \\
6 & 20.00 & 119.00 & 253.02 & 3.84 & 0.00 & Reject H0 \\
7 & 20.00 & 123.00 & 269.81 & 3.84 & 0.00 & Reject H0 \\
8 & 15.00 & 90.00 & 194.26 & 3.84 & 0.00 & Reject H0 \\
9 & 10.00 & 50.00 & 84.15 & 3.84 & 0.00 & Reject H0 \\
10 & 20.00 & 110.00 & 216.66 & 3.84 & 0.00 & Reject H0 \\
11 & 9.00 & 39.00 & 55.56 & 3.84 & 0.00 & Reject H0 \\
12 & 20.00 & 108.00 & 208.85 & 3.84 & 0.00 & Reject H0 \\
13 & 20.00 & 134.00 & 317.88 & 3.84 & 0.00 & Reject H0 \\
14 & 20.00 & 174.00 & 514.86 & 3.84 & 0.00 & Reject H0 \\
15 & 9.00 & 54.00 & 109.55 & 3.84 & 0.00 & Reject H0 \\
16 & 20.00 & 126.00 & 282.65 & 3.84 & 0.00 & Reject H0 \\
17 & 20.00 & 165.00 & 470.50 & 3.84 & 0.00 & Reject H0 \\
18 & 20.00 & 170.00 & 493.66 & 3.84 & 0.00 & Reject H0 \\
\hline
\end{tabular}
\end{table}


in which having the \centering command does nothing to the output which is a table that is beyond the right corner of my page. Is there a way to center this table to fit my page? As I mentioned I tested having the \centering command and removing and the output was the same!

• Welcome to TeX.SX! See Centered, wide float or Center figure that is wider than \textwidth Oct 13 '14 at 18:11
• Optionally you could rewrite your table header, for example by splitting stuff over two rows. Try e.g. adding \usepackage{siunitx} (for S columns), and modify the start of the table to \begin{tabular}{*{6}{S}c} \hline & \multicolumn{2}{c}{Exceedances} & {Test} & {Critical} & \\ {Bond} & {Expected} & {Actual} & {Statistic} & {Value} & {$p$-Value} & {Decision}\\ \hline Oct 13 '14 at 18:20

The main problem with your table is that quite a few of the entries in the header row are fairly long. I suggest you break them up across two lines. That way, it's only necessary to change the value of \tabcolsep -- the parameter that governs the amount of intercolumn whitespace -- to 5pt (default value: 6pt) to make the table fit comfortably inside the text block.

Instead of using r for all columns, you may want to use the S column type for the middle five columns, since they contain numbers that should be aligned on the respective decimal markers. You may also want to load the booktabs package and use its line-drawing macros instead of the generic \hline.

\documentclass{article}
\usepackage{booktabs,siunitx,amsmath,caption}
\begin{document}
\begin{table}[ht]
\setlength\tabcolsep{5pt} % default value: 6pt
\caption{Backtesting --- CFM $\alpha=5\%$, $\text{confidence interval} = 95\%$ }
\centering
\begin{tabular}{@{}lSSSSSc@{}}
\toprule
Bond & {Expected} & {Actual}  & {Test} & {Critical} &  {p-value} & Decision \\
& {Exceedances} & {Exceedances} & {Statistic} & {Value} \\
\midrule
1 & 42.00 & 287.00 & 686.63 & 3.84 & 0.00 & Reject H0 \\
2 & 20.00 & 103.00 & 189.78 & 3.84 & 0.00 & Reject H0 \\
3 & 20.00 & 101.00 & 182.33 & 3.84 & 0.00 & Reject H0 \\
4 & 20.00 & 173.00 & 509.53 & 3.84 & 0.00 & Reject H0 \\
5 & 20.00 & 125.00 & 278.35 & 3.84 & 0.00 & Reject H0 \\
6 & 20.00 & 119.00 & 253.02 & 3.84 & 0.00 & Reject H0 \\
7 & 20.00 & 123.00 & 269.81 & 3.84 & 0.00 & Reject H0 \\
8 & 15.00 &  50.00 &  84.15 & 3.84 & 0.00 & Reject H0 \\
10 & 20.00 & 110.00 & 216.66 & 3.84 & 0.00 & Reject H0 \\
11 &  9.00 &  39.00 &  55.56 & 3.84 & 0.00 & Reject H0 \\
12 & 20.00 & 108.00 & 208.85 & 3.84 & 0.00 & Reject H0 \\
13 & 20.00 & 134.00 & 317.88 & 3.84 & 0.00 & Reject H0 \\
14 & 20.00 & 174.00 & 514.86 & 3.84 & 0.00 & Reject H0 \\
15 &  9.00 &  54.00 & 109.55 & 3.84 & 0.00 & Reject H0 \\
16 & 20.00 & 126.00 & 282.65 & 3.84 & 0.00 & Reject H0 \\
17 & 20.00 & 165.00 & 470.50 & 3.84 & 0.00 & Reject H0 \\
18 & 20.00 & 170.00 & 493.66 & 3.84 & 0.00 & Reject H0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


Addendum: the variables "Expected Exceedances" and "Actual Exceedances" are integer-valued, right? If so, one shouldn't show the decimal fractional components of these variables (which, unsurprisingly, are .00 in all cases). Suppressing the display of the zero decimals may be achieved by setting the option zero-decimal-to-integer for columns of type S.

\documentclass{article}
\usepackage{booktabs,siunitx,amsmath,caption}
\setlength\tabcolsep{5pt}
\begin{document}
\hrule
\begin{table}[ht]
\caption{Backtesting --- CFM $\alpha=5\%$, $\text{confidence interval} = 95\%$ }
\centering
\begin{tabular}{@{} l
S[table-format=2.0,zero-decimal-to-integer]
S[table-format=3.0,zero-decimal-to-integer]
S[table-format=3.2]
S[table-format=1.2]
S[table-format=1.2]
c @{}}
\toprule
Bond & {Expected} & {Actual}  & {Test} & {Critical} &  {p-value} & Decision \\
& {Exceedances} & {Exceedances} & {Statistic} & {Value} \\
\midrule
1 & 42.00 & 287.00 & 686.63 & 3.84 & 0.00 & Reject H0 \\
2 & 20.00 & 103.00 & 189.78 & 3.84 & 0.00 & Reject H0 \\
3 & 20.00 & 101.00 & 182.33 & 3.84 & 0.00 & Reject H0 \\
4 & 20.00 & 173.00 & 509.53 & 3.84 & 0.00 & Reject H0 \\
5 & 20.00 & 125.00 & 278.35 & 3.84 & 0.00 & Reject H0 \\
6 & 20.00 & 119.00 & 253.02 & 3.84 & 0.00 & Reject H0 \\
7 & 20.00 & 123.00 & 269.81 & 3.84 & 0.00 & Reject H0 \\
8 & 15.00 &  50.00 &  84.15 & 3.84 & 0.00 & Reject H0 \\
10 & 20.00 & 110.00 & 216.66 & 3.84 & 0.00 & Reject H0 \\
11 &  9.00 &  39.00 &  55.56 & 3.84 & 0.00 & Reject H0 \\
12 & 20.00 & 108.00 & 208.85 & 3.84 & 0.00 & Reject H0 \\
13 & 20.00 & 134.00 & 317.88 & 3.84 & 0.00 & Reject H0 \\
14 & 20.00 & 174.00 & 514.86 & 3.84 & 0.00 & Reject H0 \\
15 &  9.00 &  54.00 & 109.55 & 3.84 & 0.00 & Reject H0 \\
16 & 20.00 & 126.00 & 282.65 & 3.84 & 0.00 & Reject H0 \\
17 & 20.00 & 165.00 & 470.50 & 3.84 & 0.00 & Reject H0 \\
18 & 20.00 & 170.00 & 493.66 & 3.84 & 0.00 & Reject H0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


You can rewrite your tabular (thick line only to show the horizontal width), e.g.

\documentclass{article}

\begin{document}

\def\btc{\begin{tabular}{c}}
\def\etc{\end{tabular}}
\def\RejectH0{Reject $H_0$}

\noindent\rule{\linewidth}{3pt}
\medskip

\begin{table}[ht]
\caption{Backtesting - CFM $\alpha=5\%$, $confidence \ interval = 95\%$ }

\centering
\begin{tabular}{@{}rrrrrrr@{}}
\hline
Bond & \btc Expected\\ Excee-\\dances \etc & \btc Actual \\Excee-\\dances\etc & \btc Test \\ Stat-\\istic\etc & \btc Crit-\\ical\\ Value\etc &  $p$-Value & Decision \\
\hline
1 & 42.00 & 287.00 & 686.63 & 3.84 & 0.00 & \RejectH0 \\
2 & 20.00 & 103.00 & 189.78 & 3.84 & 0.00 & \RejectH0 \\
3 & 20.00 & 101.00 & 182.33 & 3.84 & 0.00 & \RejectH0 \\
4 & 20.00 & 173.00 & 509.53 & 3.84 & 0.00 & \RejectH0 \\
5 & 20.00 & 125.00 & 278.35 & 3.84 & 0.00 & \RejectH0 \\
6 & 20.00 & 119.00 & 253.02 & 3.84 & 0.00 & \RejectH0 \\
7 & 20.00 & 123.00 & 269.81 & 3.84 & 0.00 & \RejectH0 \\
8 & 15.00 & 90.00 & 194.26 & 3.84 & 0.00 & \RejectH0 \\
9 & 10.00 & 50.00 & 84.15 & 3.84 & 0.00 & \RejectH0 \\
10 & 20.00 & 110.00 & 216.66 & 3.84 & 0.00 & \RejectH0 \\
11 & 9.00 & 39.00 & 55.56 & 3.84 & 0.00 & \RejectH0 \\
12 & 20.00 & 108.00 & 208.85 & 3.84 & 0.00 & \RejectH0 \\
13 & 20.00 & 134.00 & 317.88 & 3.84 & 0.00 & \RejectH0 \\
14 & 20.00 & 174.00 & 514.86 & 3.84 & 0.00 & \RejectH0 \\
15 & 9.00 & 54.00 & 109.55 & 3.84 & 0.00 & \RejectH0 \\
16 & 20.00 & 126.00 & 282.65 & 3.84 & 0.00 & \RejectH0 \\
17 & 20.00 & 165.00 & 470.50 & 3.84 & 0.00 & \RejectH0 \\
18 & 20.00 & 170.00 & 493.66 & 3.84 & 0.00 & \RejectH0 \\
\hline
\end{tabular}
\end{table}

\end{document}