2

I am trying to fit a long table in multiple landscape pages by using longtable, and I would like it to break between columns (here I reduced its number of rows for simplicity):

\documentclass[12pt]{scrreprt}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{dcolumn}

\begin{landscape}
        \tiny
    \begin{longtable}{@{\extracolsep{0pt}} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2}}
     \caption{Correlation matrix} 
     \label{tab:correl} 
    \\[-1.8ex]\hline 
    \hline \\[-1.8ex] 
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{LEVEL\_B} & \multicolumn{1}{c}{LEVEL\_W} & \multicolumn{1}{c}{MPI} & \multicolumn{1}{c}{EXP} & \multicolumn{1}{c}{PAT} & \multicolumn{1}{c}{INF} & \multicolumn{1}{c}{PAC\_FSC} & \multicolumn{1}{c}{L488} & \multicolumn{1}{c}{PUBSEC} & \multicolumn{1}{c}{PA\_EMP} & \multicolumn{1}{c}{NET} & \multicolumn{1}{c}{LEA} & \multicolumn{1}{c}{UNEMP} & \multicolumn{1}{c}{EDU} & \multicolumn{1}{c}{CRIM} & \multicolumn{1}{c}{WC\_CRIM} & \multicolumn{1}{c}{TAXGAP} & \multicolumn{1}{c}{NGO} & \multicolumn{1}{c}{DIM} & \multicolumn{1}{c}{INNO} & \multicolumn{1}{c}{NO\_DEG} & \multicolumn{1}{c}{LABOR} & \multicolumn{1}{c}{ERDF} & \multicolumn{1}{c}{PA\_CLIENT} & \multicolumn{1}{c}{MARKET} & \multicolumn{1}{c}{DIM\_LU} \\ 
    \hline \\[-1.8ex] 
    \multicolumn{1}{l}{LEVEL\_B} & 1 & 0.37 & 0.30 & -0.12 & 0.08 & 0.02 & 0.13 & 0.06 & -0.07 & 0.10 & 0.20 & -0.06 & 0.20 & 0.10 & 0.12 & 0.13 & 0.03 & -0.19 & -0.11 & -0.09 & 0.10 & -0.08 & -0.02 & 0.04 & 0.07 & 0.06 \\ 
    \multicolumn{1}{l}{LEVEL\_W} & 0.37 & 1 & 0.12 & 0.04 & 0.41 & 0.29 & -0.04 & -0.11 & -0.07 & 0.08 & -0.03 & -0.16 & -0.05 & 0.20 & 0.37 & -0.03 & -0.21 & -0.14 & -0.18 & -0.01 & 0.11 & -0.24 & -0.08 & -0.15 & 0.01 & 0.19 \\ 
    \multicolumn{1}{l}{MPI} & 0.30 & 0.12 & 1 & -0.39 & -0.10 & -0.17 & 0.34 & 0.43 & -0.11 & 0.19 & 0.62 & -0.06 & 0.60 & 0.13 & -0.002 & 0.52 & 0.37 & -0.49 & -0.19 & 0 & -0 & 0 & 0.22 & 0.11 & 0.02 & -0.002 \\ 
    \multicolumn{1}{l}{EXP} & -0.12 & 0.04 & -0.39 & 1 & 0.29 & 0.40 & -0.40 & -0.47 & -0.11 & -0.24 & -0.44 & -0.21 & -0.55 & -0.11 & 0.17 & -0.40 & -0.56 & 0.20 & -0.11 & 0 & -0 & 0 & -0.12 & -0.16 & -0.04 & -0.03 \\ 
    \multicolumn{1}{l}{PAT} & 0.08 & 0.41 & -0.10 & 0.29 & 1 & 0.59 & -0.28 & -0.36 & -0.09 & 0.11 & -0.33 & -0.24 & -0.39 & 0.32 & 0.69 & -0.32 & -0.53 & 0.05 & -0.30 & 0 & 0 & 0 & -0.08 & -0.12 & -0.06 & -0.05 \\ 
    \multicolumn{1}{l}{INF} & 0.02 & 0.29 & -0.17 & 0.40 & 0.59 & 1 & -0.38 & -0.56 & -0.15 & 0.06 & -0.45 & -0.34 & -0.55 & 0.26 & 0.70 & -0.44 & -0.61 & 0.10 & -0.27 & -0 & -0 & -0 & -0.11 & -0.17 & -0.04 & -0.07 \\ 
    \multicolumn{1}{l}{PAC\_FSC} & 0.13 & -0.04 & 0.34 & -0.40 & -0.28 & -0.38 & 1 & 0.52 & 0.04 & 0.28 & 0.57 & 0.08 & 0.64 & 0.07 & -0.28 & 0.44 & 0.38 & -0.35 & 0.02 & 0 & 0 & 0 & 0.12 & 0.16 & 0.03 & 0.02 \\ 
    \multicolumn{1}{l}{L488} & 0.06 & -0.11 & 0.43 & -0.47 & -0.36 & -0.56 & 0.52 & 1 & -0.05 & 0.18 & 0.74 & 0.10 & 0.76 & 0.09 & -0.46 & 0.68 & 0.68 & -0.47 & 0.04 & -0 & 0 & -0 & 0.20 & 0.22 & 0.04 & 0.04 \\ 
    \multicolumn{1}{l}{PUBSEC} & -0.07 & -0.07 & -0.11 & -0.11 & -0.09 & -0.15 & 0.04 & -0.05 & 1 & 0.40 & -0.22 & 0.69 & -0.15 & 0.04 & -0.16 & -0.20 & -0.11 & 0.58 & 0.40 & -0 & -0 & 0 & 0.01 & 0.11 & -0.06 & -0.0003 \\ 
    \multicolumn{1}{l}{PA\_EMP} & 0.10 & 0.08 & 0.19 & -0.24 & 0.11 & 0.06 & 0.28 & 0.18 & 0.40 & 1 & 0.13 & 0.35 & 0.18 & 0.45 & 0.05 & 0.14 & -0.06 & 0.15 & 0.03 & -0 & 0 & 0 & 0.10 & 0.16 & 0.002 & -0.02 \\ 
    \multicolumn{1}{l}{NET} & 0.20 & -0.03 & 0.62 & -0.44 & -0.33 & -0.45 & 0.57 & 0.74 & -0.22 & 0.13 & 1 & -0.09 & 0.86 & 0.03 & -0.28 & 0.87 & 0.67 & -0.60 & -0.22 & 0 & -0 & -0.0001 & 0.18 & 0.16 & 0.07 & 0.03 \\ 
    \multicolumn{1}{l}{LEA} & -0.06 & -0.16 & -0.06 & -0.21 & -0.24 & -0.34 & 0.08 & 0.10 & 0.69 & 0.35 & -0.09 & 1 & 0.03 & 0.002 & -0.27 & -0.07 & 0.11 & 0.35 & 0.40 & 0 & -0 & 0 & 0.04 & 0.11 & -0.02 & 0.03 \\ 
    \hline 
    \hline \\[-1.8ex] 
    \end{longtable}
    \end{landscape}

I read multiple threads in this and other blogs, but can't find a solution. I am not using a figure or table environment, and I run the code many times (I read that using multicolumn it may take longer to produce the correct layout). Can anyone help me? Is maybe \hline confusing LaTeX?

5
  • longtable breaks between rows if you had lots lf lines it would break, it does not break between columns. Jan 2, 2016 at 18:44
  • Hi @DavidCarlisle, thank you for your comment. I modified my question to make it clearer: I would like it to break between columns: isn't it possible?
    – Vera
    Jan 2, 2016 at 18:47
  • Vera there is no particularly good automatic column breaker, certainly longtable won't help at all. Jan 2, 2016 at 18:50
  • Related question: Table and multi-page
    – Alan Munn
    Jan 2, 2016 at 19:12
  • Also tex.stackexchange.com/questions/21683/….
    – cfr
    Jan 2, 2016 at 22:23

1 Answer 1

2

longtable not relevant here unless you have more rows in the table.

the table is simply too wide, you can make it narrower, for example:

enter image description here

\documentclass[12pt]{scrreprt}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{dcolumn}

\newcommand\hd[1]{\multicolumn{1}{c}{\rotatebox{90}{#1}}}
\begin{document}
\begin{landscape}
        \tiny
\setlength\tabcolsep{.1pt}
    \begin{longtable}{@{\extracolsep{0pt}} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2}}
     \caption{Correlation matrix} 
     \label{tab:correl} 
    \\\hline 
    \hline \\[-1.8ex] 
    \hd{} & \hd{LEVEL\_B} & \hd{LEVEL\_W} & \hd{MPI} & \hd{EXP} & \hd{PAT} & \hd{INF} & \hd{PAC\_FSC} & \hd{L488} & \hd{PUBSEC} & \hd{PA\_EMP} & \hd{NET} & \hd{LEA} & \hd{UNEMP} & \hd{EDU} & \hd{CRIM} & \hd{WC\_CRIM} & \hd{TAXGAP} & \hd{NGO} & \hd{DIM} & \hd{INNO} & \hd{NO\_DEG} & \hd{LABOR} & \hd{ERDF} & \hd{PA\_CLIENT} & \hd{MARKET} & \hd{DIM\_LU} \\ 
    \hline \\[-1.8ex] 
    \multicolumn{1}{l}{LEVEL\_B} & 1 & 0.37 & 0.30 & -0.12 & 0.08 & 0.02 & 0.13 & 0.06 & -0.07 & 0.10 & 0.20 & -0.06 & 0.20 & 0.10 & 0.12 & 0.13 & 0.03 & -0.19 & -0.11 & -0.09 & 0.10 & -0.08 & -0.02 & 0.04 & 0.07 & 0.06 \\ 
    \multicolumn{1}{l}{LEVEL\_W} & 0.37 & 1 & 0.12 & 0.04 & 0.41 & 0.29 & -0.04 & -0.11 & -0.07 & 0.08 & -0.03 & -0.16 & -0.05 & 0.20 & 0.37 & -0.03 & -0.21 & -0.14 & -0.18 & -0.01 & 0.11 & -0.24 & -0.08 & -0.15 & 0.01 & 0.19 \\ 
    \multicolumn{1}{l}{MPI} & 0.30 & 0.12 & 1 & -0.39 & -0.10 & -0.17 & 0.34 & 0.43 & -0.11 & 0.19 & 0.62 & -0.06 & 0.60 & 0.13 & -0.002 & 0.52 & 0.37 & -0.49 & -0.19 & 0 & -0 & 0 & 0.22 & 0.11 & 0.02 & -0.002 \\ 
    \multicolumn{1}{l}{EXP} & -0.12 & 0.04 & -0.39 & 1 & 0.29 & 0.40 & -0.40 & -0.47 & -0.11 & -0.24 & -0.44 & -0.21 & -0.55 & -0.11 & 0.17 & -0.40 & -0.56 & 0.20 & -0.11 & 0 & -0 & 0 & -0.12 & -0.16 & -0.04 & -0.03 \\ 
    \multicolumn{1}{l}{PAT} & 0.08 & 0.41 & -0.10 & 0.29 & 1 & 0.59 & -0.28 & -0.36 & -0.09 & 0.11 & -0.33 & -0.24 & -0.39 & 0.32 & 0.69 & -0.32 & -0.53 & 0.05 & -0.30 & 0 & 0 & 0 & -0.08 & -0.12 & -0.06 & -0.05 \\ 
    \multicolumn{1}{l}{INF} & 0.02 & 0.29 & -0.17 & 0.40 & 0.59 & 1 & -0.38 & -0.56 & -0.15 & 0.06 & -0.45 & -0.34 & -0.55 & 0.26 & 0.70 & -0.44 & -0.61 & 0.10 & -0.27 & -0 & -0 & -0 & -0.11 & -0.17 & -0.04 & -0.07 \\ 
    \multicolumn{1}{l}{PAC\_FSC} & 0.13 & -0.04 & 0.34 & -0.40 & -0.28 & -0.38 & 1 & 0.52 & 0.04 & 0.28 & 0.57 & 0.08 & 0.64 & 0.07 & -0.28 & 0.44 & 0.38 & -0.35 & 0.02 & 0 & 0 & 0 & 0.12 & 0.16 & 0.03 & 0.02 \\ 
    \multicolumn{1}{l}{L488} & 0.06 & -0.11 & 0.43 & -0.47 & -0.36 & -0.56 & 0.52 & 1 & -0.05 & 0.18 & 0.74 & 0.10 & 0.76 & 0.09 & -0.46 & 0.68 & 0.68 & -0.47 & 0.04 & -0 & 0 & -0 & 0.20 & 0.22 & 0.04 & 0.04 \\ 
    \multicolumn{1}{l}{PUBSEC} & -0.07 & -0.07 & -0.11 & -0.11 & -0.09 & -0.15 & 0.04 & -0.05 & 1 & 0.40 & -0.22 & 0.69 & -0.15 & 0.04 & -0.16 & -0.20 & -0.11 & 0.58 & 0.40 & -0 & -0 & 0 & 0.01 & 0.11 & -0.06 & -0.0003 \\ 
    \multicolumn{1}{l}{PA\_EMP} & 0.10 & 0.08 & 0.19 & -0.24 & 0.11 & 0.06 & 0.28 & 0.18 & 0.40 & 1 & 0.13 & 0.35 & 0.18 & 0.45 & 0.05 & 0.14 & -0.06 & 0.15 & 0.03 & -0 & 0 & 0 & 0.10 & 0.16 & 0.002 & -0.02 \\ 
    \multicolumn{1}{l}{NET} & 0.20 & -0.03 & 0.62 & -0.44 & -0.33 & -0.45 & 0.57 & 0.74 & -0.22 & 0.13 & 1 & -0.09 & 0.86 & 0.03 & -0.28 & 0.87 & 0.67 & -0.60 & -0.22 & 0 & -0 & -0.0001 & 0.18 & 0.16 & 0.07 & 0.03 \\ 
    \multicolumn{1}{l}{LEA} & -0.06 & -0.16 & -0.06 & -0.21 & -0.24 & -0.34 & 0.08 & 0.10 & 0.69 & 0.35 & -0.09 & 1 & 0.03 & 0.002 & -0.27 & -0.07 & 0.11 & 0.35 & 0.40 & 0 & -0 & 0 & 0.04 & 0.11 & -0.02 & 0.03 \\ 
    \hline 
    \hline \\[-1.8ex] 
    \end{longtable}
    \end{landscape}

\end{document}

You must log in to answer this question.

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