1

enter image description hereenter image description hereI managed to break my extra wide table using the hints provided here: Column-wise break of extra wide tables.

As one can see, there are a lot of empty cells in the second part of the table. So I do not want to display those empty rows in the second part. Any ideas on how I could solve the problem?

\documentclass[a4paper]{article}
\usepackage{tabularx}
\usepackage{array}
\def\widesplit#1{%
\clearpage
\def\row##1##2{##1}%
#1%
\def\row##1##2{##2}%
#1%
}
\begin{document}
\widesplit{%
\begin{tabularx}{\textwidth}{l*{13}{c}}
\hline
          &\multicolumn{11}{c}{} \\
\row
 {         &   A&  B&     C&     D&   E&   F& G}{&   H& I& J& K}\\
\hline
A 
\row
{   &        1&    &    &    &    &   &   }{    &  &     &    & } \\
B
\row
{  &    0.779&        1&  &  &  &   &    }{ &  &     &     &   } \\
C
\row
{     &    0.511&    0.384&        1&         &         &         &        }{ &         &         &         &      } \\
D
\row
{      &    0.327&    0.310&    0.618&        1&         &         &       }{  &         &         &         &      } \\
E
\row
{    &   0.0722&   0.0938&    0.157&    0.259&        1&         &        }{ &         &         &         &      } \\
F
\row
{      &   0.0108&   0.0141&  -0.0342&    0.117&   0.0654&        1&    }{ &         &         &         &        } \\
G
\row
{ &    0.429&    0.339&    0.535&    0.233&   0.0932&  -0.0283&        1}{&         &         &      &        } \\
H
\row
{    &   -0.404&   -0.355&   -0.314&   -0.267&   0.0820&  -0.0418&   -0.201}{&        1&         &         &        } \\
I
\row
{     &  -0.0834&  -0.0971&   -0.319&   -0.212&  -0.0749&   0.0505&   -0.124}{&   0.0476&        1&     &  } \\
J
\row
{&   -0.802&   -0.553&   -0.681&   -0.335&    0.138&   0.0799&   -0.342}{&    0.434&    0.191&     1& } \\
K
\row
{&    0.786&    0.602&    0.575&    0.287& -0.00758&  -0.0450&    0.336}{&   -0.400&   -0.169&   -0.933&        1}\\
\hline
\end{tabularx}
}
\end{document}
JoMo
  • 21
  • not printing the rows would be really weird, the idea of splitting the rows that way is that on a 2-page spread it looks like a single table, if you omit some rows the two halves do not line up. – David Carlisle May 11 '18 at 13:13
  • It might sound weird, but it is a correlation table and it is quite common to break the table and not display the empty cells in the second part. That is what stata (econometric program) is giving in its output window for instance (see picture added). – JoMo May 11 '18 at 15:54
  • If the right hand side rows are unrelated to the left hand side of the same row why input it as a table with that many columns rather than as two tables? (als I would never use tabularx for numeric data it is designed to adjust line breaking within cells and there is no linebreaking here) but anyway if I understand you correctly move all the \\ to inside (both) of the {} groups but use {} for the empty ones so: { & A& B& C& D& E& F& G\\}{& H& I& J& K\\} but { & 0.779& 1& & & & & \\ }{} – David Carlisle May 11 '18 at 16:00
  • Thanks for this hint. I just tried it , but what happens is that in the second part of the table, in the first row A B C D E F G H just appear next to each other. So I would like to suppress A to G. See second picture in the question. – JoMo May 11 '18 at 16:29
  • but in the second table you should throw away the first {} of every row so why is ABC... getting printed? – David Carlisle May 11 '18 at 16:34
  • I deleted them starting from row H. But this breaks the code and LaTex TexMaker is not doing anything anymore. – JoMo May 11 '18 at 17:42

1 Answers1

1

I assume you are looking for something like this, I would use tabular rather than over-stretch the table to \textwidth but I left it stretched here (using tabular* as using tabularx with no X columns does nothing useful. I would also use decimal aligned columns (dcolumn or siunitx packages rather than centred, however this should get you started.

enter image description here

\documentclass[a4paper]{article}
\usepackage{tabularx}
\usepackage{array}
\def\widesplit#1{%
\clearpage
\def\row##1##2##3{\ifx\relax##2\relax\else##1##2\fi}%
#1%
\def\row##1##2##3{\ifx\relax##3\relax\else##1##3\fi}%
#1%
}
\begin{document}
\centering
\widesplit{%
\begin{tabular*}{\textwidth}{!{\extracolsep{\fill}}l*{13}{c}}
\hline
\row {}
 {         &   A&  B&     C&     D&   E&   F& G \\}{&   H& I& J& K\\}
\hline
\row A
{   &        1&    &    &    &    &   &    \\}{}
\row B
{  &    0.779&        1&  &  &  &   &     \\}{}
\row C
{     &    0.511&    0.384&        1&         &         &         &         \\}{}
\row D
{      &    0.327&    0.310&    0.618&        1&         &         &        \\}{}
\row E
{    &   0.0722&   0.0938&    0.157&    0.259&        1&         &         \\}{}
\row F
{      &   0.0108&   0.0141&  -0.0342&    0.117&   0.0654&        1&     \\}{}
\row G
{ &    0.429&    0.339&    0.535&    0.233&   0.0932&  -0.0283&        1 \\}{}
\row H
{    &   -0.404&   -0.355&   -0.314&   -0.267&   0.0820&  -0.0418&   -0.201 \\}{}
\row I
{     &  -0.0834&  -0.0971&   -0.319&   -0.212&  -0.0749&   0.0505&   -0.124 \\}{&   0.0476&        1&     &  \\}
\row J
{&   -0.802&   -0.553&   -0.681&   -0.335&    0.138&   0.0799&   -0.342 \\}{&    0.434&    0.191&     1& \\}
\row K
{&    0.786&    0.602&    0.575&    0.287& -0.00758&  -0.0450&    0.336 \\}{&   -0.400&   -0.169&   -0.933&        1\\}
\hline
\end{tabular*}
}
\end{document}
David Carlisle
  • 757,742