在长表环境中调整文本大小而不调整标题大小

在长表环境中调整文本大小而不调整标题大小

我的文档中有多个长度不等的表格,加起来占用了大量空间。因此,我决定通过在环境\small启动之前tabular(环境内部table)和\caption命令之后使用命令来减小每个表中文本的大小,如第一个代码片段所示。

标准表:

\documentclass[draft, 12pt, a4paper, twoside, english]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}
\begin{document}

\lipsum[1]

\begin{table}[h]
    \centering
    \caption{Standard table example.}
    \vspace{0.5cm}
    \small
        \begin{tabular}{lllr}
        \toprule
        \multirow{2}{4em}{\slshape{Book}} & \multicolumn{2}{c}{\slshape{Timespan}} & \multirow{2}{4em}{\slshape{Pages}} \\
        \cmidrule{2-3}
        & \slshape{Start} & \slshape{End} & \\
        \midrule
        001 & October 1884 & March 1896 & 530 \\
        002 & March 1896 & January 1901 & 489 \\
        003 & January 1901 & July 1911 & 501 \\
        004 & July 1911 & April 1923 & 475 \\
        005 & April 1923 & December 1947 & 526 \\
        \bottomrule
        \end{tabular}
    \label{tab:st_example}
\end{table}

\lipsum[1]

\end{document}

然而,相同的解决方案似乎在该环境中不可能实现longtable,例如如下表所示。

表使用longtable环境

\documentclass[draft, 12pt, a4paper, twoside, english]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}
\begin{document}

\lipsum[1]

\begin{longtable}{lllr}
    \caption{Longtable example.} \\
    \label{tab:lt_example} \\
    
    \toprule
    \multirow{2}{4em}{\slshape{Book}} & \multicolumn{2}{c}{\slshape{Timespan}} & \multirow{2}{4em}{\slshape{Pages}} \\
    \cmidrule{2-3}
    & \slshape{Start} & \slshape{End} & \\
    \midrule
    \endfirsthead
    
    \multicolumn{4}{c}{{\tablename\thetable{}\itshape ... continues from the previous page}} \\
    \midrule
    \multirow{2}{4em}{\slshape{Book}} & \multicolumn{2}{c}{\slshape{Timespan}} & \multirow{2}{4em}{\slshape{Pages}} \\
    \cmidrule{2-3}
    & \slshape{Start} & \slshape{End} & \\
    \midrule
    \endhead

    \midrule
    \multicolumn{4}{c}{\itshape continues on the next page ...} \\
    \endfoot

    \bottomrule
    \endlastfoot
    
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
    001 & October 1884 & March 1896 & 530 \\
    002 & March 1896 & January 1901 & 489 \\
    003 & January 1901 & July 1911 & 501 \\
    004 & July 1911 & April 1923 & 475 \\
    005 & April 1923 & December 1947 & 526 \\
\end{longtable}

\lipsum[1]

\end{document}

我在网上搜索了各种建议,但没有一个适合我的情况。主要问题是我无法缩放字体而不缩放表格的标题。

2016 年,该软件包的作者longtable在回复另一位用户时写道:

对表格应用缩放总是令人生疑,所以实际上,longtable 的一个优点就是它根本不起作用。只需在表格前加上 \small 或 \tiny 或您需要的任何大小即可。– David Carlisle 2016 年 5 月 18 日 链接到主题

但是,通过将调整大小命令放在环境之前,标题不可避免地会发生改变。

是否有能力在第二个表中达到第一个表中所示的相同结果?(可能以一种稳健的方式)

提前致谢。

附言:我的表格样式可能还有待改进,欢迎提出任何建议!谢谢!

答案1

正如@JohnKormylo 在评论中建议的那样,您可以\small通过发出适当位置的指令来抵消对标题内容的影响\normalsize。为了实现这个想法,我建议您(a)caption在序言中加载包,(b)发出指令

\begingroup
\small % or '\tiny', or whatever
\captionsetup{font=normalsize}

\begin{longtable}(c)发出指令前

\endgroup 

紧接着。这样,和指令\end{longtable}的范围就仅限于所讨论的 。\small\captionsetup{font=normalsize}longtable

还请注意,\slshape是一个开关——类似于\itshape\bfseries\small——因此不是采用括号分隔的参数。写为{\slshape Hello World}\textsl{Hello World}


在此处输入图片描述

\documentclass[draft, 12pt, a4paper, twoside, english]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{caption}  % for \captionsetup directive
\usepackage{lipsum}   % filler text

\begin{document}

\lipsum[1][1-6]

\begingroup % limit the scope of the next two instructions
\small
\captionsetup{font=normalsize}

\begin{longtable}{@{} lrrc @{}}
    \caption{Longtable example.} 
    \label{tab:lt_example} \\
    
    \toprule
    \slshape Book 
    & \multicolumn{2}{c}{\slshape Timespan}
    & \slshape pp. \\
    \cmidrule(lr){2-3}
    & \multicolumn{1}{c}{\slshape Start}
    & \multicolumn{1}{c}{\slshape End} & \\
    \midrule
    \endfirsthead
    
    \multicolumn{4}{@{}l}{\tablename~\thetable,  continued} \\[0.75ex]
    \toprule
    \slshape Book 
    & \multicolumn{2}{c}{\slshape Timespan} 
    & \slshape pp. \\
    \cmidrule(lr){2-3}
    & \multicolumn{1}{c}{\slshape Start}
    & \multicolumn{1}{c}{\slshape End} & \\
    \midrule
    \endhead

    \midrule
    \multicolumn{4}{r@{}}{\itshape continues on next page} \\
    \endfoot

    \bottomrule
    \endlastfoot
    
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
    001 & Oct 1884 & Mar 1896 & 530 \\
    002 & Mar 1896 & Jan 1901 & 489 \\
    003 & Jan 1901 & Jul 1911 & 501 \\
    004 & Jul 1911 & Apr 1923 & 475 \\
    005 & Apr 1923 & Dec 1947 & 526 \\
\end{longtable}

\endgroup % matches the earlier \begingroup statement

\lipsum[2]

\end{document}

相关内容