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 just discovered the tabularx package which allows me to introduce a table column which has line wrapping, and I also know that packages that allow automatic table splitting across pages do exists (e.g. longtable).

The problem is that I need both features at once, and nesting two commands provided by two different packages doesn't work (e.g. longtable + tabularx).

I would prefer a solution which uses tabularx + some other package if necessary to achieve this. Otherwise, any solution is acceptable which allows me to do automatic table splitting across pages and long line wrapping on the same table.

share|improve this question
3  
lockstep has given an answer for combining tabularx and longtable, but your wording makes me check that you do realise that standard latex tables allow line wrapping if you use a p column? (tabularx just saves you from specifying the column width) similarly you can use p columns in longtable without any additional packages. –  David Carlisle Apr 28 '12 at 21:06

2 Answers 2

You can use feature rich tabu package that has a longtabu option which combines tabularx and longtable. Here is a MWE:

\documentclass{article}
\usepackage{tabu}
\usepackage{longtable} %tabu needs this to be loaded.
\usepackage{lipsum} % provides dummy text.
\usepackage[charter]{mathdesign} % just for some good font...(personal taste)
\usepackage[margin=1in,showframe]{geometry}% to adjust page margins etc and to show frame.
%==================================================================
\begin{document}
% ----------------------------------------------------------------------%
\begin{longtabu} to \textwidth {|X[1 , p ] |X[1 , l ] | X[1 , c ]| X[1 , r ]|}\firsthline\hline
% -----------------These are headings----------------------------------%
Head - 1 (paragraph mode) &Head - 2 (left aligned) & Head-3 (centered) & Head -4 (right aligned) \\ \hline
%
\endfirsthead
%
\multicolumn{4}{c}%
{{\bfseries  Continued from previous page}} \\
\hline
%
Head - 1 (paragraph mode) &Head - 2 (left aligned) & Head-3 (centered) & Head -4 (right aligned)  \\ \hline\hline
\endhead
%
\hline \multicolumn{4}{|r|}{{Continued on next page}} \\ \hline
\endfoot
%
\hline
\multicolumn{4}{|r|}{{Concluded}} \\ \hline
\endlastfoot
%-----------Headings end---------------------------------
%--------------------------table body starts-------------------
\lipsum[4]& \lipsum[4]& \lipsum[4] & \lipsum[4] \\\hline
\lipsum[4]& \lipsum[4]& \lipsum[4] & \lipsum[4]\\hline
\lipsum[4] &\lipsum[4]& \lipsum[4] & \lipsum[4]\\\lasthline
%--------------------------table body ends-------------------
\end{longtabu}
%===============================================================
\end{document} 

enter image description here

share|improve this answer

Have a look at the ltxtable package. From the package description:

Ltxtable provides the functionality of longtable and tabularx together inside a longtable environment. The code of each such environment (with X specifiers in its column layout) should be in a separate file, which is then included in your document by a command \LTXtable{<width>}{<file name>}

share|improve this answer

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.