tables,alignment,vertical – How to Change Text and Number Size in LaTeX Tables

alignmenttablesvertical

I am compiling the following table for my thesis. Currently, all the font sizes in this table are size 12.

Image

I am trying to achieve the following:

(1) Set the column containing Mean, Median, Standard deviation, IQR and Skewness to font size 10.

(2) Set the row containing the elements C, O, Na, Mg, Al, Si, K, Ca and Fe to font size 10.

(3) Decrease all numerical values in the table to font size 9.

(4) Vertically align the caption "Summary statistics of combined S7, S8 and S9…" in the current cell, WITHOUT decreasing the cell height. I need this cell size to remain the same as shown in the figure.

All forums I have searched have tables with the same table cell and font size. Please help.

I made this table from the code below:


\documentclass[12pt]{article}


\usepackage{fullpage}





\usepackage[left=3cm, right=3cm, top=3cm, bottom = 3cm]{geometry} 


\usepackage{amsmath, amsfonts, amssymb}

\linespread{1.25} 

\usepackage{graphicx}

\usepackage{caption}

\usepackage{subcaption}

\usepackage[table,xcdraw]{xcolor}

\usepackage[font=scriptsize,labelfont=bf]{caption} 

\begin{document}
\begin{table}[]
\centering
\caption{Summary statistics of combined dust composition wt\% for S7, S8 and S9 }
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{10}{|c|}{\cellcolor[HTML]{F8FF00}\textbf{\begin{tabular}[c]{@{}c@{}}Summary Statistics of combined S7, S8 and S9 (dust composition wt\%)\end{tabular}}}                                                                                                                                                                  \\ [3ex] \hline
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{C} & \multicolumn{1}{c|}{O} & \multicolumn{1}{c|}{Na} & \multicolumn{1}{c|}{Mg} & \multicolumn{1}{c|}{Al} & \multicolumn{1}{c|}{Si} & \multicolumn{1}{c|}{K} & \multicolumn{1}{c|}{Ca} & \multicolumn{1}{c|}{Fe} \\ \hline
Mean                   & 42.53                  & 36.08                  & 0.10                    & 0.86                    & 3.85                    & 8.48                    & 1.19                   & 3.77                    & 2.40                    \\ \hline
Median                 & 48.55                  & 32.25                  & 0.00                    & 0.70                    & 3.26                    & 7.15                    & 0.91                   & 2.45                    & 1.98                    \\ \hline
Standard Deviation     & 18.20                  & 9.49                   & 0.13                    & 0.66                    & 2.34                    & 4.70                    & 0.92                   & 3.40                    & 1.87                    \\ \hline
IQR                    & 18.29                  & 13.03                  & 0.18                    & 0.43                    & 1.74                    & 3.50                    & 0.66                   & 3.80                    & 1.36                    \\ \hline
Skewness               & -1.37                  & 0.83                   & 2.59                    & 3.51                    & 2.01                    & 1.81                    & 2.51                   & 1.47                    & 2.49                    \\ \hline
\end{tabular}
\end{table}
\end{document}

Best Answer

Your demands aren't entirely clear, so see if the following suggestion gives what you after:

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage[font=scriptsize,
            labelfont=bf]{caption}
\usepackage[xcdraw]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}



\begin{document}
\begin{table}[ht]
\fontsize{10}{12}\selectfont
\centering
\caption{Summary statistics of combined dust composition wt\% for S7, S8 and S9 }
\begin{tblr}{hlines, vlines,
             colspec = {l *{2}{S[table-format=-1.2]} *{7}{S[table-format=1.2]}},
             column{1} = {font=\bfseries},
             column{2-Z}={font=\fontsize{9}{11}\selectfont},
             row{1} = {bg=yellow!30, font=\bfseries, ht=6ex},
             row{2} = {font=\bfseries},
             hspan=minimal}
\SetCell[c=10]{c} Statistics of combined S7, S8 and S9 (dust composition wt\%)
                    &         &         &          &          &          &          &         &          &          \\                                                                                                                                                             
                    & {{{C}}} & {{{O}}} & {{{Na}}} & {{{Mg}}} & {{{Al}}} & {{{Si}}} & {{{K}}} & {{{Ca}}} & {{{Fe}}} \\
Mean                & 42.53   & 36.08   & 0.10     & 0.86     & 3.85     & 8.48     & 1.19    & 3.77     & 2.40     \\
Median              & 48.55   & 32.25   & 0.00     & 0.70     & 3.26     & 7.15     & 0.91    & 2.45     & 1.98     \\
Standard Deviation  & 18.20   & 9.49    & 0.13     & 0.66     & 2.34     & 4.70     & 0.92    & 3.40     & 1.87     \\
IQR                 & 18.29   & 13.03   & 0.18     & 0.43     & 1.74     & 3.50     & 0.66    & 3.80     & 1.36     \\     
Skewness            & -1.37   & 0.83    & 2.59     & 3.51     & 2.01     & 1.81     & 2.51    & 1.47     & 2.49     \\    
\end{tblr}
    \end{table}
\end{document}

In above MWE is used (relatively) new table package tabularray. Columns are S type defined in siunitx package (in MWE loaded by `tabularray library), font size is determined as you like to have.

enter image description here

Related Question