문서 \baselinestretch를 테이블 캡션 및 메모로 복원하는 방법

문서 \baselinestretch를 테이블 캡션 및 메모로 복원하는 방법

한 줄 간격의 표가 필요한 두 줄 또는 한 줄 간격의 문서에서 표 캡션과 메모에 대한 문서 간격을 어떻게 유지할 수 있습니까?

apa6클래스를 사용하는 MWE(pandoc 템플릿에서 생성)에서 man클래스 옵션은 문서를 12pt로 설정하고 간격을 두 배로 설정합니다. setspace, etoolbox및 패키지를 사용하여 글꼴 크기와 줄 간격의 조합에서 찾은 caption스트레치 요소를 하드코딩하여 필요한 결과(표 캡션 위와 표 메모 아래의 간격을 무시)를 얻을 수 있었습니다 .1.655setspace.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}

관련 정보