# Make table page size [duplicate]

I am new to latex and cannot solve to fit this table to page size even though I looked up the problem in the forum. Any help would be very much appreciated.

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[scaled]{helvet}
\usepackage[table]{xcolor}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
\thispagestyle{empty}
\usepackage[margin=0.7in]{geometry}
\begin{document}
\rowcolors{2}{gray!25}{white} % for alt row cols
\begin{table}[ht]
\centering
\makebox[\linewidth]{
\begin{tabular}{lllllll}
\rowcolor{gray!50} %for alt row cols
\hline
& Overall & None (N) & Mild (M) & Moderate (M) & Severe (S) \\
& Mean\% (SE) (95\% CI)&Mean\% (SE) (95\% CI)& Mean\% (SE) (95\%         CI)&Mean\% (SE) (95\% CI) & Mean\% (SE) (95\% CI) \\
\hline
\textbf{XXXXXX}& 65 (61 - 69) & 20 (17 - 23)& 8 (6 - 10) & 7 (5 - 9) & \\
\textbf{XXXXXXX} (XXXX-XXX)&  42 (34 - 51) & 23 (15 - 30) & 17 (10 - 24) & 18 (11 - 25) & \\
\textbf{XXXXXXX} (XXXX-XXXX)& 62 (53 - 70) & 19 (11 - 26) & 8 (3 - 12) & 12 (6 - 17) & \\
\textbf{XXXXXX}& 73 (63 - 84) & 18 (8 - 28) & 5 (1 - 9) & 4 (-1 - 9) & \\
\hline
\end{tabular}
}
\end{table}

\end{document}

## marked as duplicate by Werner tables StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jan 19 at 18:21

• Use \resizebox{\textwidth}{!} instead of \makebox[\linewidth] with \usepackage{graphicx} in preamble. – ferahfeza Jan 19 at 12:37
• @ferahfeza scaling tables makes horrible, inconsistent output. – David Carlisle Jan 19 at 12:50
• Mine was just a suggestion. – ferahfeza Jan 19 at 12:54
• @ferahfeza: For that I would recommend \begin{adjustbox}{max width=\linewidth,center}, but I agree with David. – Martin Scharrer Jan 19 at 12:57
• You mean to fit the table inside the normal text area, right? Not scaling it so that it covers literally the whole page? Maybe change l to p{some length} in the argument of tabular so that you can have automated line breaks in longer cells. – Martin Scharrer Jan 19 at 13:02

I suggest you switch from tabular to tabularx and allow line breaks in each of the five data column header cells.

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}\usepackage[scaled]{helvet}
\usepackage[table]{xcolor}
\renewcommand\familydefault{\sfdefault}
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\begin{document}
\begin{table}[ht]
\rowcolors{2}{gray!25}{white} % for alt row cols
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{3pt} % default 6pt
\begin{tabularx}{\textwidth}{l *{5}{C}}
\hline
\rowcolor{gray!50} % for this row only
& Overall & None (N) & Mild (M) & Moderate (M) & Severe (S) \\
& Mean\% (SE) (95\%~CI)&Mean\% (SE) (95\%~CI)& Mean\% (SE) (95\%~CI)&Mean\% (SE) (95\%~CI) & Mean\% (SE) (95\%~CI) \\
%\hline
\textbf{XXXXXX}& 65 (61--69) & 20 (17--23)& 8 (6--10) & 7 (5--9) & \\
\textbf{XXXXXXX} (XXXX-XXX)&  42 (34--51) & 23 (15--30) & 17 (10--24) & 18 (11--25) & \\
\textbf{XXXXXXX} (XXXX-XXXX)& 62 (53--70) & 19 (11--26) & 8 (3--12) & 12 (6--17) & \\
\textbf{XXXXXX}& 73 (63--84) & 18 (8--28) & 5 (1--9) & 4 ($-$1--9) & \\
\hline
\end{tabularx}
\end{table}
\end{document}
• Alternative would be something like \begin{tabular}{lp{.125\linewidth}p{.125\linewidth}p{.125\linewidth}p{.125\linewidth}p{.125\linewidth}} – Martin Scharrer Jan 19 at 13:00
• @MartinScharrer - I suppose that if the OP wants the contents of the five data columns to be typeset ragged-right rather than centered, one could run \newcolumntype{L}{>{\RaggedRight\arraybackslash}X} in the preamble and subsequently change \begin{tabularx}{\textwidth}{l *{5}{C}} to \begin{tabularx}{\textwidth}{l *{5}{L}}. – Mico Jan 19 at 14:04
• \begin{table}[p] will put the table on its own page, or at least on a page with no text. See also sidewaystable from rotating. – John Kormylo Jan 19 at 17:03

There are two parts to this:

1) How do I force LaTeX to put my table on its own page?

2) How do I make the table fill the page?

For the first, drop the {table} environment. For years, I struggled with my tables and figures going where I wanted them to until I realized that those environments were just about float placement and indexing, and weren't necessary for either a {tabular} or an \includegraphics. If you put down a {tabular} environment with all of your desired data and \clearpage before and after it, you'll get the table on its own page right in the spot in the text that you want it.

For the second question, you can set your column widths to be whatever you want, and experiment with what looks right for your columns.

For making a page-sized table that will float, I recommend creating a minibox with the same size as your page size (or the size of your page minus margins).

\begin{table}[ht]
\begin{minipage}{\textwidth}
\begin{tabular}...
• The directive \begin{tabular}[ht] can't be correct. Did you mean to write \begin{table}[ht]? – Mico Jan 19 at 14:03