In addition to the approach that uses the adjustwidth
environment to change the width of the text block locally, you can also reduce the amount of inter-column white-space to reduce the overall width of the table and hence make it fit into the normal text block.
Specifically, I recommend that you (i) omit all vertical rules (because they take up some space), (ii) use the booktabs
package to get well-spaced horizontal rules, and (iii) reduce the amount of inter-column whitespace. The third task may be achieved most easily, in my opinion, by using a tabular*
environment instead of a tabular
environment, setting \tabcolsep
to 0pt
, and using an @{\extracolsep{\fill}}
directive -- I know, it's not exactly intuitive! -- to make LaTeX figure out how much intercolumn whitespace needs to to be inserted.
As in one of the other answers, I've specified the showframe=true
option of the geometry
package merely to show the width of the text block.
By the way, if one needs to specify that a table should have 21 columns of type l
, it is not necessary to type
\begin{tabular}{ l | l | l | l ... l }
Instead, one may specify \begin{tabular}{ l *{20}{|l} }
to denote 20 instances of "|l". As explained above, I think the table looks just as good -- actually, better :-) -- without any vertical rules, hence my specification *{21}{l}
. If you simply must have vertical rules after the first column and then after every fifth column, say, you could specify \begin{tabular}{ l *{4}{|lllll} }
.
Finally, when placing a tabular
(or tabular*
) environment in a float
environment, it's better to use the table
environment rather than the figure
environment (as you did in your MWE).
\documentclass[letterpaper]{article}
\usepackage{booktabs}
\usepackage[margin=1in,showframe=true]{geometry} % remove 'showframe' option in real doc.
\begin{document}
\begin{figure}
\setlength{\tabcolsep}{0pt} % let LaTeX figure out amount of intercolumn whitespace
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{21}{l}} % no vert. bars
\toprule
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 \\
\midrule
Day 1 & 9.2&8.6&8.1&6.3&7.7&7.3&8.0&8.4&5.9&6.8&7.3&7.6&9.0&7.4&6.6&7.0&5.3&7.0&8.0&5.2\\
Day 2 & 6.7&6.9&0&7.0&0&8.1&9.0&6.1&0&6.9&0&7.3&7.8&5.3&0&8.9&0&8.4 &8.4&7.5\\
Day 3 & 0&5.2&0&0&7.5&0&0&8.2&0&0&5.4&0&0&8.3&0&0&7.7&0&0&7.3\\
\bottomrule
\end{tabular*}
\caption{\label{tab:text}Text Experiment}
\end{figure}
\end{document}