3

I have this kind of table

enter image description here

where I would like to make the titles in normal size and all stuff under them in smaller font. How can I do it easily without copy-pasting \scalebox{0.7}{...}?

Code

\begin{tabular}{| l | c | c | c | c | c | c | c |}
    \hline
    Mlf             & A & $\text{A}_s$     & MM & $\text{MM}_s$ & Lower bounds & Upper bounds & Output\\
    \hline
    \scalebox{0.7}{$p_3p_1-p_3p_2$} & 3&3 & 3&3 & \scalebox{0.7}{$[1,0,0.2]$}  & \scalebox{0.7}{$[1,0.5,0.5]$} & 1\\
    \scalebox{0.7}{$-p_3p_1+p_3p_2$}    & 3&3 & 4&3 & \scalebox{0.7}{$[1,0,0.2]$}  & \scalebox{0.7}{$[1,0.5,0.5]$} & 0\\    
    \scalebox{0.7}{$p_3p_1-p_3p_2$} & 12&11 & 25&11 & \scalebox{0.7}{$[0.01,0.01,0.01]$}  & \scalebox{0.7}{$[0.03,0.03,0.03]$} & 0\\
    \scalebox{0.7}{$p_3p_1-p_3p_2$} & 6&5     & 6&5     &  \scalebox{0.7}{$[0.01,0.01,0.02]$}  & \scalebox{0.7}{$[0.03,0.03,0.02]$} & 0\\   
    \scalebox{0.7}{$p_3p_1-p_3p_2$} & 16&7    & 16&7    &  \scalebox{0.7}{$[0.02,0.01,0.01]$}  & \scalebox{0.7}{$[0.02,0.03,0.03]$} & 0 \\
    %\hline
    \scalebox{0.7}{$p_3p_1-p_3p_2+p_4p_3-p_2p_1$} & 29&25 & 31&21  & \scalebox{0.7}{$[0.01,0.01,0.01,0.01]$} & \scalebox{0.7}{$[0.03,0.03,0.03,0.03]$} & 0 \\
    \scalebox{0.7}{$-p_3p_1+p_3p_2-p_4p_3+p_2p_1$} & 12&15 & 29&19  & \scalebox{0.7}{$[0.01,0.01,0.01,0.01]$} & \scalebox{0.7}{$[0.03,0.03,0.03,0.03]$} & 0 \\    

    \scalebox{0.7}{$p_3p_1-p_3p_2+p_4p_3-p_2p_1+p_4p_1-p_4p_2$} & 29&29 & 31&13  & \scalebox{0.7}{$[0.01,0.01,0.01,0.01]$} & \scalebox{0.7}{$[0.03,0.03,0.03,0.03]$} & 0 \\
    \scalebox{0.7}{$-p_3p_1+p_3p_2-p_4p_3+p_2p_1-p_4p_1+p_4p_2$} & 6&13 & 21&13  & \scalebox{0.7}{$[0.01,0.01,0.01,0.01]$} & \scalebox{0.7}{$[0.03,0.03,0.03,0.03]$} & 0 \\

    \hline
\end{tabular}

Related questions

  1. change font size of particular column yet with some other package
hhh
  • 8,743

3 Answers3

3

One option with two new column types and \multicolumn:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\newcolumntype{S}{ >{$\scriptstyle}c<{$}}
\newcolumntype{s}{ >{$}c<{$}}

\begin{document}

\noindent\begin{tabular}{| >{$\scriptstyle}l<{$} | s | s | s | S | S | S | s | }
    \hline
    \multicolumn{1}{|c|}{Mlf} & \multicolumn{1}{c|}{A} & \multicolumn{1}{c|}{A$_s$} & \multicolumn{1}{c|}{MM} & \multicolumn{1}{c|}{MM$_s$} & \multicolumn{1}{c|}{Lower bounds} & \multicolumn{1}{c|}{Upper bounds} & \multicolumn{1}{c|}{Output} \\
    \hline
    p_3p_1-p_3p_2 & 3&3 & 3&3 & [1,0,0.2]  & [1,0.5,0.5] & 1  \\
    -p_3p_1+p_3p_2    & 3&3 & 4&3 & [1,0,0.2]  & [1,0.5,0.5] & 0\\    
    p_3p_1-p_3p_2 & 12&11 & 25&11 & [0.01,0.01,0.01]  & [0.03,0.03,0.03] & 0\\
    p_3p_1-p_3p_2 & 6&5     & 6&5     &  [0.01,0.01,0.02]  & [0.03,0.03,0.02] & 0\\   
    p_3p_1-p_3p_2 & 16&7    & 16&7    &  [0.02,0.01,0.01]  & [0.02,0.03,0.03] & 0 \\
    \hline
\end{tabular}

\end{document}

enter image description here

Perhaps using an array would even be better here.

Gonzalo Medina
  • 505,128
2

Having noticeably different font sizes across columns in one and the same table tends to render the table very unappealing and difficult to read. For the table that's presented in your posting, it turns that one needn't resort to such methods. Instead, assuming you're using a reasonable margin and page size, all that's needed is a moderate reduction of the intercolumn whitespace -- I think it's better to economize on whitespace than to reduce the fontsize of the material that is shown excessively -- and a 10% linear reduction in the font size used in all columns.

In the example below, note that I use an array environment instead of a tabular environment since most of the table's contents appear like they should be in math mode anyway.

output

\documentclass{article}

\usepackage[margin = 1in]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}

\begin{document}

\hrule % to illustrate width of text block

\medskip

\begingroup % keep the following instructions local to the table 
\setlength{\arraycolsep}{3pt} % default value: 5pt
\small  % 10% reduction in font size
\noindent
$\begin{array}{@{} l *{7}{c} @{}}
    \hline
    \text{Mlf}                                 & A  & A_s & \text{MM} & \text{MM}_s & \text{Lower bounds}   & \text{Upper bounds}   & \text{Output} \\
    \hline
     p_3p_1-p_3p_2                             &  3 &  3  &  3        &  3          & [1,0,0.2]             & [1,0.5,0.5]           & 1             \\
    -p_3p_1+p_3p_2                             &  3 &  3  &  4        &  3          & [1,0,0.2]             & [1,0.5,0.5]           & 0             \\
     p_3p_1-p_3p_2                             & 12 & 11  & 25        & 11          & [0.01,0.01,0.01]      & [0.03,0.03,0.03]      & 0             \\
     p_3p_1-p_3p_2                             &  6 &  5  &  6        &  5          & [0.01,0.01,0.02]      & [0.03,0.03,0.02]      & 0             \\
     p_3p_1-p_3p_2                             & 16 &  7  & 16        &  7          & [0.02,0.01,0.01]      & [0.02,0.03,0.03]      & 0             \\
    %\hline
     p_3p_1-p_3p_2+p_4p_3-p_2p_1               & 29 & 25  & 31        & 21          & [0.01,0.01,0.01,0.01] & [0.03,0.03,0.03,0.03] & 0             \\
    -p_3p_1+p_3p_2-p_4p_3+p_2p_1               & 12 & 15  & 29        & 19          & [0.01,0.01,0.01,0.01] & [0.03,0.03,0.03,0.03] & 0             \\
     p_3p_1-p_3p_2+p_4p_3-p_2p_1+p_4p_1-p_4p_2 & 29 & 29  & 31        & 13          & [0.01,0.01,0.01,0.01] & [0.03,0.03,0.03,0.03] & 0             \\
    -p_3p_1+p_3p_2-p_4p_3+p_2p_1-p_4p_1+p_4p_2 &  6 & 13  & 21        & 13          & [0.01,0.01,0.01,0.01] & [0.03,0.03,0.03,0.03] & 0             \\
    \hline
\end{array}$
\endgroup

\end{document}
Mico
  • 506,678
0

You might use the makecell package. It defines a thead command for heads of columns, which can be multilined. You can specify the head font with, say,

\renewcommand\theadfont{\normalsize\bfseries\boldmath}

Similarly, you can specify spacing with theadset, vertical and horizontal alignment with \theadalignand fix a couple of parameters.

See §1.3 of the documentation for details.

Bernard
  • 271,350