3

I was putting my data into a table for one document and unfortunately, my table is too long to fit in an A4 format. The document is mandatory in vertical and I am not sure how to arrange this data without it does not look good. If someone has a suggestion that could keep the format and the type of table that I am using, I would be very thankful.

My code is the following:

         \begin{center}
                \hspace*{-5cm}
            \begin{tabular}{||c c c c c c c c c c||} 
                \hline
                Sample Nr. & PPV 9nm & PEDOT 20nm & $MoO_{3}$ 3nm  & P-TPD 10nm & PMMA 6 nm & PPP 20nm & PVK 20nm & TPBi 25nm & ZnO 25nm \\ [0.5ex] 
                \hline\hline
                1 & 25.95 & 40.83 & 28 & 94.50 & 24.44 & 30.22 & 25.54 & 26.45 & 36.43 \\ 
                \hline
                2 & 19.09 & 28.02 & 11.32 & 94.43 & 16.41 & 17.42 & 18.72 & 18.67 & 25.52\\
                \hline
                3 & 8.68 & 12.08 & 21.76 & 8.78 & 9.92 & 11.72 & 8.89 & 9.27 & 10.77 \\  [1ex] 
                \hline

                \hline
            \end{tabular}
        \end{center}

And as you might expect the table is too long for an A4 format and the table is cut and looks like this:

enter image description here

Do you have any suggestions to arrange all the data and can be easily understood?

Thanks for all your suggestions

Bernard
  • 271,350

2 Answers2

4

For the table you posted, the easiest way to accomplish this is transposition, as follows:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[version=4]{mhchem} 
\newcommand{\mc}[1]{\multicolumn1c{#1}}
\newcommand{\nm}[1]{\SI{#1}{\nano\meter}}
\begin{document}
     \begin{center}
        \begin{tabular}{lSSS}
        \toprule
            Sample Nr.       & \mc1  & \mc2  & \mc3  \\
        \midrule
            PPV \nm{9}       & 25.95 & 19.09 & 8.68  \\
            PEDOT \nm{20}    & 40.83 & 28.02 & 12.08 \\
            \ce{MoO3} \nm{3} & 28    & 11.32 & 21.76 \\
            P-TPD \nm{10}    & 94.5  & 94.43 & 8.78  \\
            PMMA \nm{6}      & 24.44 & 16.41 & 9.92  \\
            PPP \nm{20}      & 30.22 & 17.42 & 11.72 \\
            PVK \nm{20}      & 25.54 & 18.72 & 8.89  \\
            TPBi \nm{25}     & 26.45 & 18.67 & 9.27  \\
            ZnO \nm{25}      & 36.43 & 25.52 & 10.77 \\
        \bottomrule
        \end{tabular}
    \end{center}
\end{document}

enter image description here

I've made a few other changes as well:

  • the booktabs package is used to create a visually appealing table using \toprule, \midrule and \bottomrule.
  • the second to fourth column are formatted using the S column type from the siunitx package, which aligns numbers taking the decimal point into account. (For the sample numbers, this is changed to a c column using \multicolumn.)
  • the chemical compound MoO3 is typeset using \ce ("chemical expression", I think) from the very useful and versatile mhchem package. (For ZnO etc. it makes no difference, visually.)
  • \SI, again from situnitx, is used to typeset those nanometer figures. I've defined a shortcut, \nm, to avoid having to type \SI{...}{\nano\meter} all the time.

I hope that this helps!

If your full table contains many more samples, BTW, I would still suggest doing it this way, but splitting up the table and only putting a certain number of samples -- say, eight, or however many you can fit onto a page -- into each individual table.

There's a limit to how much information can be conveyed to the reader using a single table, and there's a point where a single large table -- as opposed to several smaller ones -- is no longer optimal.

chsk
  • 3,667
4

Here is my suggestion based on allowing line breaks in the column headers. For this, I used \thead from the makecell package.

enter image description here

Additionally, I also used booktabs for horizontal lines with improved spacing, siunitx for numbers and units, as well as for an ipmroved alignment of numbers inside of the table columns, as well as chemformula to correctly typeset chemical formulae.

Since there was no documentclass given in the original code, I guessed one. If the table still exceeds the linewidth in your document, feel free to adjust the font size, e.g. by commenting out \renewcommand{\theadfont}{\normalsize}, and by adding \small inside of table. If the table is still too wide, you could try to reduce the horizontal white space between the columns, for example by using something like \setlength{\tabcolsep}{4.5pt}.

\documentclass{article}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{chemformula}

\renewcommand{\theadfont}{\normalsize}

\begin{document}

\begin{table} \centering

\begin{tabular}{c *{9}{S[table-format=2.2]}} \toprule {\thead{Sample\ Nr.}} & {\thead{PPV\ \SI{9}{\nm}}} & {\thead{PEDOT\ \SI{20}{\nm}}} & {\thead{\ch{MoO_{3}}\ \SI{3}{\nm}}}
& {\thead{P-TPD\ \SI{10}{\nm}}} & {\thead{PMMA\ \SI{6}{\nm}}} & {\thead{PPP\ \SI{20}{\nm}}} & {\thead{PVK\ \SI{20}{\nm}}} & {\thead{TPBi\ \SI{25}{\nm}}} & {\thead{ZnO\ \SI{25}{\nm}}} \ \midrule 1 & 25.95 & 40.83 & 28 & 94.50 & 24.44 & 30.22 & 25.54 & 26.45 & 36.43 \ 2 & 19.09 & 28.02 & 11.32 & 94.43 & 16.41 & 17.42 & 18.72 & 18.67 & 25.52 \ 3 & 8.68 & 12.08 & 21.76 & 8.78 & 9.92 & 11.72 & 8.89 & 9.27 & 10.77 \ \bottomrule \end{tabular} \end{table}

\end{document}

leandriis
  • 62,593