0

Below you see a table that I created in my appendix and that I have three problems with (the main problem is the one of the thread title).

longtable

  1. Table A.22 depicted above is too long for one page, therefore I use the package longtable. I'm happy how the table looks, apart from the fact that I would like the header that is displayed at the beginning (Community, Paying members, ...) to be displayed on the consecutive pages too. How can I replicate this header?

  2. Somehowe, when I use longtable, it puts the table after table A.2 instead of its true position which would be A.22. Why is this?

  3. I managed to align "Community" to the left, but the actual table entries in that column are still centered. How can I align the entries to the left for this column alone?


\documentclass[12pt]{report}
    \usepackage{tabulary}
    \usepackage[maxfloats=30,morefloats=12]{morefloats}
    \usepackage{booktabs}
    \usepackage{float,lscape}
    \usepackage{longtable}
   \usepackage{pdflscape}
    \usepackage{tabularx}
    \usepackage{multirow}
    \usepackage{bigstrut}

    \begin{document}
    \begingroup
    \centering
    \tiny
    \begin{longtable}[htbp]{*{5}1}
      \caption{Zurich gymnastics organization in 1907}
        \hline
        \multicolumn{1}{l}{Association} & Paying members & Non-paying members & Total & Active members \bigstrut\\
        \hline
        Adliswil & 89    & 3     & 92    & 19 \bigstrut[t]\\
        Affoltern a. A. & 40    & 10    & 50    & 16 \\
        Affoltern b. Zürich & 60    & 12    & 72    & 18 \\
        Albisrieden & 68    & 7     & 75    & 16 \\
        Altstetten & 177   & 38    & 215   & 35 \\
        Andelfingen & 32    & 6     & 38    & 8 \\
        Bäretswil & 38    & 5     & 43    & 11 \\
        Basserdorf & 101   & 33    & 134   & 26 \\
        Birmensdorf & 32    & 6     & 38    & 10 \\
        Brüttisellen & 50    & 4     & 54    & 16 \\
        Bubikon & 32    & 6     & 38    & 12 \\
        Bülach & 64    & 5     & 69    & 16 \\
        Dielsdorf & 45    & -     & 45    & 15 \\
        Dietikon & 74    & 18    & 92    & 18 \\
        Dietlikon & 40    & 6     & 46    & 10 \\
        Dübendorf & 92    & 8     & 100   & 16 \\
        Dürnten & 100   & 3     & 103   & 20 \\
        Elgg  & 50    & 3     & 53    & 9 \\
        Embrach & 34    & 9     & 43    & 14 \\
        Engstringen & 63    & 1     & 64    & 24 \\
        Erlenbach & 70    & 3     & 73    & 20 \\
        Fehraltorf & 45    & 1     & 46    & 15 \\
        Freienstein & 40    & 4     & 44    & 9 \\
        Glattfelden & 40    & 12    & 52    & 12 \\
        Grafstall & 38    & 16    & 54    & 14 \\
        Gossau & 45    & 3     & 48    & 15 \\
        Hedingen & 59    & 3     & 62    & 19 \\
        Hinwil & 45    & 6     & 51    & 18 \\
        Hombrechtikon & 52    & -     & 52    & 15 \\
        Höngg & 129   & 19    & 148   & 38 \\
        Horgen & 154   & 36    & 190   & 48 \\
        Kilchberg & 120   & 15    & 135   & 20 \\
        Kloten & 61    & 4     & 65    & 14 \\
        Küsnacht, Bürger & 91    & 27    & 118   & 22 \\
        Küsnacht, Seminar & 65    & -     & 65    & 55 \\
        Küsnacht, Männer & 16    & -     & 16    & - \\
        Langnau & 70    & 40    & 110   & 18 \\
        Männedorf & 90    & 9     & 99    & 17 \\
        Meilen & 60    & 26    & 86    & 16 \\
        Mettmenstetten & 60    & -     & 60    & 18 \\
        Neftenbach & 48    & 18    & 66    & 23 \\
        Niederglatt & 59    & -     & 59    & 16 \\
        Ober-Winterthur & 92    & 20    & 112   & 20 \\
        Obfelden & 65    & 14    & 79    & 15 \\
        Oerlikon & 190   & 48    & 238   & 70 \\
        Ottenbach & 48    & 9     & 57    & 15 \\
        Pfäffikon & 70    & 7     & 77    & 15 \\
        Pfungen & 35    & 10    & 45    & 15 \\
        Räterschen & 14    & 15    & 29    & 10 \\
        Richterswil & 93    & 10    & 103   & 28 \\
        Rykon im Tösstal & 38    & 8     & 46    & 13 \\
        Rorbas & 15    & 15    & 30    & 15 \\
        Rüschlikon & 91    & 22    & 113   & 16 \\
        Rüti  & 163   & 34    & 197   & 38 \\
        Schwamendingen & 57    & 22    & 79    & 20 \\
        Schlieren & 92    & 20    & 112   & 23 \\
        Seebach & 223   & 47    & 270   & 42 \\
        Seen  & 80    & 14    & 94    & 19 \\
        Stäfa & 80    & 30    & 110   & 20 \\
        Thalwil & 355   & 69    & 424   & 60 \\
        Thalwil, Männer & 32    & 3     & 35    & - \\
        Töss  & 220   & 66    & 286   & 51 \\
        Turbenthal & 41    & 2     & 43    & 16 \\
        Uetikon a. See & 50    & 15    & 65    & 12 \\
        Urdorf & 9     & 21    & 30    & 7 \\
        Uster & 113   & 15    & 128   & 38 \\
        Veltheim & 235   & 39    & 274   & 31 \\
        Wädenswil & 157   & 18    & 175   & 23 \\
        Wädenswil, Grütli & 90    & 1     & 91    & 25 \\
        Wädenswil, Männer & 12    & -     & 12    & - \\
        Wald  & 60    & 10    & 70    & 27 \\
        Wallisellen & 53    & 12    & 65    & 13 \\
        Wetzikon & 94    & 17    & 111   & 23 \\
        Wiesendangen & 65    & 4     & 69    & 11 \\
        Winterthur, Deutsch. T. V. & 34    & 8     & 42    & 10 \\
        Winterthur, Grütli & 110   & 13    & 123   & 39 \\
        Winterthur, Männer & 110   & 94    & 204   & - \\
        Winterthur, Pflanzschule Geiselweid & 85    & 4     & 89    & 27 \\
        Winterthur, Stadt & 226   & 144   & 370   & 52 \\
        Winterthur, Technikum & 31    & 8     & 39    & 19 \\
        Winterthur, Tössfeld-Schöntal & 150   & 3     & 153   & 32 \\
        Wülflingen & 80    & 38    & 118   & 28 \\
        Zollikon & 93    & 14    & 107   & 15 \\
        Zürich, Alte Sektion & 469   & 73    & 542   & 65 \\
        Zürich, Aussersihl & 435   & 107   & 542   & 81 \\
        Zürich, Aussersihl Grütli & 130   & 20    & 150   & 35 \\
        Zürich, Aussersihl Männer & 126   & 24    & 150   & - \\
        Zürich Bürger & 94    & 18    & 112   & 18 \\
        Zürich Deutsche Turner & 146   & 26    & 172   & 53 \\
        Zürich Enge & 136   & 50    & 186   & 26 \\
        Zürich Fluntern & 131   & 22    & 153   & 22 \\
        Zürich Hottingen & 338   & -     & 338   & 38 \\
        Zürich Hottingen Männer & 30    & 1     & 31    & - \\
        Zürich Industriequartier & 188   & 4     & 192   & 37 \\
        Zürich Kaufm. T. S. & 169   & 14    & 183   & 67 \\
        Zürich Männer & 250   & 35    & 285   & - \\
        Zürich Neumünster & 507   & 95    & 602   & 60 \\
        Zürich Neumünster Grütli & 50    & 19    & 69    & 20 \\
        Zürich Oberstrass & 138   & 43    & 181   & 23 \\
        Zürich Utonia & 52    & 275   & 327   & 27 \\
        Zürich Unterstrass & 151   & 38    & 189   & 29 \\
        Zürich Wiedikon & 302   & 51    & 353   & 59 \\
        Zürich Wiedikon Männer & 25    & 56    & 81    & - \\
        Zürich Wipkingen & 100   & 39    & 139   & 28 \\
        Zürich Wipkingen Grütli & 60    & 12    & 72    & 18 \\
        Wollishofen & 124   & 12    & 136   & 30 \bigstrut[b]\\
        \hline
        Total & 10840 & 2422  & 13262 & 2460 \bigstrut\\
        \hline
        \end{longtable}%
      \label{tab:addlabel}%
    \endgroup%

    \end{document}
  • Your code as posted does not compile. Please correct it. Also, if you read the output, it tells you why the columns are all centred. It says it right there in black and green. – cfr Jan 6 '15 at 2:18
2

Scope of this Answer

This answer is both narrower and broader than the original question.

Narrower

This answer address only those questions which it is possible to address in light of the information given in the question. In particular, since the code posted included only one table, (2) clearly concerns an issue which cannot be reproduced and is, therefore, not answerable. I could hazard some guesses but that runs a high risk of wasting both my time and yours.

Broader

As posted, the code has multiple issues and will not compile. It also contains much that is unnecessary and some that is undesirable. These problems are addressed.

Notes

  • longtable is not a floating environment. Hence, there is no point in passing it the optional argument you might pass to a table. Floats cannot break across pages. Period. Long tables cannot, therefore, float.

    • It follows that we can delete the optional argument and all of the packages related to floats.
  • Few of the loaded packages are needed for the example. Only bigstrut and longtable are required. I have also retained booktabs for reasons explained below.

  • longtable is centred by default, so \centering is unnecessary. The group is needed only to limit the scope of \tiny.

  • 1 is not a valid column specifier. array therefore substitutes c, which is. Probably you wanted l.

    • This is part of the answer to question (1).

    • The array package tells you this in its output. Read the output on the console - the messages are sometimes opaque, but sometimes they are illuminating. In this case, the message tells you both what is wrong (1) and what is being done as a quick fix (use c instead) which, of course, explains why all your columns end up centred...

  • A \multicolumn... affects only that row. It has no influence on later rows. To change the formatting of a column, change the spec. in the argument to the longtable environment.

    • This is the other part of the answer to question (1).
  • If you do not specify any headers or footers for the longtable, you don't get any.

    • Specifying headers appropriately addresses question (1).

    • Specifying a footer improves things further.

  • booktabs produces nicer-looking tables, but only if you use its facilities. This means using its rule commands rather than \hline.

Code

\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{bigstrut}

\begin{document}
  {\tiny
  \begin{longtable}{l*{4}{c}}
    \caption{Zurich gymnastics organization in 1907\label{tab:addlabel}}\\
    \toprule
    Association & Paying members & Non-paying members & Total & Active members \bigstrut\\
    \midrule\endfirsthead
    \toprule
    Association & Paying members & Non-paying members & Total & Active members \bigstrut\\
    \midrule\endhead
    \bottomrule\endfoot
    Adliswil & 89    & 3     & 92    & 19 \bigstrut[t]\\
    Affoltern a. A. & 40    & 10    & 50    & 16 \\
    Affoltern b. Zürich & 60    & 12    & 72    & 18 \\
    Albisrieden & 68    & 7     & 75    & 16 \\
    Altstetten & 177   & 38    & 215   & 35 \\
    Andelfingen & 32    & 6     & 38    & 8 \\
    Bäretswil & 38    & 5     & 43    & 11 \\
    Basserdorf & 101   & 33    & 134   & 26 \\
    Birmensdorf & 32    & 6     & 38    & 10 \\
    Brüttisellen & 50    & 4     & 54    & 16 \\
    Bubikon & 32    & 6     & 38    & 12 \\
    Bülach & 64    & 5     & 69    & 16 \\
    Dielsdorf & 45    & -     & 45    & 15 \\
    Dietikon & 74    & 18    & 92    & 18 \\
    Dietlikon & 40    & 6     & 46    & 10 \\
    Dübendorf & 92    & 8     & 100   & 16 \\
    Dürnten & 100   & 3     & 103   & 20 \\
    Elgg  & 50    & 3     & 53    & 9 \\
    Embrach & 34    & 9     & 43    & 14 \\
    Engstringen & 63    & 1     & 64    & 24 \\
    Erlenbach & 70    & 3     & 73    & 20 \\
    Fehraltorf & 45    & 1     & 46    & 15 \\
    Freienstein & 40    & 4     & 44    & 9 \\
    Glattfelden & 40    & 12    & 52    & 12 \\
    Grafstall & 38    & 16    & 54    & 14 \\
    Gossau & 45    & 3     & 48    & 15 \\
    Hedingen & 59    & 3     & 62    & 19 \\
    Hinwil & 45    & 6     & 51    & 18 \\
    Hombrechtikon & 52    & -     & 52    & 15 \\
    Höngg & 129   & 19    & 148   & 38 \\
    Horgen & 154   & 36    & 190   & 48 \\
    Kilchberg & 120   & 15    & 135   & 20 \\
    Kloten & 61    & 4     & 65    & 14 \\
    Küsnacht, Bürger & 91    & 27    & 118   & 22 \\
    Küsnacht, Seminar & 65    & -     & 65    & 55 \\
    Küsnacht, Männer & 16    & -     & 16    & - \\
    Langnau & 70    & 40    & 110   & 18 \\
    Männedorf & 90    & 9     & 99    & 17 \\
    Meilen & 60    & 26    & 86    & 16 \\
    Mettmenstetten & 60    & -     & 60    & 18 \\
    Neftenbach & 48    & 18    & 66    & 23 \\
    Niederglatt & 59    & -     & 59    & 16 \\
    Ober-Winterthur & 92    & 20    & 112   & 20 \\
    Obfelden & 65    & 14    & 79    & 15 \\
    Oerlikon & 190   & 48    & 238   & 70 \\
    Ottenbach & 48    & 9     & 57    & 15 \\
    Pfäffikon & 70    & 7     & 77    & 15 \\
    Pfungen & 35    & 10    & 45    & 15 \\
    Räterschen & 14    & 15    & 29    & 10 \\
    Richterswil & 93    & 10    & 103   & 28 \\
    Rykon im Tösstal & 38    & 8     & 46    & 13 \\
    Rorbas & 15    & 15    & 30    & 15 \\
    Rüschlikon & 91    & 22    & 113   & 16 \\
    Rüti  & 163   & 34    & 197   & 38 \\
    Schwamendingen & 57    & 22    & 79    & 20 \\
    Schlieren & 92    & 20    & 112   & 23 \\
    Seebach & 223   & 47    & 270   & 42 \\
    Seen  & 80    & 14    & 94    & 19 \\
    Stäfa & 80    & 30    & 110   & 20 \\
    Thalwil & 355   & 69    & 424   & 60 \\
    Thalwil, Männer & 32    & 3     & 35    & - \\
    Töss  & 220   & 66    & 286   & 51 \\
    Turbenthal & 41    & 2     & 43    & 16 \\
    Uetikon a. See & 50    & 15    & 65    & 12 \\
    Urdorf & 9     & 21    & 30    & 7 \\
    Uster & 113   & 15    & 128   & 38 \\
    Veltheim & 235   & 39    & 274   & 31 \\
    Wädenswil & 157   & 18    & 175   & 23 \\
    Wädenswil, Grütli & 90    & 1     & 91    & 25 \\
    Wädenswil, Männer & 12    & -     & 12    & - \\
    Wald  & 60    & 10    & 70    & 27 \\
    Wallisellen & 53    & 12    & 65    & 13 \\
    Wetzikon & 94    & 17    & 111   & 23 \\
    Wiesendangen & 65    & 4     & 69    & 11 \\
    Winterthur, Deutsch. T. V. & 34    & 8     & 42    & 10 \\
    Winterthur, Grütli & 110   & 13    & 123   & 39 \\
    Winterthur, Männer & 110   & 94    & 204   & - \\
    Winterthur, Pflanzschule Geiselweid & 85    & 4     & 89    & 27 \\
    Winterthur, Stadt & 226   & 144   & 370   & 52 \\
    Winterthur, Technikum & 31    & 8     & 39    & 19 \\
    Winterthur, Tössfeld-Schöntal & 150   & 3     & 153   & 32 \\
    Wülflingen & 80    & 38    & 118   & 28 \\
    Zollikon & 93    & 14    & 107   & 15 \\
    Zürich, Alte Sektion & 469   & 73    & 542   & 65 \\
    Zürich, Aussersihl & 435   & 107   & 542   & 81 \\
    Zürich, Aussersihl Grütli & 130   & 20    & 150   & 35 \\
    Zürich, Aussersihl Männer & 126   & 24    & 150   & - \\
    Zürich Bürger & 94    & 18    & 112   & 18 \\
    Zürich Deutsche Turner & 146   & 26    & 172   & 53 \\
    Zürich Enge & 136   & 50    & 186   & 26 \\
    Zürich Fluntern & 131   & 22    & 153   & 22 \\
    Zürich Hottingen & 338   & -     & 338   & 38 \\
    Zürich Hottingen Männer & 30    & 1     & 31    & - \\
    Zürich Industriequartier & 188   & 4     & 192   & 37 \\
    Zürich Kaufm. T. S. & 169   & 14    & 183   & 67 \\
    Zürich Männer & 250   & 35    & 285   & - \\
    Zürich Neumünster & 507   & 95    & 602   & 60 \\
    Zürich Neumünster Grütli & 50    & 19    & 69    & 20 \\
    Zürich Oberstrass & 138   & 43    & 181   & 23 \\
    Zürich Utonia & 52    & 275   & 327   & 27 \\
    Zürich Unterstrass & 151   & 38    & 189   & 29 \\
    Zürich Wiedikon & 302   & 51    & 353   & 59 \\
    Zürich Wiedikon Männer & 25    & 56    & 81    & - \\
    Zürich Wipkingen & 100   & 39    & 139   & 28 \\
    Zürich Wipkingen Grütli & 60    & 12    & 72    & 18 \\
    Wollishofen & 124   & 12    & 136   & 30 \bigstrut[b]\\
    \cmidrule(lr){1-5}
    Total & 10840 & 2422  & 13262 & 2460 \bigstrut\\
  \end{longtable}}
\end{document}

Table

long table modified

  • Fantastic! Do you maybe also know the answer to question (2)? – MadJens Jan 6 '15 at 18:51
  • @MadJens Well, I didn't say this because I can't know without seeing code which reproduces the issue, and you only posted code which included the one table. However, if I had to guess, I'd say that your other table is created using \begin{table}... and is, therefore, a float which LaTeX will place according to the rules for float placement. If you don't want LaTeX to do that, just use a tabular environment and it won't get floated before the longer table. – cfr Jan 6 '15 at 21:29

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.