# How can I remove the extra padding from my longtable's right-most column?

I used the following code to create a longtable with five columns that stretches the full width of the page. I like everything about this table except for the fact that all columns are padded to make the table as wide as the page. Instead, I would like the first four columns to expand in this way, but I would like the fifth column (the one with header D) to be "sized to content". That is, I would like it to be only as wide as it needs to be to fit its values.

\documentclass[table]{article}

\usepackage{fancyhdr}
\usepackage[left=0.50in,top=2.0in,right=0.50in,bottom=1.0in]{geometry}
\setlength\parindent{0pt}

\usepackage{longtable}
\usepackage{pdflscape}

\begin{document}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{l @{\extracolsep{\fill}} |   r|r|r|r}

\multicolumn{5}{r}{\bfseries {\Large{My Table}}} \\

& {\bfseries A}
& {\bfseries B}
& {\bfseries C}
& {\bfseries D}
\\

\multicolumn{5}{r}{\bfseries {\Large{My Table (continued)}}} \\

% name
& {\bfseries A}
& {\bfseries B}
& {\bfseries C}
& {\bfseries D}
\\
\hline

\hline

\hspace{4mm}\ Row 1 \hspace{2mm}
& 1,200
& 800
& 2,000
& 1
\\

\hspace{4mm}\ Row 2  \hspace{2mm}
& 1,201
& 801
& 2,001
& 123
\\

\end{longtable}

\end{document}


How it currently looks:

My crude approximation of how it should look:

Is there a way to do this?

• Welcome to TeX.SE. – Mico Nov 25 '20 at 5:44
• As always on the site, please provide a full minimal example, not sniplets. With a full but minimal self contained example it is a lot easier for others to copy your code and test it as is. Here we have to add stuff to even compile it, so a lot of people will not even bother to look at it. – daleif Nov 25 '20 at 7:08
• I have updated the code to show the full document, rather than just a snippet. Thank you. – ngm Nov 25 '20 at 14:55

Like this:

\documentclass{article}

%\usepackage{fancyhdr}
\usepackage[hmargin=0.50in,top=2.0in,bottom=1.0in]{geometry}
\setlength\parindent{0pt}

\usepackage{array, longtable}
%\usepackage{pdflscape}

\begin{document}

%\setlength\LTleft{0pt}
%\setlength\LTright{0pt}

\multicolumn{5}{r}{\bfseries {\Large{My Table}}} \\

& {\bfseries A}
& {\bfseries B}
& {\bfseries C}
& {\bfseries D}
\\

\multicolumn{5}{r}{\bfseries {\Large{My Table (continued)}}} \\

% name
& {\bfseries A}
& {\bfseries B}
& {\bfseries C}
& {\bfseries D}
\\
\hline

\hline

Row 1       & 1,200
& 800
& 2,000
& 1
\\

Row 2       & 1,201
& 801
& 2,001
& 123
\\

\end{longtable}

\end{document}

• Works great, thank you! – ngm Nov 25 '20 at 21:56