如何调整表格中某一列的字体大小?

如何调整表格中某一列的字体大小?

我有这种桌子

在此处输入图片描述

我想让标题为正常大小,而标题下面的所有内容为较小字体。如何才能轻松完成此操作而无需复制粘贴\scalebox{0.7}{...}

代码

\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}

相关问题

  1. 更改特定列的字体大小但还有一些其他的包

答案1

一个选项包含两种新的列类型和\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}

在此处输入图片描述

也许在这里使用array会更好。

答案2

如果同一张表格中各列的字体大小明显不同,则会使表格非常不美观且难以阅读。对于您帖子中展示的表格,事实证明无需采用此类方法。相反,假设您使用的边距和页面大小合理,则只需适度减少列间空白(我认为节省空白比减少过多显示材料的字体大小更好),并将所有列中使用的字体大小线性减少 10%。

在下面的例子中,请注意我使用的是array环境而不是tabular环境,因为无论如何,表的大多数内容看起来都应该处于数学模式。

输出

\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}

答案3

您可以使用该makecell包。它定义了一个thead用于列头的命令,可以多行。您可以使用以下命令指定列头字体:

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

类似地,您可以用 指定间距theadset,用 指定垂直和水平对齐,\theadalign并修复几个参数。

有关详细信息,请参阅文档的§1.3。

相关内容