使用回忆录类将长表标题设置为单倍行距

使用回忆录类将长表标题设置为单倍行距

我在尝试解决这个问题时经历了一场噩梦。似乎使用 memoir 类的图形和表格的标准标题是单倍行距,但对于使用 longtable 包创建的表格,它们是双倍行距。我无法使用 caption + setspace 使它们成为单倍行距,因为 memoir 类不加载 setspace,而是使用自己的代码进行基线间距和缩放(据我所知)。我发现最有希望的帖子是这个: 长表标题间距

我认为它建议更改乳胶分布中的 longtable.sty 文件 - 添加 \singlespacing??? 如果我是正确的,我现在已经这样做了,但什么都没有改变,标题仍然是双倍行距。

任何建议都会受到热烈欢迎——这已经有好几天了。

谢谢。

编辑:这是 MWE

\documentclass[12pt,oneside]{memoir}

\usepackage{longtable}
\usepackage{lipsum}

\begin{document}


\OnehalfSpacing

\lipsum[1]

    \begin{table}[h]
        \centering
        \caption{Table very very very very very very very very very very very very very long caption}
        \begin{tabular}{llll}
            1 & 1 & 1 & 1\\
            1 & 1 & 1 & 1
        \end{tabular}
        \label{table}
    \end{table}

\setlength{\LTcapwidth}{\linewidth}
    \begin{longtable}{llll}
        \caption{Longtable very very very very very very very very very very very very very long caption} \\
        1 & 1 & 1 & 1\\
        1 & 1 & 1 & 1\\
        \label{longtable}
    \end{longtable}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{10pt}
    \begin{longtable}[htbp]{lcclcl}

        \caption[Specimen Collection]{Specimen information including species name, institution accession or record number, sex of specimen, host species name, year the specimen was collected, and location it was collected. Sex: F = Female, M = Male, j. = juvenile, t. = transitionary stage.}
        \label{table:museo} \\ \toprule

        \multicolumn{1}{c}{Species}  & \multicolumn{1}{c}{Acc./Record} & \multicolumn{1}{c}{Sex} & \multicolumn{1}{c}{Host}  & \multicolumn{1}{c}{Year Collected} & \multicolumn{1}{c}{Location} \\ \hline
    \end{longtable}


    \lipsum[2]

\end{document} 

您将在表格 2 和表格 3 中看到标题行距为 1.5,而使用普通表格时,表格 1 是单倍行距。我现在已改回 longtable.sty 文件,因为该解决方案无论如何都不起作用。

编辑:所有包

\usepackage{lineno}

\usepackage{amsmath,amsthm,amssymb,amsfonts}

\newtheorem{thm}{Theorem}
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition} 

\usepackage{microtype}

\usepackage[dvipsnames]{xcolor}


\makeatletter
\newcommand\GIANT{\@setfontsize\Huge{20}{0}}
\makeatother  

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\bfseries}{}{0pt}{\GIANT}

\usepackage[numbered]{bookmark}

\usepackage{url} 
\PassOptionsToPackage{hyphens,spaces,obeyspaces}{url}\usepackage{hyperref}

\usepackage{textcomp}

\usepackage{color, colortbl} 

\usepackage[final]{pdfpages}

\usepackage{adjustbox}

\usepackage{multirow}

\usepackage{graphicx}

\usepackage{blindtext}

\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault}

\usepackage[T1]{fontenc}

\usepackage[helvet]{sfmath}

\usepackage[left=3.5cm,right=2cm, bottom=2.5cm, headsep=40pt]{geometry}

\usepackage{siunitx,booktabs,array,calc}

%\usepackage{setspace} doesn't work with memoir???

\usepackage{caption}

\usepackage{longtable}

\usepackage{etoolbox}

\usepackage{lscape}

\usepackage{rotating}

\usepackage{natbib}
\newcommand\cites[1]{\citeauthor{#1}'s\ (\citeyear{#1})} %adds possessive citation \cites{}
\newcommand{\citeay}[1]{\citeauthor{#1}, \citeyear{#1}} % comman in citealt
\bibpunct[, ]{(}{)}{;}{a}{,}{,}

答案1

不错的 hack 1 (或‘hack-patch 1’)

\baselinestretch经过一番修改,我发现了一个(希望)更好的解决方案。我建议使用-command ,而不是进行操作\fontsize{<fontsize>}{<leading>}。它只是将字体大小重置为标题的字体大小(此处为 12 pt),并使用第二个参数创建单倍行距。LaTeX 通常设置 20% 的行距,因此正确的命令应该是\fontsize{12}{13.2}\selectfont}。但是,您可以使用 12 pt 或 12.5 pt 行距来压缩标题。

使用\fontsize-命令,您不需要设置可选的[Short caption]

此外,我建议定义一个简写,\sspace这样你就可以改变一个位置。也许这甚至应该被称为补丁,或者至少是“黑客补丁”或“补丁黑客”,因为我使用了字体命令:

在此处输入图片描述

\documentclass[12pt,oneside]{memoir}
\newcommand{\sspace}{\fontsize{12}{12}\selectfont} 

\usepackage{longtable}
%\usepackage{caption}
\usepackage{lipsum}

\begin{document}


\OnehalfSpacing

\lipsum[1]

    \begin{table}[h]
        \centering
        \caption{\sspace Table very very very very very very very very very very very very very long caption.}
        \begin{tabular}{llll}
            1 & 1 & 1 & 1\\
            1 & 1 & 1 & 1
        \end{tabular}
        \label{table}
    \end{table}

\setlength{\LTcapwidth}{\linewidth}
    \begin{longtable}{llll}
        \caption{\sspace Longtable very very very very very very very very very very very very very long caption.} \\
        1 & 1 & 1 & 1\\
        1 & 1 & 1 & 1\\
        \label{longtable}
    \end{longtable}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{10pt}
    \begin{longtable}[htbp]{lcclcl}

        \caption{\sspace Specimen information including species name, institution accession or record number, sex of specimen, host species name, year the specimen was collected, and location it was collected. Sex: F = Female, M = Male, j. = juvenile, t. = transitionary stage.}
        \label{table:museo} \\ \toprule

        \multicolumn{1}{c}{Species}  & \multicolumn{1}{c}{Acc./Record} & \multicolumn{1}{c}{Sex} & \multicolumn{1}{c}{Host}  & \multicolumn{1}{c}{Year Collected} & \multicolumn{1}{c}{Location} \\ \hline
    \end{longtable}


    \lipsum[2]

\end{document} 

粗暴的攻击 1

这是一个可行的粗略方法,添加\renewcommand\baselinestretch{1}\selectfont到标题中。出于某种原因,您必须设置可选的短标题 [长标题]:

在此处输入图片描述

\documentclass[12pt,oneside]{memoir}

\usepackage{longtable}
\usepackage{lipsum}

\begin{document}


\OnehalfSpacing

\lipsum[1]

    \begin{table}[h]
        \centering
        \caption{Table very very very very very very very very very very very very very long caption}
        \begin{tabular}{llll}
            1 & 1 & 1 & 1\\
            1 & 1 & 1 & 1
        \end{tabular}
        \label{table}
    \end{table}

\setlength{\LTcapwidth}{\linewidth}
    \begin{longtable}{llll}
        \caption[Long Caption]{\renewcommand\baselinestretch{1}\selectfont Longtable very very very very very very very very very very very very very long caption} \\
        1 & 1 & 1 & 1\\
        1 & 1 & 1 & 1\\
        \label{longtable}
    \end{longtable}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{10pt}
    \begin{longtable}[htbp]{lcclcl}

        \caption[Specimen Collection]{\renewcommand\baselinestretch{1}\selectfont Specimen information including species name, institution accession or record number, sex of specimen, host species name, year the specimen was collected, and location it was collected. Sex: F = Female, M = Male, j. = juvenile, t. = transitionary stage.}
        \label{table:museo} \\ \toprule

        \multicolumn{1}{c}{Species}  & \multicolumn{1}{c}{Acc./Record} & \multicolumn{1}{c}{Sex} & \multicolumn{1}{c}{Host}  & \multicolumn{1}{c}{Year Collected} & \multicolumn{1}{c}{Location} \\ \hline
    \end{longtable}


    \lipsum[2]

\end{document} 

答案2

以下修补程序\LT@makecaption在正确的位置使用正确的信息为您的 MWE 打补丁。问题是宏正在重新定义,这会删除补丁。如果我们修补\AtBeginDocument它应该可以工作,而且我们不会搜索,\sbox因为新定义不使用,\sbox但我们使用,因为这是围绕标题的\let第一个标记:\parbox

编辑:我稍微修改了答案,以便无论是否caption加载包都可以正常工作。如果您使用重新定义的其他包,它仍然可能会失败\LT@makecaption

\documentclass[12pt,oneside]{memoir}

\usepackage{longtable}
\usepackage{lipsum}
\usepackage{etoolbox}
%\usepackage{caption}

\makeatletter
\AtBeginDocument
  {%
    \@ifpackageloaded{caption}
      {%
        \patchcmd\LT@makecaption{\caption@@make}{\SingleSpacing\caption@@make}
      }
      {%
        \patchcmd\LT@makecaption{\let}{\SingleSpacing\let}
      }
      {}{\errmessage{patch failed!}}%
  }
\makeatother

\begin{document}

\OnehalfSpacing

\lipsum[1]

    \begin{table}[h]
        \centering
        \caption{Table very very very very very very very very very very very very very long caption}
        \begin{tabular}{llll}
            1 & 1 & 1 & 1\\
            1 & 1 & 1 & 1
        \end{tabular}
        \label{table}
    \end{table}

\setlength{\LTcapwidth}{\linewidth}
    \begin{longtable}{llll}
        \caption{Longtable very very very very very very very very very very very very very long caption} \\
        1 & 1 & 1 & 1\\
        1 & 1 & 1 & 1\\
        \label{longtable}
    \end{longtable}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{10pt}
    \begin{longtable}[htbp]{lcclcl}

        \caption[Specimen Collection]{Specimen information including species name, institution accession or record number, sex of specimen, host species name, year the specimen was collected, and location it was collected. Sex: F = Female, M = Male, j. = juvenile, t. = transitionary stage.}
        \label{table:museo} \\ \toprule

        \multicolumn{1}{c}{Species}  & \multicolumn{1}{c}{Acc./Record} & \multicolumn{1}{c}{Sex} & \multicolumn{1}{c}{Host}  & \multicolumn{1}{c}{Year Collected} & \multicolumn{1}{c}{Location} \\ \hline
    \end{longtable}


    \lipsum[2]

\end{document}

在此处输入图片描述

相关内容