Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

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.

enter image description here

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} 
share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
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

1 Answer 1

up vote 0 down vote accepted

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

enter image description here

\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}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.