# Adjusting table to \textwidth with calc and \p{}

The following tabular environment has 3 columns. Each column has a width of \textwidth/3, but somehow the table is wider than \textwidth.

\documentclass{article}

\usepackage{calc,lipsum}
\begin{document}

\begin{tabular}{||p{\textwidth/3}||p{\textwidth/3}|p{\textwidth/3}||}
aaaaaaa&bbbbbbbb&cccccccccc\\
\end{tabular}

\lipsum
\end{document}


What might the problem be?

-
You are not allowing for the inter-column separation. Do you want to remove this entirely or to allow for it? –  Joseph Wright Oct 29 '12 at 11:53
@JosephWright There won't be any space betweeen the columns. –  hos Oct 29 '12 at 11:55
If you remove the vertical rules (that are bad typography anyway), just saying p{\textwidth/3 - 2\tabcolsep} will do. –  egreg Oct 29 '12 at 11:59
Adding - 2\tabcolsep fixed the problem. Thanks ^^ –  hos Oct 29 '12 at 12:01

using tabularx makes more sense in this special case

\documentclass{article}

\usepackage{tabularx,lipsum}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|| X || X | X ||}
aaaaaaa&bbbbbbbb&cccccccccc\\
\end{tabularx}

\lipsum
\end{document}

-