如果文档的行距为双倍或半倍,而要求表格的行距为单倍,那么如何保留表格标题和注释的文档间距?
apa6
在使用类的 MWE(由 pandoc 模板生成)中,man
类选项将文档设置为 12pt 并设置双倍行距。通过使用setspace
、etoolbox
和caption
包,我能够通过在 处硬编码拉伸因子来实现所需的结果(忽略表格标题上方和表格注释下方的间距)1.655
,我在 中找到了setspace.sty
这种字体大小和行距组合。
但是,我正在寻找一个通用的解决方案,能够将表格标题和注释的行距恢复为\baselinestretch
文档开头的值。(即,无论正文行距是多少,都会应用于表格标题和注释,而不管表格行的行距是多少)。
\documentclass[man,floatsintext,noextraspace,longtable,nofontenc,nolmodern,nosf]{apa6}
% man class option sets entire document at 12pt and with double spacing
\usepackage{lipsum} % only for MWE
% \usepackage{longtable,threeparttable} % loaded by apa6
% \usepackage{etoolbox} % loaded by apa6
% \usepackage{caption} % loaded by apa6
\usepackage{setspace}
% single spaced tables excluding caption and table notes (set by pandoc variable)
\AtBeginEnvironment{longtable}{\singlespacing}
% NEED TO REPLACE: both hardcoded 1.655 values (double spacing at 12pt)
% with the \baselinestretch at the beginning of the document
\captionsetup{font={stretch=1.655}}
\AtBeginEnvironment{tablenotes}{\setstretch{1.655}}
\title{Full Title}
\author{The Author}
\shorttitle{Short Title}
\affiliation{The Institute}
\begin{document}
\maketitle
\lipsum[1]
\begin{threeparttable}
% start of pandoc generated table
\begin{longtable}[]{@{}ccc@{}}
\caption{Advantages of Various Fruits}\tabularnewline
\toprule
\begin{minipage}[b]{0.20\columnwidth}\centering
Fruit\strut
\end{minipage} & \begin{minipage}[b]{0.24\columnwidth}\centering
Price\strut
\end{minipage} & \begin{minipage}[b]{0.32\columnwidth}\centering
Advantages\tabfnm{a}\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.20\columnwidth}\centering
Fruit\strut
\end{minipage} & \begin{minipage}[b]{0.24\columnwidth}\centering
Price\strut
\end{minipage} & \begin{minipage}[b]{0.32\columnwidth}\centering
Advantages\tabfnm{a}\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.20\columnwidth}\centering
Bananas\strut
\end{minipage} & \begin{minipage}[t]{0.24\columnwidth}\centering
\$1.34\tabfnm{*}\strut
\end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\centering
Built-in wrapper
and bright colour\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.20\columnwidth}\centering
Oranges\strut
\end{minipage} & \begin{minipage}[t]{0.24\columnwidth}\centering
\$2.10\tabfnm{**}\strut
\end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\centering
Cures scurvy\tabfnm{b}
and tastes great\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}
% end of pandoc generated table
\begin{tablenotes}
\textit{Note.} A general note.
\tabfnt{a}{Specific note a.}
\tabfnt{b}{Specific note b.}
\tabfnt{*}{Probability note p < .05.}
\tabfnt{**}{Probability note p < .01.}
\end{tablenotes}
\end{threeparttable}
\lipsum[2]
\end{document}
答案1
以下解决方案保存文档\baselinestretch
并恢复已保存的\baselinestretch
标题和表格注释。
\documentclass[man,floatsintext,noextraspace,longtable,nofontenc,nolmodern,nosf]{apa6}
% man class option sets entire document at 12pt and with double spacing
\usepackage{lipsum} % only for MWE
% \usepackage{longtable,threeparttable} % loaded by apa6
% \usepackage{etoolbox} % loaded by apa6
% \usepackage{caption} % loaded by apa6
\usepackage{setspace}
% single spaced tables excluding caption and table notes (set by pandoc variable)
\AtBeginEnvironment{longtable}{\singlespacing}
% save baselinestretch
\AtBeginDocument{\let\savedbaselinestretch\baselinestretch}
% restore saved baselinestretch
\captionsetup{font={stretch=\savedbaselinestretch}}
\AtBeginEnvironment{tablenotes}{\setstretch{\savedbaselinestretch}}
\AtEndEnvironment{tablenotes}{\setstretch{\savedbaselinestretch}}
\title{Full Title}
\author{The Author}
\shorttitle{Short Title}
\affiliation{The Institute}
\begin{document}
\maketitle
\lipsum[1]
\begin{threeparttable}
% start of pandoc generated table
\begin{longtable}[]{@{}ccc@{}}
\caption{Advantages of Various Fruits}\tabularnewline
\toprule
\begin{minipage}[b]{0.20\columnwidth}\centering
Fruit\strut
\end{minipage} & \begin{minipage}[b]{0.24\columnwidth}\centering
Price\strut
\end{minipage} & \begin{minipage}[b]{0.32\columnwidth}\centering
Advantages\tabfnm{a}\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.20\columnwidth}\centering
Fruit\strut
\end{minipage} & \begin{minipage}[b]{0.24\columnwidth}\centering
Price\strut
\end{minipage} & \begin{minipage}[b]{0.32\columnwidth}\centering
Advantages\tabfnm{a}\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.20\columnwidth}\centering
Bananas\strut
\end{minipage} & \begin{minipage}[t]{0.24\columnwidth}\centering
\$1.34\tabfnm{*}\strut
\end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\centering
Built-in wrapper
and bright colour\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.20\columnwidth}\centering
Oranges\strut
\end{minipage} & \begin{minipage}[t]{0.24\columnwidth}\centering
\$2.10\tabfnm{**}\strut
\end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\centering
Cures scurvy\tabfnm{b}
and tastes great\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}
% end of pandoc generated table
\begin{tablenotes}
\textit{Note.} A general note.
\tabfnt{a}{Specific note a.}
\tabfnt{b}{Specific note b.}
\tabfnt{*}{Probability note p < .05.}
\tabfnt{**}{Probability note p < .01.}
\end{tablenotes}
\end{threeparttable}
\lipsum[2]
\end{document}