2
\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.

  • 1
    @{}l@{\extracolsep{\fill}}r@{} – Fran May 19 at 8:12
  • 2
    Do you mean the whole page's margin, or just the table? – L. Nielsen May 19 at 8:16
  • Thank you Fran and Nielsen. {\textwidth}{@{}l@{\extracolsep{\fill}}r@{}} is exactly what I wanted. – – ARUN KUMAR May 19 at 12:26
4
\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}
| improve this answer | |

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.