# How to adjust space between columns in longtable environment?

In the regular tabular environment, we can use \setlength{\tabcolsep} to specify the size of the space between the columns, but this doesn't work in longtable. Is there a similar command?

\documentclass[12pt]{article}
\usepackage{longtable}

\begin{document}
\begin{longtable}{rl}
\setlength{\tabcolsep}{2pt}
2: $x^3$&= $6x^2-4x-16$ \\
4: $x^5$ &= $6x^4-8x^3+8x^2-16x-64$ \\
6: $x^9$ &= $6x^8-4x^7-24x^6+48x^5-32x^4-64x^3-384x^2+256x+1024$ \\
8: $x^{15}$ &=$6x^{14}-4x^{13}-16x^{12}-32x^{11}+192x^{10}-128x^{9}-512x^8+512x^7$\\
&$\hspace{.25cm}-3072x^6+2048x^5+8192x^4+4096x^3-24576x^2+16384x+65536$
\end{longtable}

\end{document}

-
Welcome to TeX.sx! You have to do the setting of \tabcolsep before starting the longtable. But \begin{longtable}{@{}r@{\hspace{2pt}}l@{}} would do the same. Are you sure you need a longtable? Wouldn't align from amsmath do as well? –  egreg Apr 26 '13 at 15:42
A tip: You can use backticks  to mark your inline code as I did in my edit. –  hpesoj626 Apr 26 '13 at 15:43
As egreg said, note it wouldn't work in tabular if you set it in that position either. –  David Carlisle Apr 26 '13 at 15:44

You need to set the length before entering longtable just as you would set it before tabular. However note that as set you have = being set out of math mode so getting incorrect spacing. The second example shows = set in math mode with mathrel spacing. Finally a suggestion not to use longtable at all but a dedicated math display environment such as align.

\documentclass[12pt]{article}
\usepackage{longtable,amsmath}

\begin{document}
{\setlength{\tabcolsep}{2pt}
\begin{longtable}{rl}
2: $x^3$&= $6x^2-4x-16$ \\
4: $x^5$ &= $6x^4-8x^3+8x^2-16x-64$ \\
6: $x^9$ &= $6x^8-4x^7-24x^6+48x^5-32x^4-64x^3-384x^2+256x+1024$ \\
8: $x^{15}$ &=$6x^{14}-4x^{13}-16x^{12}-32x^{11}+192x^{10}-128x^{9}-512x^8+512x^7$\\
&$\hspace{.25cm}-3072x^6+2048x^5+8192x^4+4096x^3-24576x^2+16384x+65536$
\end{longtable}
}

2& $x^3$&${}= 6x^2-4x-16$ \\
4& $x^5$ &${}= 6x^4-8x^3+8x^2-16x-64$ \\
6& $x^9$ &${}= 6x^8-4x^7-24x^6+48x^5-32x^4-64x^3-384x^2+256x+1024$ \\
8& $x^{15}$ &${}=6x^{14}-4x^{13}-16x^{12}-32x^{11}+192x^{10}-128x^{9}-512x^8+512x^7$\\
&&$\hspace{.25cm}{}-3072x^6+2048x^5+8192x^4+4096x^3-24576x^2+16384x+65536$
\end{longtable}

\begin{align*}
x^3&= 6x^2-4x-16 \tag{2}\\
x^5 &= 6x^4-8x^3+8x^2-16x-64 \tag{4}\\
x^9 &= 6x^8-4x^7-24x^6+48x^5-32x^4-64x^3-384x^2+256x+1024  \tag{6}\\
x^{15} &=6x^{14}-4x^{13}-16x^{12}-32x^{11}+192x^{10}-128x^{9}-512x^8+512x^7\tag{8}\\
`