1

This question already has an answer here:

Consider the following:

\documentclass{article}

\setlength\parindent{0pt}

\begin{document}
content \hfill content

\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}
  one   & two \\
  three & four
\end{tabular*}

content \hfill content
\end{document}

output

How can I remove the whitespace at either side of the tabular?

marked as duplicate by user11232, Jesse, Guido, karlkoeller, Reinstate Monica - M. Schröder Jan 8 '14 at 7:32

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.

  • Of course I find the problem as soon as I guts up and post: while I'm not specifying to display them, LaTeX is leaving room for separator lines. Adding \setlength{\tabcolsep}{0pt} solves this issue. ('Doh!) – Sean Allred Jan 8 '14 at 6:07
  • 2
    While it won't make a difference in the present case, it's better in general to insert @{} in front of the first column and after the final column to eliminate the extra whitespace. I.e., one would write something like \begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}r@{}}. One reason this it better is because it works with all other tabular-type environments, viz., tabular, tabularx, tabulary, etc. – Mico Jan 8 '14 at 6:28
  • @Mico Your right. Sounds like an answer (before the potential closing I started…) :-) – Sean Allred Jan 8 '14 at 6:39
  • Related/duplicate: Column and row padding in tables – Werner Jan 8 '14 at 7:01
4

While \setlength{\tabcolsep}{0pt} will do the job in your example, it's better in general to insert @{} in front of the first column and after the final column to eliminate the whitespace (in the amount of \tabcolsep) that LaTeX inserts by default in these locations.

For the case of your example, you'd write

\begin{tabular*}{\textwidth}{@{} l @{\extracolsep{\fill}} r @{}}

instead of

\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} r}

The approach based on inserting @{} particles is better because it works not only with tabular* but also with tabular, tabularx, tabulary, and so on.

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