3

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.

\begin{tabular}{*{40}{c}}
 H1&H2&H3&H4&H5&H6&H7&H8&H9&H10&H11&H12&H13&H14&H15&H16&H17&H18&H19&H20&H21&H22&H23&H24&H25&H26&H27&H28&H29&H30&H31&H32&H33&H34&H35&H36&H37&H38&H39&H40\\


  1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26&27&28&29&30&31&32&33&34&35&36&37&38&39&40
    \end{tabular}

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.

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

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.

\begin{tabular}{ll*{40}{c}}
  \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}\\
  Name&ID&H1&H2&H3&H4&H5&H6&H7&H8&H9&H10&H11&H12&H13&H14&H15&H16&H17&H18&H19&H20&H21&H22&H23&H24&H25&H26&H27&H28&H29&H30&H31&H32&H33&H34&H35&H36&H37&H38&H39&H40\\
  A&00001&1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26&27&28&29&30&31&32&33&34&35&36&37&38&39&40
\end{tabular}

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.)

8
  • 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. 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
    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. 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
    Jan 19, 2018 at 10:12
  • 1

1 Answer 1

3

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

\starttext

\startlinetable
  \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
\stoplinetable

\stoptext

enter image description here

1
  • 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. Jan 19, 2018 at 13:03

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