2

I want to insert a long table in a two-column paper. I tried "tabular" first, but the problem is that it doesn't divide the table among pages. Then people in this post suggested that I use xtab:

How can I make a table that takes up more than a single page?

I tried it but, unfortunately, I got this error after adding the star to a working xtabular table:

./composition-body.tex:392: Missing number, treated as zero.
<to be read again> 
                   |
l.392     \hline

I didn't understand the error, especially that removing the star removes the error. After some search in the internet, I thought it might expect width, so I added {5in} just after \begin{xtabular*}. This solved the compiling problem, but LaTeX still tries to insert the table in a column as shown in the following two images:

enter image description here

enter image description here

Here is the LaTeX code in case you want to read it:

\tablecaption{The factors the camera solver depends on to evaluate the rules.}
\tablehead{\hline \textbf{Factor} & \textbf{Best Value} & \textbf{$\Delta_t$} & \textbf{$\Delta_{do}$} & \textbf{Explanation} \\}
\begin{xtabular*}{5in}{|c|c|c|c|p{3in}|}
    \hline
    %%% ----- Rule of Thirds (Corners) -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Rule of Thirds (Corners)} \\
    \hline
    Horizontal Distance to Corner   & 0     & HD/20         & HD        & The horizontal distance between the centre of mass of the object and the closest corner.                              \\
    \hline
    Vertical Distance to Corner     & 0     & HD/20         & HD        & The vertical distance between the centre of mass of the object and the closest corner.                                \\
    \hline
    %%% ----- Rule of Thirds (Lines) -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Rule of Thirds (Lines)} \\
    \hline
    Line Angle                      & 45    & 15            & 30        & The angle between the prominent line of the object and the diagonal lines                                             \\ % TODO: What object? Make sure it is clear.
    \hline
    Line Distance                   & 0     & 0.25          & 1         & The distance, in screen coordinates, from the prominent line of the object to the diagonal lines.                     \\ % TODO: Need to define screen coordinates
    \hline
    Corner Distances                & 0     & 0.1           & 0.7       & The distance, in screen coordinates, from the end of the prominent line of the object to the corners of the screen.   \\
    \hline
    %%% ----- Diagonal Dominance -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Diagonal Dominance} \\
    \hline
    Line Angle                      & 45    & 15            & 30        & The angle between the prominent line of the object and the diagonal lines                                             \\ % TODO: What object? Make sure it is clear.
    \hline
    Line Distance                   & 0     & 0.25          & 1         & The distance, in screen coordinates, from the prominent line of the object to the diagonal lines.                     \\ % TODO: Need to define screen coordinates
    \hline
    Corner Distances                & 0     & 0.1           & 0.7       & The distance, in screen coordinates, from the end of the prominent line of the object to the corners of the screen.   \\
    \hline
    %%% ----- Visual Balance -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visual Balance} \\
    \hline
    Horizontal Center               & 0     & 0.1           & 0.5       & The horizontal component of the centre of mass of all the objects of the rule.                                        \\ % TODO: What does "objects" mean here? It should be well explained.
    \hline
    Vertical Center                 & 0     & 0.1           & 0.5       & The vertical component of the centre of mass of all the objects of the rule.                                          \\ % TODO: What does "objects" mean here? It should be well explained.
    \hline
    %%% ----- Boundary Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Boundardy Rule} \\
    \hline
    Left Outside                    & 0     & 5\% BW        & 25\% BW   & The width of the part of the object which is beyond the left border of the boundary specified by the rule.            \\
    \hline
    Right Outside                   & 0     & 5\% BW        & 25\% BW   & The width of the part of the object which is beyond the right border of the boundary specified by the rule.           \\
    \hline
    Top Outside                     & 0     & 5\% BH        & 25\% BH   & The height of the part of the object which is beyond the upper border of the boundary specified by the rule.          \\
    \hline
    Bottom Outside                  & 0     & 5\% BH        & 25\% BH   & The height of the part of the object which is beyond the lower border of the boundary specified by the rule.          \\
    \hline
    %%% ----- Framing Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Framing Rule} \\
    \hline
    Left Delta                      & 0     & 5\% FW        & 25\% FW   & The distance between the left of the object's frame and the left of the frame specified by the rule.                  \\
    \hline
    Right Delta                     & 0     & 5\% FW        & 25\% FW   & The distance between the right of the object's frame and the right of the frame specified by the rule.                \\
    \hline
    Top Delta                       & 0     & 5\% FH        & 25\% FH   & The distance between the top of the object's frame and the top of the frame specified by the rule.                    \\
    \hline
    Bottom Delta                    & 0     & 5\% FH        & 25\% FH   & The distance between the bottom of the object's frame and the bottom of the frame specified by the rule.              \\
    \hline
    %%% ----- Visibility Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visibility Rule (Full Visibility)} \\
    \hline
    Visibility                      & 100   & 5             & 50        & The percentage of the visible part of the object.                                                                     \\
    \hline
    %%% ----- Visibility Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visibility Rule (No Visibility)} \\
    \hline
    Visibility                      & 0     & 5             & 50        & The percentage of the visible part of the object.                                                                     \\
    \hline
    %%% ----- Position Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Position Rule} \\
    \hline
    Horizontal Distance             & 0     & 0.01          & 0.25      & The horizontal distance between the centre of mass of the object and the position specified by the rule.              \\
    \hline
    Vertical Distance               & 0     & 0.01          & 0.25      & The vertical distance between the centre of mass of the object and the position specified by the rule.                \\
    \hline
    %%% ----- Size Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Size Rule} \\
    \hline
    Beyond Minimum Width            & 0     & 5\% AOW       & 25\% FW   & The amount the width of the object is beyond the minimum width.                                                       \\
    \hline
    Beyond Minimum Height           & 0     & 5\% AOH       & 25\% FH   & The amount the height of the object is beyond the minimum height.                                                     \\
    \hline
    Beyond Maximum Width            & 0     & 5\% AOW       & 25\% FW   & The amount the width of the object is beyond the maximum width.                                                       \\
    \hline
    Beyond Maximum Height           & 0     & 5\% AOH       & 25\% FH   & The amount the height of the object is beyond the maximum height.                                                     \\
    \hline
    \label{table:factors}
\end{xtabular*}
  • 2
    For these issues it's very important to give as an complete, compilable but minimal example. Just put some dummy text in it using lipsum or blindtext to cause the existing page break scenario and minimize the number of rows. – Martin Scharrer Feb 18 '11 at 11:26
3

So far I understood the source code of xtab the xtabular* version simply uses tabular* internally, i.e. it allows you to set the table width explicitly. This caused your error when the width wasn't given. It apparently doesn't make the tabular span over two columns as it is mentioned in the manual!

My tip:

Put it back into a top float \begin{figure*}[t] to make it appear on top of the next page (or alternatively on the bottom). If the table is still longer than a page, break it down manually into two floats. I think for a paper this effort is acceptable and gives you the best result. For a multi-page (3+) table in a longer document I would do it differently.

| improve this answer | |
2

Using xtabular in two-column document, just compile once and once again. xtab needs to compile many times to determine the proper height of the table.

tabular* in LaTeX, and xtabular*/supertabular* in xtab/supertabular, are not easy to use. You must add @{\extracolsep{\fill}} etc. to fill the columns. For example:

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

\begin{document}

\begin{xtabular*}{\columnwidth}{@{\extracolsep{\fill}}|*{5}{p{1.2cm}|}}
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}

However, it is not suitable for your table, which has too much content itself. Thus, you'd better not use the xtabular* in such narrow column. Here is a better solution:

\documentclass{article}
\usepackage{xtab,colortbl}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\usepackage{multicol}
\usepackage{lipsum}

\begin{document}
\begin{multicols}{2}
\lipsum[1-2]
\end{multicols}
\tablecaption{The factors the camera solver depends on to evaluate the rules.}
\tablehead{\hline \textbf{Factor} & \textbf{Best Value} & \textbf{$\Delta_t$} & \textbf{$\Delta_{do}$} & \textbf{Explanation} \\}
\begin{xtabular*}{\textwidth}{|@{\extracolsep{\fill}}*{4}{C{0.5in}}p{1.8in}|}
    \hline
    %%% ----- Rule of Thirds (Corners) -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Rule of Thirds (Corners)} \\
    \hline
    Horizontal Distance to Corner   & 0     & HD/20         & HD        & The horizontal distance between the centre of mass of the object and the closest corner.                              \\
    \hline
    Vertical Distance to Corner     & 0     & HD/20         & HD        & The vertical distance between the centre of mass of the object and the closest corner.                                \\
    \hline
    %%% ----- Rule of Thirds (Lines) -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Rule of Thirds (Lines)} \\
    \hline
    Line Angle                      & 45    & 15            & 30        & The angle between the prominent line of the object and the diagonal lines                                             \\ % TODO: What object? Make sure it is clear.
    \hline
    Line Distance                   & 0     & 0.25          & 1         & The distance, in screen coordinates, from the prominent line of the object to the diagonal lines.                     \\ % TODO: Need to define screen coordinates
    \hline
    Corner Distances                & 0     & 0.1           & 0.7       & The distance, in screen coordinates, from the end of the prominent line of the object to the corners of the screen.   \\
    \hline
    %%% ----- Diagonal Dominance -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Diagonal Dominance} \\
    \hline
    Line Angle                      & 45    & 15            & 30        & The angle between the prominent line of the object and the diagonal lines                                             \\ % TODO: What object? Make sure it is clear.
    \hline
    Line Distance                   & 0     & 0.25          & 1         & The distance, in screen coordinates, from the prominent line of the object to the diagonal lines.                     \\ % TODO: Need to define screen coordinates
    \hline
    Corner Distances                & 0     & 0.1           & 0.7       & The distance, in screen coordinates, from the end of the prominent line of the object to the corners of the screen.   \\
    \hline
    %%% ----- Visual Balance -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visual Balance} \\
    \hline
    Horizontal Center               & 0     & 0.1           & 0.5       & The horizontal component of the centre of mass of all the objects of the rule.                                        \\ % TODO: What does "objects" mean here? It should be well explained.
    \hline
    Vertical Center                 & 0     & 0.1           & 0.5       & The vertical component of the centre of mass of all the objects of the rule.                                          \\ % TODO: What does "objects" mean here? It should be well explained.
    \hline
    %%% ----- Boundary Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Boundardy Rule} \\
    \hline
    Left Outside                    & 0     & 5\% BW        & 25\% BW   & The width of the part of the object which is beyond the left border of the boundary specified by the rule.            \\
    \hline
    Right Outside                   & 0     & 5\% BW        & 25\% BW   & The width of the part of the object which is beyond the right border of the boundary specified by the rule.           \\
    \hline
    Top Outside                     & 0     & 5\% BH        & 25\% BH   & The height of the part of the object which is beyond the upper border of the boundary specified by the rule.          \\
    \hline
    Bottom Outside                  & 0     & 5\% BH        & 25\% BH   & The height of the part of the object which is beyond the lower border of the boundary specified by the rule.          \\
    \hline
    %%% ----- Framing Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Framing Rule} \\
    \hline
    Left Delta                      & 0     & 5\% FW        & 25\% FW   & The distance between the left of the object's frame and the left of the frame specified by the rule.                  \\
    \hline
    Right Delta                     & 0     & 5\% FW        & 25\% FW   & The distance between the right of the object's frame and the right of the frame specified by the rule.                \\
    \hline
    Top Delta                       & 0     & 5\% FH        & 25\% FH   & The distance between the top of the object's frame and the top of the frame specified by the rule.                    \\
    \hline
    Bottom Delta                    & 0     & 5\% FH        & 25\% FH   & The distance between the bottom of the object's frame and the bottom of the frame specified by the rule.              \\
    \hline
    %%% ----- Visibility Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visibility Rule (Full Visibility)} \\
    \hline
    Visibility                      & 100   & 5             & 50        & The percentage of the visible part of the object.                                                                     \\
    \hline
    %%% ----- Visibility Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Visibility Rule (No Visibility)} \\
    \hline
    Visibility                      & 0     & 5             & 50        & The percentage of the visible part of the object.                                                                     \\
    \hline
    %%% ----- Position Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Position Rule} \\
    \hline
    Horizontal Distance             & 0     & 0.01          & 0.25      & The horizontal distance between the centre of mass of the object and the position specified by the rule.              \\
    \hline
    Vertical Distance               & 0     & 0.01          & 0.25      & The vertical distance between the centre of mass of the object and the position specified by the rule.                \\
    \hline
    %%% ----- Size Rule -----
    \multicolumn{5}{|>{\columncolor[gray]{.8}}l|}{Size Rule} \\
    \hline
    Beyond Minimum Width            & 0     & 5\% AOW       & 25\% FW   & The amount the width of the object is beyond the minimum width.                                                       \\
    \hline
    Beyond Minimum Height           & 0     & 5\% AOH       & 25\% FH   & The amount the height of the object is beyond the minimum height.                                                     \\
    \hline
    Beyond Maximum Width            & 0     & 5\% AOW       & 25\% FW   & The amount the width of the object is beyond the maximum width.                                                       \\
    \hline
    Beyond Maximum Height           & 0     & 5\% AOH       & 25\% FH   & The amount the height of the object is beyond the maximum height.                                                     \\
    \hline
    \label{table:factors}
\end{xtabular*}
\begin{multicols}{2}
\lipsum[3-4]
\end{multicols}

\end{document}
| improve this answer | |
  • It doesn't work :-( – Rafid Feb 21 '11 at 13:52
  • Your texts in table are too wide for four c column. If you use \begin{xtabular*}{\columnwidth}{@{\extracolsep{\fill}}|*{5}{p{1cm}|}}, the result would fit one column and break properly, but really bad look. Narrow table is not suitable here. You'd better use a wide one, say, table placed by table* environment, or use multicol package to switch the columns. – Leo Liu Feb 22 '11 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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