# How to set zero margin around tabular of textwidth?

\begin{tabular*}{ \textwidth{l@{\extracolsep{\fill}}r} a & b \end{tabular*}


I need to fit a tabular to textwidth with zero left and right margins. The code above allows to fit the text to table width, but I don't know how to set the left and right margins to zero.

• @{}l@{\extracolsep{\fill}}r@{}
– Fran
May 19, 2020 at 8:12
• Do you mean the whole page's margin, or just the table? May 19, 2020 at 8:16
• Thank you Fran and Nielsen. {\textwidth}{@{}l@{\extracolsep{\fill}}r@{}} is exactly what I wanted. – May 19, 2020 at 12:26

## 1 Answer

\documentclass{article}
\begin{document}
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}r@{}}%
\hline a&b\\\hline
\end{tabular*}
\end{document}


Of course, if the table is not in a float (a table environment) and \partindent is not 0pt (the default) as in this MWE, remember add \noindent before the tabular* environment to maintain it between the page margins.

If you refer to extend the table to the page margins, as L. Nielsen suspected, the trick is put the table in a centered box of zero space, and of course, make the table enough big:

\documentclass{article}
\usepackage{geometry}
\begin{document}
\centering\makebox[0cm]{%
\begin{tabular*}{\paperwidth}{@{}l@{\extracolsep{\fill}}r@{}}%
\hline a&b\\\hline%
\end{tabular*}}%
\end{document}