[Tex/LaTex] multi-page two column table in a single column document

columnstablesxtab

I have looked through and tried quite a few probable solutions but am unable to get this right. I am posting the best minimal example I currently have of what I am trying to accomplish here. Being new, I am not allowed to post images, so please do copy the two files and compile.

I want the title to be at the top of both the sides/columns of the table and also to manage the extra whitespace at the end of table.

\documentclass{article}
\usepackage[left=2cm, top=3cm, right=2cm, bottom=3cm]{geometry}
\usepackage{tabularx}
\usepackage{xtab}

\begin{document}

\section{List}

\topcaption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
\label{tab:xxxxx}

\twocolumn

\tablehead{\hline x & x*x \\ \hline}

\begin{xtabular}{| l || c |}
\input{squares.tex}
\end{xtabular}
\end{document}

Data File to test the script above :: squares.tex

101 & 10201 \\
102 & 10404 \\
103 & 10609 \\
104 & 10816 \\
105 & 11025 \\
106 & 11236 \\
107 & 11449 \\
108 & 11664 \\
109 & 11881 \\
110 & 12100 \\
111 & 12321 \\
112 & 12544 \\
113 & 12769 \\
114 & 12996 \\
115 & 13225 \\
116 & 13456 \\
117 & 13689 \\
118 & 13924 \\
119 & 14161 \\
120 & 14400 \\
121 & 14641 \\
122 & 14884 \\
123 & 15129 \\
124 & 15376 \\
125 & 15625 \\
126 & 15876 \\
127 & 16129 \\
128 & 16384 \\
129 & 16641 \\
130 & 16900 \\
131 & 17161 \\
132 & 17424 \\
133 & 17689 \\
134 & 17956 \\
135 & 18225 \\
136 & 18496 \\
137 & 18769 \\
138 & 19044 \\
139 & 19321 \\
140 & 19600 \\
141 & 19881 \\
142 & 20164 \\
143 & 20449 \\
144 & 20736 \\
145 & 21025 \\
146 & 21316 \\
147 & 21609 \\
148 & 21904 \\
149 & 22201 \\
150 & 22500 \\
151 & 22801 \\
152 & 23104 \\
153 & 23409 \\
154 & 23716 \\
155 & 24025 \\
156 & 24336 \\
157 & 24649 \\
158 & 24964 \\
159 & 25281 \\
160 & 25600 \\
161 & 25921 \\
162 & 26244 \\
163 & 26569 \\
164 & 26896 \\
165 & 27225 \\
166 & 27556 \\
167 & 27889 \\
168 & 28224 \\
169 & 28561 \\
170 & 28900 \\
171 & 29241 \\
172 & 29584 \\
173 & 29929 \\
174 & 30276 \\
175 & 30625 \\
176 & 30976 \\
177 & 31329 \\
178 & 31684 \\
179 & 32041 \\
180 & 32400 \\
181 & 32761 \\
182 & 33124 \\
183 & 33489 \\
184 & 33856 \\
185 & 34225 \\
186 & 34596 \\
187 & 34969 \\
188 & 35344 \\
189 & 35721 \\
190 & 36100 \\
191 & 36481 \\
192 & 36864 \\
193 & 37249 \\
194 & 37636 \\
195 & 38025 \\
196 & 38416 \\
197 & 38809 \\
198 & 39204 \\
199 & 39601 \\
200 & 40000 \

Best Answer

longtable can in fact work in two column mode, it just needs a bit of encouragement not to give up and issue an error message:

enter image description here

\documentclass{article}
\usepackage[left=2cm, top=3cm, right=2cm, bottom=3cm]{geometry}
\usepackage{longtable}


\makeatletter
\let\saved@longtable\longtable
\long\def\foo#1\LT@err#2#3#4!!{\def\longtable{#1#4}}
\expandafter\foo\longtable!!

\long\def\foo#1\@outputpage#2\@outputpage#3!!{%
\def\LT@output{#1\@opcol#2\@opcol#3}}
\expandafter\foo\LT@output!!
\makeatother

\begin{document}




\twocolumn[\section{List}]



\begin{longtable}{| l || c |}
\caption{Some square numbers\label{tab:xxx}}\\
$n$&$n$-squared\\
\hline
\endfirsthead
$n$&$n$-squared\\
\hline
\endhead
a&b\\\relax
\input{squares.tex}
\end{longtable}
\end{document}