latexwidthlongtable

Large longtable to fit in LaTeX


I'm trying to fit a multiple page longtable into my LaTeX document. Even after searching around for answers for longtable fitting in LaTeX I can't find a solution that works for my table.

This is what my table is going to contain. It should be a four column table. I have no idea how to use the longtable function correctly, since in all of my attempts the table is way too wide.

Edit:

I've updated the table after using the input from Ellen McCastle.

This now works with the multiple page bit, but it is overruling the placements of the text in the columns. So that it doesn't look as neat as I would like.

Is there any way to edit this?

I've uploaded a image of how the table looks in excel for comparison.

Table:

\begin{longtable}{@{\extracolsep{\fill}}R{2cm}L{7.5cm}R{3cm}C{0.85cm}}
\hline
\multicolumn{1}{l}{{\color[HTML]{FE0000} Pengeinstitutternes størrelsesgruppering 2016}} &                                      &  &    \\ \hline
\multicolumn{1}{l}{Antal pengeinstitutter gruppe 1- 4}                                   &                                      &  & 76 \\
\multicolumn{1}{l}{Gruppe 1 - Arb. kapital over 75 mia. kr.}                             &                                      &  &    \\ \hline
3000                                                                                     & Danske Bank A/S                      &  &    \\
2222                                                                                     & Nordea Bank Danmark A/S              &  &    \\
7858                                                                                     & Jyske Bank A/S                       &  &    \\
8079                                                                                     & Sydbank A/S                          &  &    \\
8117                                                                                     & Nykredit Bank A/S                    &  &    \\ \hline
5                                                                                        & \multicolumn{1}{r}{5}                &  &    \\
\multicolumn{1}{l}{Gruppe 2 - Arb. kapital over 12 mia. kr.}                             &                                      &  &    \\ \hline
9380                                                                                     & Spar Nord Bank A/S                   &  &    \\
5301                                                                                     & Arbejdernes Landsbank, Aktieselskab  &  &    \\
1149                                                                                     & Saxo Bank A/S                        &  &    \\
7730                                                                                     & Vestjysk Bank A/S                    &  &    \\
7670                                                                                     & Ringkjøbing Landbobank, Aktieselskab &  &    \\
8099                                                                                     & Nordjyske Bank A/S                   &  &    \\
9335                                                                                     & Kronjylland, Sparekassen             &  &    \\
9686                                                                                     & Den Jyske Sparekasse                 &  &    \\
400                                                                                      & Lån og Spar Bank A/S                 &  &    \\
9217                                                                                     & Jutlander Bank A/S                   &  &    \\
522                                                                                      & Sparekassen Sjælland A/S             &  &    \\
9070                                                                                     & Sparekassen Vendsyssel               &  &    \\ \hline
12                                                                                       & \multicolumn{1}{r}{11}               &  &    \\
\multicolumn{1}{l}{Gruppe 3 - Arb. kapital over 500 mio. kr.}                            &                                      &  &    \\ \hline
7681                                                                                     & Alm. Brand Bank A/S                  &  &    \\
5999                                                                                     & Danske Andelskassers Bank A/S        &  &    \\
10001                                                                                    & FIH Erhvervsbank A/S                 &  &    \\
755                                                                                      & Middelfart Sparekasse                &  &    \\
6771                                                                                     & Lægernes Pensionsbank A/S            &  &    \\
7320                                                                                     & Djurslands Bank A/S                  &  &    \\
9090                                                                                     & Sparekassen Thy                      &  &    \\
9740                                                                                     & Frøs Herreds Sparekasse              &  &    \\
844                                                                                      & Fynske Bank A/S                      &  &    \\
828                                                                                      & Sparekassen Fyn A/S                  &  &    \\
7780                                                                                     & Skjern Bank, Aktieselskabet          &  &    \\
6471                                                                                     & Grønlandsbanken, Aktieselskab        &  &    \\
9695                                                                                     & Saxo Privatbank A/S                  &  &    \\
7230                                                                                     & Østjydsk Bank A/S                    &  &    \\
7890                                                                                     & Salling Bank A/S                     &  &    \\
6520                                                                                     & Lollands Bank, Aktieselskab          &  &    \\
13460                                                                                    & Merkur Andelskasse                   &  &    \\
7930                                                                                     & Kreditbanken A/S                     &  &    \\
6860                                                                                     & Nordfyns Bank Aktieselskabet         &  &    \\
6880                                                                                     & Totalbanken A/S                      &  &    \\
1671                                                                                     & Basisbank A/S                        &  &    \\
9044                                                                                     & Dronninglund Sparekasse              &  &    \\
6140                                                                                     & Møns Bank, A/S                       &  &    \\
9682                                                                                     & Nr. Nebel og Omegn, Sparekassen for  &  &    \\
7570                                                                                     & PenSam Bank A/S                      &  &    \\
9797                                                                                     & Broager Sparekasse                   &  &    \\
9388                                                                                     & Sparekassen Djursland                &  &    \\
9827                                                                                     & Sparekassen Bredebro                 &  &    \\
537                                                                                      & Dragsholm Sparekasse                 &  &    \\
6620                                                                                     & Coop Bank A/S                        &  &    \\
9283                                                                                     & Langå Sparekasse                     &  &    \\
7500                                                                                     & Hvidbjerg Bank Aktieselskab          &  &    \\
13080                                                                                    & Frørup Andelskasse                   &  &    \\
9354                                                                                     & Rønde Sparekasse                     &  &    \\
9312                                                                                     & Sparekassen Balling                  &  &    \\
9133                                                                                     & Frøslev-Mollerup Sparekasse          &  &    \\
9137                                                                                     & Ekspres Bank A/S                     &  &    \\
9860                                                                                     & Folkesparekassen                     &  &    \\
847                                                                                      & Rise Sparekasse                      &  &    \\ \hline
39                                                                                       & \multicolumn{1}{r}{39}               &  &    \\
\multicolumn{1}{l}{Gruppe 4 - Arb. kapital under 500 mio. kr.}                           &                                      &  &    \\ \hline
13290                                                                                    & Andelskassen Fælleskassen            &  &    \\
9684                                                                                     & Fanø Sparekasse                      &  &    \\
6102                                                                                     & Landbrugets Finansieringsbank (LFB)  &  &    \\
9124                                                                                     & Sønderhå-Hørsted Sparekasse          &  &    \\
9135                                                                                     & Klim Sparekasse                      &  &    \\
13100                                                                                    & Københavns Andelskasse               &  &    \\
9634                                                                                     & Borbjerg Sparekasse                  &  &    \\
13070                                                                                    & Faster Andelskasse                   &  &    \\
800                                                                                      & Flemløse Sparekasse                  &  &    \\
9369                                                                                     & Søby-Skader-Halling Sparekasse       &  &    \\
1693                                                                                     & PFA Bank                             &  &    \\
579                                                                                      & Sparekassen Den lille Bikube         &  &    \\
5125                                                                                     & Leasing Fyn Bank A/S                 &  &    \\
13350                                                                                    & Østervraa, J.A.K. Andelskassen       &  &    \\
28001                                                                                    & MAJ Bank A/S                         &  &    \\
9629                                                                                     & Stadil Sparekasse                    &  &    \\
13220                                                                                    & Andelskassen OIKOS                   &  &    \\
544                                                                                      & Refsnæs Sparekasse                   &  &    \\
9639                                                                                     & Fjaltring-Trans Sparekasse           &  &    \\
13330                                                                                    & Slagelse Andelskasse                 &  &    \\ \hline
20                                                                                       & \multicolumn{1}{r}{17}               &  &    \\
\multicolumn{1}{l}{}                                                                     &                                      &  &   
\end{longtable}

My margins in my document are:

\setmarginsrb           { 1.25in}  % left margin
                        { 0.6in}  % top margin
                        { 1.25in}  % right margin
                        { 1in}  % bottom margin
                        {  20pt}  % head height
                        {0.25in}  % head sep
                        {   9pt}  % foot height
                        { 0.3in}  % foot sep

Please ask for any more information, and I will try my best to supply. I am very green in LaTeX.

Image of table in excel:

Excel_table


Solution

  • It would be helpful if you could provide your own attempts at the longtable.

    Until then, maybe this can help you:

    \usepackage{longtable}
    \usepackage{vmargin}   
    \usepackage{tabularx}
    
    \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}                  
    \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}                        
    \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
    ...
    \begin{longtable}{@{\extracolsep{\fill}}R{2cm}L{7.5cm}R{3cm}C{0.85cm}}
    

    {@{\extracolsep{\fill}} takes care of spreading the table across the width of your text area, the R{2cm} make the content of that column stick to the right, C to the center and L to the left.

    I hope this helps you!