2

I have a table with 2 columns. The 2nd column has a content which exceeds a page limit. I wish latex can break it automatically at the end of the page and continue on the next. here's my example.

\documentclass{article}

\usepackage{longtable}

\begin{document}
\begin{longtable}{| p{.75\textwidth} | p{.20\textwidth} |} 
\hline
foo & bar \\ \hline 
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr \\ \hline

\end{longtable}

\end{document}
7
  • Welcome to TeX SX! No, a long table can be broken only at a new row.
    – Bernard
    Commented Aug 4, 2016 at 13:56
  • Yes, it is possible (in principle), but no, I do not know how. It is not a standard feature provided by any of the tabular-like environments.
    – JPi
    Commented Aug 4, 2016 at 13:58
  • You should better use a list perhaps alongs with a tcolorbox (and probably less lines). Commented Aug 4, 2016 at 14:08
  • @JPi I think so too but I've been searching the whole day and couldn't find anything helpful.
    – texguy
    Commented Aug 4, 2016 at 14:22
  • @UlrikeFischer If there's no other alternatives I guess tcolorbox should be acceptable too...
    – texguy
    Commented Aug 4, 2016 at 14:24

1 Answer 1

1

Almost always such "tables" are best set as a list. Here I show the basic default description formatting but list formatting is highly flexible, perhaps most easily by use of the enumitem package. Note that unlike table rows list items always break over a page (here I show breaking over a column in two-column mode, just to make a smaller example).

enter image description here

\documentclass[twocolumn]{article}

\usepackage{longtable}
\hyphenation{ss-s-s-s-s-s-s-s-ss 
             ss-s-s-s-s-s-s-s-s-s-s-s-s-sr
             ss-s-s-s-s-s-s-s-s-s-s-s-s-ss
             ss-s-s-s-s-s-s-s-s-ss
             ss-s-s-s-s-s-s-s-s-s-s-s-s-s-ss
             }

\addtolength\textheight{-10\baselineskip}
\begin{document}

\begin{description}
\item[foo]bar  
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo]bar 
\item[foo] bassssss sssssssssssssssss sssssssssssssssss ssssssssssss
  sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss sssssssssss ssssssssssssssss sssssssssssssssr
\item[foo] bassssss sssssssssssssssss sssssssssssssssss ssssssssssss
  sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss ssssss
\item[foo] bassssss sssssssssssssssss sssssssssssssssss ssssssssssss
  sssssssssss ssssssssssssssss sssssssssssssssr bassssss
  sssssssssssssssss sssssssssssssssss ssssssssssss sssssssssss
  ssssssssssssssss sssssssssssssssr bassssss sssssssssssssssss
  sssssssssssssssss ssssssssssss sssssssssss ssssssssssssssss
  sssssssssssssssr bassssss sssssssssssssssss sssssssssssssssss
  ssssssssssss ssssss zzzzzzz zzzzzzzzzzzzz
\end{description}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .