1

I have the following code, however the table does not fit on 1 page as it is a 18x18 table. I tried doing it in landscape, but then it still does not fit on one page. Also I tried to make the font smaller, but this doesn't get the desired result also. My code is the following:

\begin{landscape}
\begin{scriptsize}
\begin{table}[H] \centering 
  \caption{18x18 correlation matrix} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lcccccccccccccccccc}
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
.....
\hline \\[-1.8ex] 
\end{tabular}
\end{table}
\end{scriptsize}
\end{landscape}
  • 2
    remove the \begin{scriptsize} it does nothing as it is outside the table, use \scriptsize or \tiny or whatever font size you need inside \begin{table}, but if the font really has to be that small have a thought for your readers and consider using a larger font but showing the data over two or three pages. – David Carlisle Jan 25 at 9:39
  • 1
    \hline should never be followed by \\ that is adding spurious enmpty rows which is why you are needing negative space, delete all those \\[..] – David Carlisle Jan 25 at 9:40
  • How wide and tall is text block? – Mico Jan 25 at 9:43
  • Clear. Thank you for your response. 1 more question about the \tiny inside \begin{table} - how do you mean this exactly? – Famke Jan 25 at 9:44
  • @ Mico: the text has a width of 0.0000 – Famke Jan 25 at 9:45
1

enter image description here

\documentclass[a4paper]{article}
\usepackage[pdftex]{lscape}
\begin{document}

\begin{landscape}
\footnotesize
\setlength\arraycolsep{4pt}
\[
  \begin{array}{*{18}r}
1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000
  \end{array}
\]
\end{landscape}
\end{document}
| improve this answer | |
  • This helped tremendously, exactly what I needed. I just added the headings for both the rows and columns. Any idea how to specify the border for the first column (in which the headings for the rows are stated)? – Famke Jan 26 at 15:19
  • @Famke change *{18}r by l|*{18}r to have an extra l column at the start separated by a vertical rul – David Carlisle Jan 26 at 15:27
  • Thank you SO much for your help!!! – Famke Jan 26 at 15:50
0

With due apologies to @DavidCarlisle I could not resist adding color !!

enter image description here

\documentclass{article}
\usepackage{booktabs}  
\usepackage[table]{xcolor}
\makeatletter
\newcommand*{\minuscellcolor}{}
\def\minuscellcolor\ignorespaces{%
  % \ignorespaces not really needed, because \@ifnextchar gobbles spaces
  \@ifnextchar1{\cellcolor{blue!20}}{}%
}
\newcolumntype{C}{>{\minuscellcolor}c}
\makeatother
\begin{document}  
\begin{table}  
  \footnotesize
  \setlength\tabcolsep{1pt}
  \centering
  \begin{tabular}{CCCCCCCCCCCCCCCCCC}  
    \toprule  
1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000&0.0000\\
0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&0.0000&1.0000\\
  \bottomrule
  \end{tabular}
\end{table}
\end{document}
| improve this answer | |
  • 1
    colour is OK but a correlation matrix is math, it should be array not tabular. – David Carlisle Jan 25 at 14:11

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.