Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to split a table in several pages, for doing this I'm using the xtab package and xtabular. However, the behavior of the xtabular* environment (that supposedly should break the two column format and be only one column) is quite odd, because it is not working (as this other question also shows).

It is wrapping around the two columns, instead of creating a single column. And, as you can see in the example below, if the text is wider than the column width it get over the content of the next column.

I would like the behavior of splitting the tables of the xtabular in single column document, in the two column document using xtabular*.

Can you point me in the right direction? Or another package that will accomplish the same result?

\documentclass[twocolumn]{article}
\usepackage{xtab}

\begin{document}

\begin{xtabular*}{\textwidth}{@{\extracolsep{\fill}}|*{5}{p{1.2cm}|}}
\hline
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
\end{xtabular*}

\end{document}

Edit (Partial Solution)

So, I've been trying to solve this, and I try using figure or other float environment (like table*) to make it work. The closest I get was using table*. However, as you may know, by putting it into a one big float the table isn't split into many tables.

So, I thought to try to redefine an xtabular* that is wrapped around a table*. So I make this attempt:

\documentclass[twocolumn]{article}
\usepackage{xtab}
\usepackage{lipsum}

\makeatletter
\newif\ifST@tb
\@namedef{tbxtabular*}#1{%
  \@ifnextchar[{\@nameuse{@tbsupertabular*}{#1}}%
               {\@nameuse{@tbsupertabular*}{#1}[]}%]
}

\@namedef{@tbsupertabular*}#1[#2]#3{%
  \ST@trace\tw@{Starting a new tbxtabular*}%
  \def\ST@tableformat{#3}%
  \ST@wd=#1\relax
  \global\ST@startrue
  \global\ST@tbtrue
  \ST@rightskip \rightskip
  \ST@leftskip \leftskip
  \ST@parfillskip \parfillskip
  \x@supertabular
  \csname table*\endcsname[t]
  \noindent\expandafter\csname org@tabular*\expandafter\endcsname
  \expandafter{\expandafter\ST@wd\expandafter}%
  \expandafter{\ST@tableformat}%
  \@@tablehead}

\def\endtbxtabular{%
  \ifx\@table@last@tail\undefined
    \@tabletail
  \else
    \@table@last@tail
  \fi
  \csname endtabular\ifST@star*\fi\endcsname
  \csname endtable*\endcsname
  \x@endsupertabular
  \ST@trace\tw@{Ended an tbxtabular\ifST@star*\fi}}
  \expandafter\let\csname endtbxtabular*\endcsname\endtbxtabular
\def\ST@newpage{%
  \noalign{\ST@trace\tw@{Starting new page, writing tail}}%
  \@tabletail
  \ifST@star
    \csname endtabular*\endcsname
  \else
    \endtabular
  \fi
  \ifST@mp
    \endminipage
  \fi
  \ifST@tb
    \csname endtable*\endcsname
  \fi
  \global\let\ST@skippage\ST@newpage
  \newpage\PWSTcalnextpageht
  \ST@trace\tw@{writing head}%
  \PWSTsethead
  \ifST@mp
    \noindent\minipage{\columnwidth}%
    \parfillskip\ST@parfillskip
    \rightskip \ST@rightskip
    \leftskip \ST@leftskip
  \fi
  \ifST@tb
    \noindent\csname table*\endcsname[t]
  \fi
  \noindent
  \ifST@star
    \expandafter\csname org@tabular*\expandafter\endcsname
    \expandafter{\expandafter\ST@wd\expandafter}%
    \expandafter{\ST@tableformat}%
  \else
    \expandafter\org@tabular\expandafter{\ST@tableformat}%
  \fi}

\makeatother


\begin{document}
\lipsum[1-5]


\tablefirsthead{\hline \textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E}\\}
\tablehead{\hline \textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E}\\}
\tabletail{\hline}
\begin{tbxtabular*}{\textwidth}{@{\extracolsep{\fill}}|*{5}{p{1.2cm}|}}
\hline
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
\end{tbxtabular*}


\lipsum[1-5]
\end{document}

I changed the mpxtabular*, and create a tbxtabular* version of it, that is mainly the xtabular* with a table* around it. I don't know if this is the best approach or I'm just wasting my time. But, at least the tables now are converted into one column and are placed nicely in different pages and not over the text. However, the tables are not split correctly (c.f. pages 4 and 5).

Error pages

share|improve this question
add comment

migrated from stackoverflow.com Nov 30 '11 at 2:55

This question came from our site for professional and enthusiast programmers.

2 Answers

Replace \textwidth with \linewidth.

\documentclass[twocolumn]{article}

\usepackage{xtab}

\begin{document}

\begin{xtabular*}{\linewidth}{@{\extracolsep{\fill}}|*{5}{p{1.2cm}|}}
\hline
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
a & b & c & d & e \\
(This is the last table row)
\end{xtabular*}

\end{document}
share|improve this answer
    
Actually, I was trying to show that when the table is wider than the linewidth, xtabular* does not break the two column format, and just goes into the other column. I thought that when one uses the starred version, it will behave like the normal xtabular in one column. Instead it just overflows into the other column. So, is there a way to automatically fix this length? Or should I manually fix the content so it doesn't overflow to the linewidth? –  adn Dec 12 '11 at 2:29
add comment

You didn't define it as a table.

It should read like this:

\begin{table}

   \begin{xtabular*}{\textwidth}{@{\extracolsep{\fill}}|*{5}{p{1.2cm}|}}

      \hline

     a & b & c & d & e \\
      ...
      ...
      ...

   \end{xtabular*}

\end{table}
share|improve this answer
    
Welcome to TeX.sx! Your answer was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other. –  Werner Nov 30 '11 at 3:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.