Sometimes we need to render tables which do not fit in a page since the tables are too wide. Now, since longtable renders tables which do not fit in a page lengthwise, how can we build a package which do not fit in a page width-wise?

The capabilities I am looking for in the proposed package are:

Feature 1

Automatic splitting of columns when the table width exceeds page width.



In the above code, since all the columns will not fit in the page width, it will split the table at an appropriate column automatically.

Feature 2

Repeat columns at left.


When the table has been split at appropriate column, there should be an optional provision to repeat the leftmost two columns.

Feature 3

Provision not to break columns when a header cell is formed using multiple columns.

  \multicolumn{2}{c}{Particulars}&\multicolumn{5}{c}{Subject 1}&\multicolumn{10}{c}{Subject 2}&\multicolumn{7}{c}{Subject 3}&\multicolumn{8}{c}{Subject 4}&\multicolumn{10}{c}{Subject 5}\\

The table will not be split at the mid point any multi-column Subject n header.

These are the primary features I can think of. May be more can be added once that package is born.

Surprisingly, all the major spreadsheets have all or majority of the above features.

(Why am I not writing the above package? Simple, that is above my knowledge grade. And that is why I am asking this question.)

(Perhaps you may want to take a look at this related question. This issue has remained unsolved at my end for more than a couple of years.)

  • 4
    The obvious answer to such questions is that nobody has found the reward worth the effort to write such a package. Either because the effort would be too high due to insufficient TeX-fu, or because the reward is too low due to them not needing such a package, or maybe they work around the problem if it arises. I don't think you are going to get any better answers than that. Sorry. Commented Jan 19, 2018 at 9:47
  • @HaraldHanche-Olsen Can you suggest an automatic work-around when there are more than hundred tables to process?
    – Masroor
    Commented Jan 19, 2018 at 9:51
  • 3
    Not really. But if I had this problem, I'd probably steer away from a TeX only approach. For example, is using luatex is an option, I would prefer to have the table contents in a lua array, and then write lua code to try different splits of the table until one is found that works. But I am a rank beginner in lua, so this would take me days to implement. Sorry, I don't have time for such endeavours. Commented Jan 19, 2018 at 9:57
  • @HaraldHanche-Olsen Thanks, because you introduced my to LuaTeX. I was not aware of it. Just a quick question, can lua code be embedded to LaTeX code?
    – Masroor
    Commented Jan 19, 2018 at 10:12
  • 1
    tex.stackexchange.com/questions/108494/… Commented Jan 19, 2018 at 14:47

1 Answer 1


Use ConTeXt with Linetable. Documentation for that is basically non-existent but you can read the source (it's very readable).


  \NC[nx=2] Particulars \NC[nx=5] Subject 1 \NC[nx=10] Subject 2 \NC[nx=7] Subject 3 \NC[nx=8] Subject 4 \NC[nx=10] Subject 5 \NC\NR
  \NC Name \NC ID    \NC H1 \NC H2 \NC H3 \NC H4 \NC H5 \NC H6 \NC H7 \NC H8 \NC H9 \NC H10 \NC H11 \NC H12 \NC H13 \NC H14 \NC H15 \NC H16 \NC H17 \NC H18 \NC H19 \NC H20 \NC H21 \NC H22 \NC H23 \NC H24 \NC H25 \NC H26 \NC H27 \NC H28 \NC H29 \NC H30 \NC H31 \NC H32 \NC H33 \NC H34 \NC H35 \NC H36 \NC H37 \NC H38 \NC H39 \NC H40 \NC\NR
  \NC A    \NC 00001 \NC 1  \NC 2  \NC 3  \NC 4  \NC 5  \NC 6  \NC 7  \NC 8  \NC 9  \NC 10  \NC 11  \NC 12  \NC 13  \NC 14  \NC 15  \NC 16  \NC 17  \NC 18  \NC 19  \NC 20  \NC 21  \NC 22  \NC 23  \NC 24  \NC 25  \NC 26  \NC 27  \NC 28  \NC 29  \NC 30  \NC 31  \NC 32  \NC 33  \NC 34  \NC 35  \NC 36  \NC 37  \NC 38  \NC 39  \NC 40 \NC\NR


enter image description here

  • 1
    while this is certainly a reasonable approach, it would be helpful to mention that context is likely even more of a paradigm shift than lualatex. Commented Jan 19, 2018 at 13:03

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