1

I am trying to typeset a long and wide table using this code. Whatever I do the table is not page-breaked. Instead it vertically overflows the space allocated for it. As you can see the last rows of table are printed on page footer. If the typesetting functioned correctly these rows should go to the next page. To be more specific they should go in our example to page + 5 after all columns for previous rows are printed. How can I accomplish the desired behaviour ?

\documentclass[twoside]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{caption}
\newcounter{tablepage}
\makeatletter

% #1 no of pages
% #2 caption
% #3 table 
% table usesnormal tabular except
% Replace & by \thbreak after column(s) you want repeated.
% replace & by \tbreak at points you want page to break.
% must be a \tbreak before final \\
% any nested tabulars must be inside {} to hide the &
% \multicolumn is allowed but can not span a break.
% might want to replace \cleardoublepage by a cmmand to get onto left pf speread
% the tabular preamble needs as many columns (including heading columns) as the 
% page with the most columns.
\long\def\widesplit#1#2#3{%
\def\row{\rowz\c@tablepage}%
\cleardoublepage
\setcounter{tablepage}{0}%
\loop
\refstepcounter{tablepage}%
\noindent\begin{minipage}{\columnwidth}\centering
 \ifnum\c@tablepage=\@ne
    \captionof{table}{#2}%
 \else
\captionof*{table}{#2 (page \thetablepage\ of #1)}%
 \fi
#3\end{minipage}%
\clearpage
\ifnum#1>\c@tablepage
\repeat}

%\input{PreambleCsv}

\begin{document}

\def\rowa#1\thbreak#2\tbreak#3\\{#1&#2\\}

\def\rowz#1{%
    \ifnum#1=\@ne
    \expandafter\rowa
    \else
    \expandafter\rowq\expandafter{\the\numexpr#1-1\expandafter\relax\expandafter}%
    \fi}

\def\rowq#1#2\thbreak#3\tbreak{\rowz{#1}#2\thbreak}

\widesplit{5}{some boring numbers}{%
    \begin{tabular}{>\bfseries{l}rrrrr}
        \row
        Sample \thbreak   Sample 1 &   Sample 2 &   Sample 3 &   Sample 4 &   Sample 5 \tbreak   Sample 6 &   Sample 7 &   Sample 8 &   Sample 9 &  Sample 10 \tbreak  Sample 11 &  Sample 12 &  Sample 13 &  Sample 14 &  Sample 15 \tbreak  Sample 16 &  Sample 17 &  Sample 18 &  Sample 19 &  Sample 20 \tbreak  Sample 21 &  Sample 22 &  Sample 23 &  Sample 24 \tbreak\\[2ex]
        \row
        \rlap{Major element abundances (wt\%)} \thbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            \tbreak\\
        \row
        SiO2 \thbreak         25 &         81 &         36 &         75 &         23 \tbreak         21 &         65 &         84 &          1 &         59 \tbreak         38 &         16 &          3 &         56 &         29 \tbreak         34 &          3 &         59 &         55 &         17 \tbreak          2 &         81 &         59 &         43 \tbreak\\
        \row
        TiO2 \thbreak         48 &         96 &          0 &         90 &         61 \tbreak         72 &         83 &         16 &         10 &          1 \tbreak         40 &         83 &         35 &         31 &         76 \tbreak         31 &         57 &          8 &         83 &        100 \tbreak         14 &         12 &         48 &         69 \tbreak\\
        \row
        Al2O3 \thbreak          7 &         14 &         99 &         53 &         89 \tbreak         65 &         88 &         17 &         76 &         81 \tbreak         43 &         87 &         15 &         71 &         17 \tbreak         85 &         59 &        100 &         96 &         85 \tbreak         74 &         50 &         59 &         36 \tbreak\\
        \row
        Fe2O3 \thbreak         32 &         34 &         23 &         86 &         50 \tbreak         58 &          8 &         29 &         88 &         27 \tbreak         49 &         16 &         19 &         89 &         45 \tbreak         88 &         79 &         42 &         42 &         29 \tbreak         10 &         60 &         87 &         97 \tbreak\\
        \row
        FeOt \thbreak         35 &         42 &         83 &          0 &         55 \tbreak         51 &         35 &         11 &         43 &         44 \tbreak         69 &         30 &         49 &         55 &         56 \tbreak          4 &         74 &         72 &         98 &         94 \tbreak         14 &         35 &         59 &         34 \tbreak\\
        \row
        MnO \thbreak         64 &         48 &         52 &         65 &         61 \tbreak         16 &         73 &         56 &         73 &         54 \tbreak         75 &          7 &         18 &         84 &         52 \tbreak         38 &         46 &         91 &         59 &         90 \tbreak         31 &         84 &         54 &         32 \tbreak\\
        \row
        MgO \thbreak         48 &         97 &         83 &         47 &         43 \tbreak         41 &         37 &         71 &         92 &         57 \tbreak         76 &         36 &          8 &         37 &         94 \tbreak          6 &         50 &         57 &         80 &         63 \tbreak         25 &         18 &         85 &         16 \tbreak\\
        \row
        CaO \thbreak         56 &         11 &         68 &         49 &          6 \tbreak         20 &         31 &         74 &         72 &         24 \tbreak         39 &         38 &         68 &         69 &         73 \tbreak         23 &         40 &         32 &         63 &         93 \tbreak         28 &         56 &         12 &         18 \tbreak\\
        \row
        Na2O \thbreak         73 &         18 &          0 &         62 &         98 \tbreak         61 &         59 &         42 &         97 &         47 \tbreak         74 &         31 &         40 &          3 &         75 \tbreak          2 &         52 &         96 &         67 &         44 \tbreak         84 &          9 &         35 &         51 \tbreak\\
        \row
        K2O \thbreak         69 &          0 &         52 &         73 &         23 \tbreak         11 &         12 &         70 &         86 &         46 \tbreak         29 &         84 &         77 &         47 &         25 \tbreak         43 &         97 &         48 &         30 &         94 \tbreak         83 &         93 &         23 &         25 \tbreak\\
        \row
        P2O5 \thbreak         92 &         80 &         59 &          6 &         90 \tbreak         99 &         54 &         64 &         96 &         84 \tbreak         58 &         18 &         37 &          7 &         55 \tbreak         89 &         34 &         53 &         59 &         56 \tbreak         38 &         23 &         63 &         89 \tbreak\\
        \row
        LOI§ \thbreak         51 &         65 &         64 &          2 &         67 \tbreak         51 &         58 &         55 &         60 &         48 \tbreak         64 &         54 &         56 &         46 &         78 \tbreak         70 &         38 &         44 &         45 &         37 \tbreak         66 &          7 &         34 &         76 \tbreak\\
        \row
        Mg\# \thbreak         20 &         27 &         34 &         40 &         66 \tbreak          3 &          7 &         42 &         19 &         85 \tbreak         35 &         24 &         31 &         40 &         14 \tbreak         39 &         31 &        100 &          0 &         41 \tbreak         19 &         14 &         75 &          5 \tbreak\\
        \row
        CIA \thbreak         24 &         57 &          1 &         80 &         86 \tbreak         72 &         38 &         11 &         51 &         23 \tbreak         49 &         94 &         43 &         65 &         15 \tbreak          5 &         41 &         21 &         32 &         83 \tbreak         22 &         16 &         63 &         51 \tbreak\\[2ex]
        \row
        \rlap{Trace element abundances (ppm)} \thbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            &            \tbreak            &            &            &            \tbreak\\
        \row
        V \thbreak         91 &        421 &        256 &        480 &        669 \tbreak        888 &        403 &        456 &        661 &         77 \tbreak        997 &        729 &        647 &         77 &         69 \tbreak        163 &         52 &        589 &        772 &        267 \tbreak        110 &        998 &        547 &        789 \tbreak\\
        \row
        Cr \thbreak        635 &        712 &        208 &        938 &        754 \tbreak        600 &         91 &        531 &        211 &        798 \tbreak        880 &        240 &        197 &        671 &        298 \tbreak        921 &        538 &        577 &         49 &        195 \tbreak        596 &        744 &        719 &        910 \tbreak\\
        \row
        Co \thbreak        288 &        182 &        672 &        825 &        197 \tbreak        466 &        204 &        803 &        943 &        321 \tbreak        444 &        134 &        471 &         22 &        191 \tbreak        188 &        457 &        481 &        288 &        971 \tbreak        475 &        906 &        261 &        243 \tbreak\\
        \row
        Ni \thbreak        492 &        234 &         46 &         62 &        213 \tbreak        531 &        808 &        557 &        599 &        356 \tbreak        681 &        487 &        929 &         36 &        729 \tbreak         84 &        962 &        918 &        260 &        688 \tbreak        373 &        363 &        679 &         51 \tbreak\\
        \row
        Cu \thbreak        675 &        494 &        754 &        743 &        119 \tbreak        404 &        142 &        402 &        120 &        643 \tbreak        576 &        135 &        870 &        205 &        639 \tbreak        775 &        549 &         82 &        933 &        222 \tbreak         55 &        567 &        672 &        354 \tbreak\\
        \row
        Zn \thbreak        440 &        656 &        667 &        193 &        305 \tbreak        758 &        814 &        660 &        811 &        519 \tbreak        885 &        488 &        223 &        182 &        120 \tbreak        448 &         58 &        830 &        173 &        473 \tbreak        847 &        809 &         22 &        456 \tbreak\\
        \row
        Ga \thbreak        782 &        639 &        282 &        906 &        595 \tbreak         39 &        901 &         73 &        825 &        330 \tbreak        937 &        860 &         48 &        920 &        968 \tbreak        150 &        967 &        838 &        819 &        997 \tbreak        430 &        635 &        959 &        672 \tbreak\\
        \row
        Rb \thbreak        422 &        930 &        404 &        581 &        916 \tbreak        747 &        970 &         87 &        343 &        784 \tbreak        843 &        339 &        919 &        398 &        827 \tbreak        265 &        216 &        382 &        772 &         17 \tbreak        770 &        745 &        543 &        224 \tbreak\\
        \row
        Sr \thbreak        468 &         17 &        860 &        996 &        938 \tbreak        416 &        594 &        506 &        226 &        572 \tbreak        507 &        432 &         54 &        484 &        517 \tbreak        629 &        793 &        721 &        743 &        481 \tbreak        306 &        948 &        387 &        239 \tbreak\\
        \row
        Pb \thbreak        429 &        280 &         83 &        495 &        980 \tbreak        715 &        225 &        540 &         58 &        513 \tbreak        653 &        149 &        893 &        918 &        553 \tbreak        879 &        136 &        266 &        900 &        811 \tbreak        942 &        706 &        344 &        528 \tbreak\\
        \row
        U \thbreak        669 &        507 &        455 &        714 &         83 \tbreak         39 &         83 &        175 &        466 &        940 \tbreak        794 &        232 &        600 &        327 &        590 \tbreak        723 &        597 &        759 &        377 &        214 \tbreak        372 &        627 &        746 &        102 \tbreak\\
        \row
        Cs \thbreak        408 &        615 &        657 &        539 &        612 \tbreak        907 &        615 &        820 &        650 &        133 \tbreak        870 &        605 &        691 &        190 &        741 \tbreak        245 &        370 &        486 &        269 &        475 \tbreak        258 &        320 &        909 &        204 \tbreak\\
        \row
        Y \thbreak        291 &        830 &        767 &        872 &        522 \tbreak        639 &        159 &        548 &        236 &        718 \tbreak        701 &        762 &        965 &        323 &        770 \tbreak        688 &         22 &         11 &        930 &        329 \tbreak        657 &        778 &        432 &        581 \tbreak\\
        \row
        Zr \thbreak        902 &        131 &        233 &        211 &        399 \tbreak        315 &        730 &        852 &         76 &        973 \tbreak        350 &        887 &        201 &        895 &        691 \tbreak        885 &        223 &        830 &        690 &        477 \tbreak        424 &        756 &        659 &        166 \tbreak\\
        \row
        Nb \thbreak        594 &        969 &        833 &        663 &        243 \tbreak        154 &        197 &        104 &        317 &        834 \tbreak        901 &        891 &        997 &        934 &        328 \tbreak        261 &        982 &        581 &        781 &        933 \tbreak        625 &        783 &        711 &        354 \tbreak\\
        \row
        Ba \thbreak        790 &        957 &        606 &        730 &        754 \tbreak        928 &        646 &          0 &        389 &         71 \tbreak        616 &        434 &        107 &        126 &        692 \tbreak        118 &        983 &         24 &        281 &        808 \tbreak        743 &        381 &        139 &        856 \tbreak\\
        \row
        La \thbreak        624 &        859 &        233 &        176 &        540 \tbreak        138 &        188 &        475 &        478 &        203 \tbreak        614 &         53 &        435 &        694 &         66 \tbreak        860 &        628 &        271 &        338 &        799 \tbreak        924 &        877 &        777 &        721 \tbreak\\
        \row
        Ce \thbreak        826 &        471 &        327 &        809 &        496 \tbreak        180 &        378 &        155 &         61 &        345 \tbreak        736 &        341 &        201 &        634 &        393 \tbreak        932 &        498 &        334 &         29 &        319 \tbreak        254 &         79 &        691 &         52 \tbreak\\
        \row
        Pr \thbreak        476 &        447 &        951 &        786 &        450 \tbreak        717 &        248 &        790 &        561 &        259 \tbreak        748 &        104 &        881 &        804 &        385 \tbreak        676 &        435 &        815 &        634 &        234 \tbreak        809 &        105 &        471 &        529 \tbreak\\
        \row
        Nd \thbreak        758 &        523 &        672 &        159 &        405 \tbreak        597 &        657 &        307 &         28 &         28 \tbreak         30 &        273 &         74 &        189 &        403 \tbreak        326 &         19 &        735 &        121 &        992 \tbreak         26 &        723 &        243 &        927 \tbreak\\
        \row
        Sm \thbreak        307 &        422 &        764 &        933 &        197 \tbreak        180 &        956 &        276 &        347 &        492 \tbreak        534 &        760 &        904 &        247 &          0 \tbreak        518 &        593 &        714 &        223 &        619 \tbreak        634 &         39 &        265 &        445 \tbreak\\
        \row
        Eu \thbreak        463 &        194 &        627 &        954 &         32 \tbreak        940 &        824 &        229 &         58 &        684 \tbreak        780 &        761 &        348 &        464 &         39 \tbreak        577 &        432 &        920 &        425 &        799 \tbreak          3 &        207 &        208 &        398 \tbreak\\
        \row
        Gd \thbreak        863 &        274 &        512 &        718 &        770 \tbreak        900 &        221 &        674 &        342 &        553 \tbreak        522 &        945 &        880 &         23 &        605 \tbreak        544 &        214 &        987 &        348 &        445 \tbreak        763 &        893 &        607 &        162 \tbreak\\
        \row
        Tb \thbreak        162 &        547 &         73 &        216 &        420 \tbreak        242 &        451 &        196 &        987 &        649 \tbreak        184 &        256 &        218 &         86 &        962 \tbreak        203 &         37 &        494 &        286 &        663 \tbreak        612 &        549 &        537 &        594 \tbreak\\
        \row
        Dy \thbreak        265 &         21 &        889 &        312 &        756 \tbreak         94 &        976 &        188 &        147 &        839 \tbreak        527 &        442 &        849 &        948 &        570 \tbreak        553 &        902 &        290 &         81 &        758 \tbreak        759 &        598 &        344 &        104 \tbreak\\
        \row
        Ho \thbreak        218 &        503 &        999 &        465 &        573 \tbreak        586 &        122 &        991 &        241 &        710 \tbreak        182 &         87 &        965 &        746 &         90 \tbreak        638 &         35 &        122 &        389 &        892 \tbreak        815 &        617 &        116 &        895 \tbreak\\
        \row
        Er \thbreak        571 &        932 &        738 &        653 &        986 \tbreak        430 &        992 &        432 &        823 &        542 \tbreak        444 &        702 &        524 &         58 &        248 \tbreak        914 &        697 &        420 &        913 &        754 \tbreak        596 &        429 &        995 &        927 \tbreak\\
        \row
        Tm \thbreak        551 &         72 &        654 &        819 &        593 \tbreak          7 &        110 &        707 &        535 &         74 \tbreak        142 &        150 &        610 &        564 &        859 \tbreak        451 &        832 &        822 &        938 &        877 \tbreak        954 &        430 &         41 &        657 \tbreak\\
        \row
        Yb \thbreak        815 &        643 &        650 &        217 &        962 \tbreak        612 &        926 &        524 &        559 &        500 \tbreak        822 &        630 &        901 &        525 &        407 \tbreak        563 &        575 &        161 &        505 &        166 \tbreak        207 &        680 &        418 &        478 \tbreak\\
        \row
        Lu \thbreak        106 &        597 &        551 &        650 &        391 \tbreak        850 &        589 &        649 &          6 &        277 \tbreak        129 &        566 &        109 &        922 &        767 \tbreak        173 &        525 &        250 &        449 &        662 \tbreak        221 &        831 &        969 &        479 \tbreak\\
        \row
        Hf \thbreak        100 &        833 &        566 &        331 &         36 \tbreak        589 &         33 &        785 &        862 &        447 \tbreak        469 &        284 &        329 &        116 &        608 \tbreak        256 &        665 &         41 &         74 &        527 \tbreak        479 &        300 &        800 &         51 \tbreak\\
        \row
        Ta \thbreak        337 &        757 &        903 &        411 &        745 \tbreak        638 &        243 &        584 &        336 &        477 \tbreak        994 &        307 &        349 &        981 &        572 \tbreak        364 &        822 &        609 &        198 &        478 \tbreak        922 &        854 &        819 &        130 \tbreak\\
        \row
        Th \thbreak       1000 &        520 &        222 &        998 &        774 \tbreak         88 &        843 &        259 &        424 &        845 \tbreak        884 &        739 &        666 &        673 &        531 \tbreak        934 &        322 &        682 &        754 &        944 \tbreak        153 &        779 &         20 &        890 \tbreak\\        
    \end{tabular}        
}

\end{document}

enter image description here

  • I don't know where you found \widesplit, but I would try longtable or supertabular packages instead – user31729 Mar 21 '15 at 15:46
  • Do longtable and supertabular support both horizontal and vertical splitting of big table ? Horizontal because of large number of columns and vertical because of large number of rows. – truthseeker Mar 21 '15 at 15:59
  • 1
    it doesn't really make sense to break for wide and long tables at the same time, even if it worked how would the reader know which fragment was which? You need to organise your data into columns that fit the page, then use page breaking on rows, or organise it to have rows that fit the page then do page breaking on columns. – David Carlisle Mar 21 '15 at 15:59
  • A tip for you: or try the tabu package and its longtabu environment. – Malipivo Mar 21 '15 at 16:06
  • It would be good looking and readable to print wide table on adjacent pages in two-sided document (without any sort of rotation). Unfortunately the table is too long to print on one page. In MWE the table is too wide (5 pages) but in my practical case (not presented here) the columns can be printed on exactly two pages (so table width is two pages). No sort of ambiguity. – truthseeker Mar 21 '15 at 16:07
3

If you reduce the font size, and steal some margin, the data fits on a page (although your real data may be larger...

enter image description here

\documentclass[twoside]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\usepackage{array}
\usepackage{caption}
\newcounter{tablepage}
\makeatletter



\begin{document}
\setlength\LTleft{0pt minus 100pt}
\setlength\LTright{0pt minus 100pt}
\setlength\tabcolsep{2pt}
\footnotesize
    \begin{longtable}{>\bfseries{l}*{24}{r}}

        Sample &\textbf{1} &\textbf{2} &\textbf{3} &\textbf{4} &\textbf{5} &\textbf{6} &\textbf{7} &\textbf{8} &\textbf{9} &\textbf{10} &\textbf{11} &\textbf{12} &\textbf{13} &\textbf{14} &\textbf{15} &\textbf{16} &\textbf{17} &\textbf{18} &\textbf{19} &\textbf{20} &\textbf{21} &\textbf{22} &\textbf{23} &\textbf{24} \\[2ex]

        \rlap{Major element abundances (wt\%)} \\

        SiO2 &         25 &         81 &         36 &         75 &         23 &         21 &         65 &         84 &          1 &         59 &         38 &         16 &          3 &         56 &         29 &         34 &          3 &         59 &         55 &         17 &          2 &         81 &         59 &         43 \\

        TiO2 &         48 &         96 &          0 &         90 &         61 &         72 &         83 &         16 &         10 &          1 &         40 &         83 &         35 &         31 &         76 &         31 &         57 &          8 &         83 &        100 &         14 &         12 &         48 &         69 \\

        Al2O3 &          7 &         14 &         99 &         53 &         89 &         65 &         88 &         17 &         76 &         81 &         43 &         87 &         15 &         71 &         17 &         85 &         59 &        100 &         96 &         85 &         74 &         50 &         59 &         36 \\

        Fe2O3 &         32 &         34 &         23 &         86 &         50 &         58 &          8 &         29 &         88 &         27 &         49 &         16 &         19 &         89 &         45 &         88 &         79 &         42 &         42 &         29 &         10 &         60 &         87 &         97 \\

        FeOt &         35 &         42 &         83 &          0 &         55 &         51 &         35 &         11 &         43 &         44 &         69 &         30 &         49 &         55 &         56 &          4 &         74 &         72 &         98 &         94 &         14 &         35 &         59 &         34 \\

        MnO &         64 &         48 &         52 &         65 &         61 &         16 &         73 &         56 &         73 &         54 &         75 &          7 &         18 &         84 &         52 &         38 &         46 &         91 &         59 &         90 &         31 &         84 &         54 &         32 \\

        MgO &         48 &         97 &         83 &         47 &         43 &         41 &         37 &         71 &         92 &         57 &         76 &         36 &          8 &         37 &         94 &          6 &         50 &         57 &         80 &         63 &         25 &         18 &         85 &         16 \\

        CaO &         56 &         11 &         68 &         49 &          6 &         20 &         31 &         74 &         72 &         24 &         39 &         38 &         68 &         69 &         73 &         23 &         40 &         32 &         63 &         93 &         28 &         56 &         12 &         18 \\

        Na2O &         73 &         18 &          0 &         62 &         98 &         61 &         59 &         42 &         97 &         47 &         74 &         31 &         40 &          3 &         75 &          2 &         52 &         96 &         67 &         44 &         84 &          9 &         35 &         51 \\

        K2O &         69 &          0 &         52 &         73 &         23 &         11 &         12 &         70 &         86 &         46 &         29 &         84 &         77 &         47 &         25 &         43 &         97 &         48 &         30 &         94 &         83 &         93 &         23 &         25 \\

        P2O5 &         92 &         80 &         59 &          6 &         90 &         99 &         54 &         64 &         96 &         84 &         58 &         18 &         37 &          7 &         55 &         89 &         34 &         53 &         59 &         56 &         38 &         23 &         63 &         89 \\

        LOI§ &         51 &         65 &         64 &          2 &         67 &         51 &         58 &         55 &         60 &         48 &         64 &         54 &         56 &         46 &         78 &         70 &         38 &         44 &         45 &         37 &         66 &          7 &         34 &         76 \\

        Mg\# &         20 &         27 &         34 &         40 &         66 &          3 &          7 &         42 &         19 &         85 &         35 &         24 &         31 &         40 &         14 &         39 &         31 &        100 &          0 &         41 &         19 &         14 &         75 &          5 \\

        CIA &         24 &         57 &          1 &         80 &         86 &         72 &         38 &         11 &         51 &         23 &         49 &         94 &         43 &         65 &         15 &          5 &         41 &         21 &         32 &         83 &         22 &         16 &         63 &         51 \\[2ex]

        \rlap{Trace element abundances (ppm)} &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            &            \\

        V &         91 &        421 &        256 &        480 &        669 &        888 &        403 &        456 &        661 &         77 &        997 &        729 &        647 &         77 &         69 &        163 &         52 &        589 &        772 &        267 &        110 &        998 &        547 &        789 \\

        Cr &        635 &        712 &        208 &        938 &        754 &        600 &         91 &        531 &        211 &        798 &        880 &        240 &        197 &        671 &        298 &        921 &        538 &        577 &         49 &        195 &        596 &        744 &        719 &        910 \\

        Co &        288 &        182 &        672 &        825 &        197 &        466 &        204 &        803 &        943 &        321 &        444 &        134 &        471 &         22 &        191 &        188 &        457 &        481 &        288 &        971 &        475 &        906 &        261 &        243 \\

        Ni &        492 &        234 &         46 &         62 &        213 &        531 &        808 &        557 &        599 &        356 &        681 &        487 &        929 &         36 &        729 &         84 &        962 &        918 &        260 &        688 &        373 &        363 &        679 &         51 \\

        Cu &        675 &        494 &        754 &        743 &        119 &        404 &        142 &        402 &        120 &        643 &        576 &        135 &        870 &        205 &        639 &        775 &        549 &         82 &        933 &        222 &         55 &        567 &        672 &        354 \\

        Zn &        440 &        656 &        667 &        193 &        305 &        758 &        814 &        660 &        811 &        519 &        885 &        488 &        223 &        182 &        120 &        448 &         58 &        830 &        173 &        473 &        847 &        809 &         22 &        456 \\

        Ga &        782 &        639 &        282 &        906 &        595 &         39 &        901 &         73 &        825 &        330 &        937 &        860 &         48 &        920 &        968 &        150 &        967 &        838 &        819 &        997 &        430 &        635 &        959 &        672 \\

        Rb &        422 &        930 &        404 &        581 &        916 &        747 &        970 &         87 &        343 &        784 &        843 &        339 &        919 &        398 &        827 &        265 &        216 &        382 &        772 &         17 &        770 &        745 &        543 &        224 \\

        Sr &        468 &         17 &        860 &        996 &        938 &        416 &        594 &        506 &        226 &        572 &        507 &        432 &         54 &        484 &        517 &        629 &        793 &        721 &        743 &        481 &        306 &        948 &        387 &        239 \\

        Pb &        429 &        280 &         83 &        495 &        980 &        715 &        225 &        540 &         58 &        513 &        653 &        149 &        893 &        918 &        553 &        879 &        136 &        266 &        900 &        811 &        942 &        706 &        344 &        528 \\

        U &        669 &        507 &        455 &        714 &         83 &         39 &         83 &        175 &        466 &        940 &        794 &        232 &        600 &        327 &        590 &        723 &        597 &        759 &        377 &        214 &        372 &        627 &        746 &        102 \\

        Cs &        408 &        615 &        657 &        539 &        612 &        907 &        615 &        820 &        650 &        133 &        870 &        605 &        691 &        190 &        741 &        245 &        370 &        486 &        269 &        475 &        258 &        320 &        909 &        204 \\

        Y &        291 &        830 &        767 &        872 &        522 &        639 &        159 &        548 &        236 &        718 &        701 &        762 &        965 &        323 &        770 &        688 &         22 &         11 &        930 &        329 &        657 &        778 &        432 &        581 \\

        Zr &        902 &        131 &        233 &        211 &        399 &        315 &        730 &        852 &         76 &        973 &        350 &        887 &        201 &        895 &        691 &        885 &        223 &        830 &        690 &        477 &        424 &        756 &        659 &        166 \\

        Nb &        594 &        969 &        833 &        663 &        243 &        154 &        197 &        104 &        317 &        834 &        901 &        891 &        997 &        934 &        328 &        261 &        982 &        581 &        781 &        933 &        625 &        783 &        711 &        354 \\

        Ba &        790 &        957 &        606 &        730 &        754 &        928 &        646 &          0 &        389 &         71 &        616 &        434 &        107 &        126 &        692 &        118 &        983 &         24 &        281 &        808 &        743 &        381 &        139 &        856 \\

        La &        624 &        859 &        233 &        176 &        540 &        138 &        188 &        475 &        478 &        203 &        614 &         53 &        435 &        694 &         66 &        860 &        628 &        271 &        338 &        799 &        924 &        877 &        777 &        721 \\

        Ce &        826 &        471 &        327 &        809 &        496 &        180 &        378 &        155 &         61 &        345 &        736 &        341 &        201 &        634 &        393 &        932 &        498 &        334 &         29 &        319 &        254 &         79 &        691 &         52 \\

        Pr &        476 &        447 &        951 &        786 &        450 &        717 &        248 &        790 &        561 &        259 &        748 &        104 &        881 &        804 &        385 &        676 &        435 &        815 &        634 &        234 &        809 &        105 &        471 &        529 \\

        Nd &        758 &        523 &        672 &        159 &        405 &        597 &        657 &        307 &         28 &         28 &         30 &        273 &         74 &        189 &        403 &        326 &         19 &        735 &        121 &        992 &         26 &        723 &        243 &        927 \\

        Sm &        307 &        422 &        764 &        933 &        197 &        180 &        956 &        276 &        347 &        492 &        534 &        760 &        904 &        247 &          0 &        518 &        593 &        714 &        223 &        619 &        634 &         39 &        265 &        445 \\

        Eu &        463 &        194 &        627 &        954 &         32 &        940 &        824 &        229 &         58 &        684 &        780 &        761 &        348 &        464 &         39 &        577 &        432 &        920 &        425 &        799 &          3 &        207 &        208 &        398 \\

        Gd &        863 &        274 &        512 &        718 &        770 &        900 &        221 &        674 &        342 &        553 &        522 &        945 &        880 &         23 &        605 &        544 &        214 &        987 &        348 &        445 &        763 &        893 &        607 &        162 \\

        Tb &        162 &        547 &         73 &        216 &        420 &        242 &        451 &        196 &        987 &        649 &        184 &        256 &        218 &         86 &        962 &        203 &         37 &        494 &        286 &        663 &        612 &        549 &        537 &        594 \\

        Dy &        265 &         21 &        889 &        312 &        756 &         94 &        976 &        188 &        147 &        839 &        527 &        442 &        849 &        948 &        570 &        553 &        902 &        290 &         81 &        758 &        759 &        598 &        344 &        104 \\

        Ho &        218 &        503 &        999 &        465 &        573 &        586 &        122 &        991 &        241 &        710 &        182 &         87 &        965 &        746 &         90 &        638 &         35 &        122 &        389 &        892 &        815 &        617 &        116 &        895 \\

        Er &        571 &        932 &        738 &        653 &        986 &        430 &        992 &        432 &        823 &        542 &        444 &        702 &        524 &         58 &        248 &        914 &        697 &        420 &        913 &        754 &        596 &        429 &        995 &        927 \\

        Tm &        551 &         72 &        654 &        819 &        593 &          7 &        110 &        707 &        535 &         74 &        142 &        150 &        610 &        564 &        859 &        451 &        832 &        822 &        938 &        877 &        954 &        430 &         41 &        657 \\

        Yb &        815 &        643 &        650 &        217 &        962 &        612 &        926 &        524 &        559 &        500 &        822 &        630 &        901 &        525 &        407 &        563 &        575 &        161 &        505 &        166 &        207 &        680 &        418 &        478 \\

        Lu &        106 &        597 &        551 &        650 &        391 &        850 &        589 &        649 &          6 &        277 &        129 &        566 &        109 &        922 &        767 &        173 &        525 &        250 &        449 &        662 &        221 &        831 &        969 &        479 \\

        Hf &        100 &        833 &        566 &        331 &         36 &        589 &         33 &        785 &        862 &        447 &        469 &        284 &        329 &        116 &        608 &        256 &        665 &         41 &         74 &        527 &        479 &        300 &        800 &         51 \\

        Ta &        337 &        757 &        903 &        411 &        745 &        638 &        243 &        584 &        336 &        477 &        994 &        307 &        349 &        981 &        572 &        364 &        822 &        609 &        198 &        478 &        922 &        854 &        819 &        130 \\

        Th &       1000 &        520 &        222 &        998 &        774 &         88 &        843 &        259 &        424 &        845 &        884 &        739 &        666 &        673 &        531 &        934 &        322 &        682 &        754 &        944 &        153 &        779 &         20 &        890 \\        
    \end{longtable}        

\end{document}
0

This is how I accomplished the desired behaviour. For editing large tables I use LibreOffice Calc application. The reasons are following:

  • prize (LibreOffice package is free)
  • maturity (the application is relatively bug free)
  • easy of use also for inexperienced user. What that means you appreciate in the moment when you need change order of existing columns or add new column in the middle of already existing table. In standard TeX editor (I use TeXstudio) this was something horrible. Even when TeX studio has GUI commands for pasting, removing or cut-ying column, these commands have several bugs and or not usable for serious work.
  • support for saving csv files in UTF-8 format (this you cant do even in newest Microsoft Excel 2013!)

After finishing editation of my table I save it in UTF-8 format. It is important to not neglect setting custom format in the saving process which includes choosing correct encoding (UTF-8) and separator which should be '&' character. Because the table is wide (it spans accross two pages), in LibreOffice calc I create it as two separate tables each saved to separate csv file. Each csv file can contain all rows, so there is no need at this phase to consider page breaks. First csv file contains that part of table which will be visible on even pages. Second csv file contains that part of table which will be visible on odd pages.

Another key point is to use \partialinput macro (defined here and copy-pasted to my example source code) which extracts from selected input file only those rows which will be typeset on one particular page. Here is extract of source code for my case:

\makeatletter
\newread\pin@file
\newcounter{pinlineno}
\newcommand\pin@accu{}
\newcommand\pin@ext{pintmp}
% inputs #3, selecting only lines #1 to #2 (inclusive)
\newcommand*\partialinput [3] {%
  \IfFileExists{#3}{%
    \openin\pin@file #3
    % skip lines 1 to #1 (exclusive)
    \setcounter{pinlineno}{1}
    \@whilenum\value{pinlineno}<#1 \do{%
      \read\pin@file to\pin@line
      \stepcounter{pinlineno}%
    }
    % prepare reading lines #1 to #2 inclusive
    \addtocounter{pinlineno}{-1}
    \let\pin@accu\empty
    \begingroup
    \endlinechar\newlinechar
    \@whilenum\value{pinlineno}<#2 \do{%
      % use safe catcodes provided by e-TeX's \readline
      \readline\pin@file to\pin@line
      \edef\pin@accu{\pin@accu\pin@line}%
      \stepcounter{pinlineno}%
    }
    \closein\pin@file
    \expandafter\endgroup
    \scantokens\expandafter{\pin@accu}%
  }{%
    \errmessage{File `#3' doesn't exist!}%
  }%
}
\makeatother

\begin{table} 
    \begin{tabular}{p{1.4cm}p{6cm}p{5cm}p{3.3cm}}
    \toprule
    \partialinput{2}{37}{data/basnici_cina_left.csv}
    \bottomrule
    \end{tabular}
}
\end{table}

\begin{table}
    \begin{tabular}{p{2.2cm}p{2cm}p{2.3cm}p{2.3cm}p{3cm}p{3cm}}
    \toprule
    \partialinput{2}{37}{data/basnici_cina_right.csv}
    \bottomrule
    \end{tabular}
\end{table}

\begin{table} 
    \begin{tabular}{p{1.4cm}p{6cm}p{5cm}p{3.3cm}}
        \toprule
        \partialinput{38}{75}{data/basnici_cina_left.csv}
        \bottomrule
    \end{tabular}
\end{table}

\begin{table}
    \begin{tabular}{p{2.2cm}p{2cm}p{2.3cm}p{2.3cm}p{3cm}p{3cm}}
        \toprule
        \partialinput{38}{75}{data/basnici_cina_right.csv}
        \bottomrule
    \end{tabular}
\end{table}

\begin{table}
    \begin{tabular}{p{1.4cm}p{6cm}p{5cm}p{3.3cm}}
        \toprule
        \partialinput{76}{80}{data/basnici_cina_left.csv}
        \bottomrule
    \end{tabular}
\end{table}

\begin{table}   
    \begin{tabular}{p{2.2cm}p{2cm}p{2.3cm}p{2.3cm}p{3cm}p{3cm}}
        \toprule
        \partialinput{76}{80}{data/basnici_cina_right.csv}
        \bottomrule
    \end{tabular}
\end{table}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.