# Making table width fit into text width [duplicate]

I'm using p{} format to adjust the width of a table.

I expected using {p{0.1\textwidth}||p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}} makes the table width smaller than the text width (1 > 0.1 + 0.2*4), but the result is not what I expect.

What might be wrong? Why the total width of the table is wider than text width?

This is the code.

\documentclass[oneside, openany, 10pt]{article}
%\documentclass[article, oneside, openany, 10pt]{memoir}
\newcommand{\HRule}{\rule{1.0\textwidth}{0.5mm}}
\newcommand{\Hrule}{\rule{1.0\textwidth}{0.3mm}}

\makeatletter% since there's an at-sign (@) in the command name
\renewcommand{\@maketitle}{%
\parindent=0pt% don't indent paragraphs in the title block
\centering
{\Large \bfseries\textsc{\@title}}
\HRule\par%
\textit{\@author \hfill \@date}
\par
}
\author{prosseek}
\title{test}

\begin{document}

\maketitle

\begin{table}[hbtp]
\footnotesize
\centering
\begin{tabular}{p{0.1\textwidth}||p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}}
\hline
& Function & Pre conditions & Post conditions & Constraints \\
\hline\hline
R1 & An election official is assigned for each precinct & Precincts and
elections officials are created & Unique one on one mapping from an
election official to precinct & Before voting starts\\  \hline
\end{tabular}
\caption{Requirements before voting starts}
\label{eoRequirements}
\end{table}

\end{document}

-

## marked as duplicate by Werner, Kurt, Benedikt Bauer, mafp, dustinSep 27 '13 at 18:46

Because you are not counting some other spaces (such as tabcolsep). You could work around this by using either tabulary or tabularx... or simply considering the missing space (check the array documentation ) – Mario S. E. Sep 27 '13 at 15:40

With Mario's hint, I could use tabularly to get this result.

\maketitle
\begin{table}[hbtp]
\footnotesize
\centering
\begin{tabulary}{1.0\textwidth}{C||L|L|L|L}
\hline
& Function & Pre conditions & Post conditions & Constraints \\
\hline\hline
R1 & An election official is assigned for each precinct & Precincts and
elections officials are created & Unique one on one mapping from an
election official to precinct & Before voting starts\\  \hline
\end{tabulary}
\caption{Requirements before voting starts}
\label{eoRequirements}
\end{table}

-
I think you should write it like 1.0*\textwidth – lonesome Apr 30 '15 at 3:06