表格:所有单元格的字体大小设置和 \arraystretch

表格:所有单元格的字体大小设置和 \arraystretch

我正在尝试创建单元格中字体大小较小的文本且行与行之间有较大间距的表格。

如果我\small在每个单元格中输入命令

\renewcommand{\arraystretch}{1.3}

可以工作,但是如果我尝试将其放在\small所有表中,它就不再起作用了。

有没有办法一次性为所有单元格设置小字体大小,同时保持行与行之间的较大空间?

以下是 MWE:

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\pagenumbering{gobble}
\usepackage[british,english]{babel}

\usepackage{tabulary}
\usepackage[flushleft]{threeparttable}
\renewcommand{\arraystretch}{1.3}
\usepackage{booktabs}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=period,format=hang,indention=0cm]{caption}
\captionsetup[table]{position=above, belowskip=4pt}

\begin{document}

%table with \small for all the table
\begin{table}[!h]
    \centering 
    \begin{threeparttable}[b]
        \caption{Table with \textbackslash{}small set once for all the cells}
        \small
            \begin{tabular}{@{}ll@{}}
                \toprule 
                \addlinespace
                        & Capital Elements\\
                \addlinespace
                \midrule
                Tier 1  & Paid-up share capital/common stock \\
                        & Disclosed reserves \\
                \addlinespace
                Tier 2  & Undisclosed reserves \\
                        & Asset revaluation reserves \\
                        & General provision/general loan-loss reserves \\
                        & Hybrid (debt/equity) capital instruments \\
                        & Subordinated debt \\
                \bottomrule
            \end{tabular}
        \par        
        \begin{tablenotes}[para,flushleft]
            \footnotesize{}\emph{Source}: BCBS (1988).
        \end{tablenotes}
    \end{threeparttable}
\end{table}

%table with \small at every cell            
\begin{table}[!h]
    \centering 
    \begin{threeparttable}[b]
        \caption{Table with \textbackslash{}small set at every cell}
        \begin{tabular}{@{}ll@{}}
        \toprule 
        \addlinespace
                            & {\small{}Capital Elements}\\
        \addlinespace
        \midrule
        {\small{}Tier 1}    & {\small{}Paid-up share capital/common stock}\\
                            & {\small{}Disclosed reserves}\\
        \addlinespace
        {\small{}Tier 2}    & {\small{}Undisclosed reserves}\\
                            & {\small{}Asset revaluation reserves}\\
                            & {\small{}General provision/general loan-loss reserves}\\
                            & {\small{}Hybrid (debt/equity) capital instruments}\\
                            & {\small{}Subordinated debt}\\
        \bottomrule
        \end{tabular}
        \begin{tablenotes}[para,flushleft]
            \footnotesize{}\emph{Source}: BCBS (1988).
        \end{tablenotes}
    \end{threeparttable}
\end{table}

\end{document}

输出结果如下:

在此处输入图片描述

答案1

这是正常的:的结果\arraystretch取决于\baselineskip,而这取决于字体大小。

\arraystretch您可以加载cellspace定义单元格与上方和下方单元格之间的最小垂直间距的包,而不必亲自玩了。

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\pagenumbering{gobble}
\usepackage[british,english]{babel}

\usepackage{tabulary}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=period,format=hang,indention=0cm]{caption}
\captionsetup[table]{position=above, belowskip=4pt}
\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}

 \begin{document}

%table with \small for all the table
\begin{table}[!h]
    \centering
    \begin{threeparttable}[b]
        \caption{Table with \textbackslash{}footnotesize set once for all the cells and \textbackslash{}arraystretch = 1}
        \small
            \begin{tabular}{@{}SlSl@{}}
                \toprule
                \addlinespace
                        & Capital Elements\\
                \addlinespace
                \midrule
                Tier 1 & Paid-up share capital/common stock \\
                        & Disclosed reserves \\
                \addlinespace
                Tier 2 & Undisclosed reserves \\
                        & Asset revaluation reserves \\
                        & General provision/general loan-loss reserves \\
                        & Hybrid (debt/equity) capital instruments \\
                        & Subordinated debt \\
                \bottomrule
            \end{tabular}
        \par
        \begin{tablenotes}[para,flushleft]
            \footnotesize{}\emph{Source}: BCBS (1988).
        \end{tablenotes}
    \end{threeparttable}
\end{table}

%table with \small at every cell
\begin{table}[!h]
    \centering
\renewcommand{\arraystretch}{1.3}
    \begin{threeparttable}[b]
        \caption{Table with \textbackslash{}small set at every cell and\\\textbackslash{}arraystretch = 1.3}
        \begin{tabular}{@{}ll@{}}
        \toprule
        \addlinespace
                            & {\small{}Capital Elements}\\
        \addlinespace
        \midrule
        {\small{}Tier 1} & {\small{}Paid-up share capital/common stock}\\
                            & {\small{}Disclosed reserves}\\
        \addlinespace
        {\small{}Tier 2} & {\small{}Undisclosed reserves}\\
                            & {\small{}Asset revaluation reserves}\\
                            & {\small{}General provision/general loan-loss reserves}\\
                            & {\small{}Hybrid (debt/equity) capital instruments}\\
                            & {\small{}Subordinated debt}\\
        \bottomrule
        \end{tabular}
        \begin{tablenotes}[para,flushleft]
            \footnotesize{}\emph{Source}: BCBS (1988).
        \end{tablenotes}
    \end{threeparttable}
\end{table}

\end{document} 

在此处输入图片描述

答案2

正如 @Zarko 和 @Bernard 已经指出的那样,\small在每个单元格的开头设置与应用于环境\small的整行不同tabular:即使单元格内容将以相同的大小排版,的值\baselineskip也会有所不同。具体来说,假设文档的主字体大小为,如果有效,则11pt值为,而如果有效,则\baselineskip值为。13.6pt\normalsize12pt\small

有没有办法\small一次性设置所有单元格的字体大小,同时保持行与行之间的较大空间?

为了弥补 中的差异\baselineskip,您可以将 的值增加\arraystretch13.6/12=1.1333 倍,对于 中的表,该值\small在全球范围内有效,即,\arraystretch将该表设置为 1.4733。以下屏幕截图显示这是正确的调整量。(请注意,我已将其用作>{\small}l右侧表格的列定义,这样我就不必\small在每个单元格的开头进行输入。)

在此处输入图片描述

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagenumbering{gobble}
\usepackage[british,english]{babel}

\usepackage{booktabs,array}
\usepackage[margin=10pt,font=small,
            labelfont=bf,labelsep=period,
            format=hang,indention=0cm]{caption}
\captionsetup[table]{position=above, belowskip=4pt}

\newcommand\tabinterior[1]{% table interior is common to both tables
\toprule 
\addlinespace
\multicolumn{2}{@{}l}{#1}\\
\addlinespace
\midrule
Tier 1  & Paid-up share capital \\
        & Disclosed reserves \\
\addlinespace
Tier 2  & Undisclosed reserves \\
        & Asset revaluation reserves \\
        & General provision/general \\
        & Hybrid (debt/equity) capital \\
        & Subordinated debt \\
\bottomrule}
\begin{document}


\begin{table}[!h]
\small
\renewcommand{\arraystretch}{1.4733}
\begin{tabular}[t]{@{} ll @{}}
\tabinterior{\textbackslash small global for entire table}
\end{tabular}
\normalsize % back to '11pt' as the main font size
\renewcommand{\arraystretch}{1.3} 
\begin{tabular}[t]{@{} *{2}{>{\small}l} @{}}
\tabinterior{\textbackslash small local to each cell}
\end{tabular}
\end{table}

\end{document}

相关内容