ドキュメントの \baselinestretch を表のキャプションと注釈に復元する方法

ドキュメントの \baselinestretch を表のキャプションと注釈に復元する方法

1 行間隔の表が必要な 2 行または 1/2 行間隔の文書の場合、表のキャプションと注釈の文書間隔を維持するにはどうすればよいでしょうか。

apa6クラスを使用する MWE (Pandoc テンプレートから生成) では、manクラス オプションによってドキュメントが 12pt に設定され、行間が 2 倍になります。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}

関連情報