# Variable Column Names using longtable?

I've been using the longtable package in order to create a multiple page table. However, I want all of my column names to be different and am having a hard time getting it to work properly. While I've found examples that show how to vary the column names across two pages, I haven't been able to get three pages (or more) to show the proper column names. The first set of names shows up on the first page, but then the third set is at the top of the remainder of pages. I have 43 columns, so trying to force them all onto 2 pages would probably render them illegible. Any advice or suggestions?

\begin{longtable}{lcccccccccccr}
\textbf{HIP}& \textbf{(X,Y,Z)}& \textbf{[Li/H]}& \textbf{[C/H]}& \textbf{[N/H]}& \textbf{[O/H]}& \textbf{[Na/H]}& \textbf{[Mg/H]} & \textbf{[Al/H]}& \textbf{[Si/H]}& \textbf{[S/H]} & \textbf{[K/H]}& \textbf{[Ca/H]} \\
\hline
\endfirsthead

\multicolumn{13}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{HIP} & \textbf{[CaII/H]} & \textbf{[Sc/H]}& \textbf{[ScII/H]}& \textbf{[Ti/H]}& \textbf{[TiII/H]}& \textbf{[V/H]}& \textbf{[VII/H]}& \textbf{[Cr/H]} & \textbf{[CrII/H]} & \textbf{[Mn/H]} & \textbf{[Fe/H]}& \textbf{[FeII/H]} \\
\endhead
\hline \multicolumn{13}{c}{\textit{Continued on next page}} \\
\endfoot

\multicolumn{13}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{HIP} & \textbf{[Co/H]} & \textbf{[Ni/H]}& \textbf{[Cu/H]}& \textbf{[Zn/H]}& \textbf{[Sr/H]}& \textbf{[Y/H]}& \textbf{[YII/H]}& \textbf{[Zr/H]} & \textbf{[ZrII/H]} & \textbf{[Mo/H]} & \textbf{[Ru/H]}& \textbf{[Ba/H]} \\
\endhead
\hline \multicolumn{13}{c}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot

[data]

\end{longtable}

-
Welcome to TeX.sx! You are using multiple \endhead commands and so the last one is overwriting the previous one. You can only have three different header specifications AFAIK: for the first, last and all other pages. You could add the header line as custom macro which changes its definition at every use. (Just an idea without actual solution to show, so I add it as comment, not as an answer) – Martin Scharrer Jul 6 '11 at 7:25
I have some difficulties understanding your requirements of changing column names per-page. Depending on the contents some rows will end up on one page or another and then they would be in a different labeled column. You know you can simply add the column name rows into the table content as well? – Martin Scharrer Jul 6 '11 at 7:29
After trying to manipulate the placement of \endhead - I didn't really find anything that worked properly. I need to have the column names change per page because I have so many, but only ~15 rows. So the possibility of rows shifting around isn't a worry - merely showing all my data. I think that adding the column names into the table rows is my best bet. Thanks. – cosmosis Jul 7 '11 at 0:02

## 1 Answer

(Originally posted as a comment by the OP cosmosis)

After trying to manipulate the placement of \endhead, I didn't really find anything that worked properly. I need to have the column names change per page because I have so many, but only about 15 rows. So the possibility of rows shifting around isn't a worry -- merely showing all my data. I think that adding the column names into the table rows is my best bet.

-