4

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. – osolmaz Oct 29 '12 at 11:55
  • 2
    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 ^^ – osolmaz Oct 29 '12 at 12:01
3

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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