1

I have a very long table that I use to align some text, therefore I don't need it to be (specifically) a table (please consider that in the answers).

I am using supertabular for the table to span several pages. The problem is that I have some cells that contain some long text (enough to be split into two lines), which increases the width of the table and it overflows the margins.

I have seen in similar questions that I could use tabularx with the X option for the column with so much text, this would split the column into several lines, but the problem is that tabularx cannot span several pages.

I would prefer not to use p{width} for the column, because it's going to be impossible (or extremely hard) to set the proper width for this column to make the best use of the text width in total, the width of the other columns may change in different pages (that's not a problem, that's good) and I would prefer to use the full width as much as possible (the table is huge).

Please remember I could use something rather than a table, although I don't know about anything that would be useful in this context.

Related questions:

9
  • 1
    Have you considered using the ltxtable package, which lets you combine the features of the tabularx and longtable environments. To learn more about ltxtable, simply search for this string in the postings of this site.
    – Mico
    Jan 27, 2014 at 19:10
  • @Mico it ignores my width settings and it seems to extend beyond the margin further than before. I tried with 0.5\textwidth and 0.5\linewidth among other options.
    – Trylks
    Jan 29, 2014 at 11:24
  • 2
    Please consider posting an MWE (minimum working example) of what you've tried so far. Without some actual code, I'm afraid it's going to be rather difficult to diagnose, let alone cure, the problem.
    – Mico
    Jan 29, 2014 at 11:29
  • @Mico it took some time, but I was able to create the MWE and found that I was using l where I should use X, that's why the lines were not splitting properly. Now I would like the table not to page-break between some specific rows but I think I'm gonna let it be. Thank you for your help :)
    – Trylks
    Feb 13, 2014 at 17:33
  • 1
    To prevent a page break after a specific row, use \\* instead of \\ .
    – Mico
    Feb 13, 2014 at 17:41

1 Answer 1

2

I suggest you consider loading the longtable, tabularx and ltxtable packages. The latter package serves to combine the capabilities of the longtable environment -- which can span several pages -- and of the tabularx environment, which makes it straightforward to specify tables that take up a certain width, such as the entire width of the textblock.

  • Be sure to load all three of these packages in the preamble of your main tex document.

  • In a separate file named, say, long.tex, create a longtable environment that uses one or more columns of type X (provided by the tabularx package). Text in the columns of type X will break across lines automatically.

  • Back in the main file, in the location where the long&wide table needs to start, provide the instruction

    \LTXtable{<width>}{long.tex}
    

    where <width> should likely be set as \textwidth. Be sure to compile several times so that the results of all internal calculations have a chance to be fully propagated.

  • Finally, if you need to prevent page breaks from occurring at certain rows, use the instruction \\* instead of the "ordinary" \\ directive at the end of the rows in question.

1
  • thanks for that (I thought you'd just write "use ltxtable" :-) May 29, 2014 at 22:17

You must log in to answer this question.

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