longtable caption(使其看起来像 LaTeX 类定义的表格标题)

longtable caption(使其看起来像 LaTeX 类定义的表格标题)

我有以下带有表格和长表的 MWE,我只希望长表标题看起来与表格标题完全一样,而不修改上面表格中的任何内容(仅长表)。

实际上,我在 .cls 文件中有表格标题设置,我不应该更改它们,它们看起来如下所示(完整的 .cls 文件可以在这里找到:http://www.biomedcentral.com/download/tex/bmc_article.zip):

% settings for table caption
\setattribute{floatcaption}    {size}{\footnotesize\bfseries\mathversion{bold}\raggedright}
\setattribute{floatcaptionname}{size}{\bfseries}

\setlength\abovecaptionskip{0\p@}
\setlength\belowcaptionskip{4\p@}

\long\def\@makecaption#1#2{
    \vskip\abovecaptionskip
    \parbox[t]{\hsize}{\floatcaption@size{\floatcaptionname@size #1}\hskip.5em #2\par}%
    \vskip\belowcaptionskip}


\def\@floatboxreset{%
        \reset@font
        \footnotesize
        \sffamily
        \@setminipage
        \centering
}

因此,我只想使长表标题看起来像 .cls 文件中指定的表格标题,但只在 .tex 文件中引入所需的更改。我不明白为什么 .cls 文件只影响表格标题而不影响长表标题,但如果我在序言中写入 \usepackage{caption},它会影响所有内容...我如何在某些特定标题(长表标题)中进行局部更改,以便它们看起来与 .cls 文件中指定的完全一样??

这是 MWE:

\documentclass[a4paper,12pt]{article}

\usepackage{multirow}
\renewcommand{\arraystretch}{2}
\usepackage{longtable}


\begin{document}

\section*{Tables}
\begin{table}[h!]
\caption{Sample table title. This is where the description of the table should go.}
      \begin{tabular}{cccc}
        \hline
           & B1  &B2   & B3\\ \hline
        A3 & ..  & .   & .\\ \hline
      \end{tabular}
\end{table}



\begin{longtable}{|c|c|c|c|}
\caption{Statistically significant Gene Ontology terms from enrichment tests for each gene class. Adjusted p-value < 0.01, N/A indicates no terms at this level of significance.}\\
\hline
    \textbf{Class}
    & \textbf{Ontology}
    & \textbf{Term}
    & \textbf{Adj. p-value}\\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continues from previous page}}\\
\hline
    \textbf{Class}
    & \textbf{Ontology}
    & \textbf{Term}
    & \textbf{Adj. p-value}\\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continues on next page}} \\
\endfoot
\hline
\endlastfoot


\multirow{8}{*}{\textbf{1}}
        & \multirow{2}{*}{\textbf{\textit{BP}}}
        & \textit{{\scriptsize positive regulation of cell migration}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize cell-cell adhesion}}
        & 6.10E-03\\
\cline{2-4}
        \multicolumn{1}{|c|}{}
        & \multirow{2}{*}{\textbf{\textit{CC}}}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{2-4}
        \multicolumn{1}{|c|}{}
        & \multirow{4}{*}{\textbf{\textit{MF}}}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\hline
\end{longtable}


\end{document}

答案1

bmc_article您可以使用包的语法复制类文件的(公认的不透明定义的)标题相关设置caption

\usepackage{caption}
\captionsetup{
   labelsep = space,
   justification = raggedright,
   font = {footnotesize,bf,singlespacing,sf},
   singlelinecheck=off,
   skip=4pt,
   position=top}

另外,你还应该设置

\setlength\LTcapwidth{\textwidth} % default value is 4in, I think

通过在序言中插入这些说明,“普通”table环境以及longtable环境的标题应该符合类文件规定的外观。

在此处输入图片描述

\documentclass[a4paper,12pt]{bmc_article}
\usepackage[T1]{fontenc} % to properly typeset the "<" symbol even though it's not in math mode
\usepackage{multirow}
\renewcommand{\arraystretch}{2}
\usepackage{longtable}
\setlength\LTcapwidth{\textwidth}

\usepackage{caption}
\captionsetup{
   labelsep = space,
   justification = raggedright,
   font = {footnotesize,bf,singlespacing,sf},
   singlelinecheck=off,
   skip=4pt,
   position=top}

\begin{document}
\section*{Tables}
\begin{table}[h!]
\caption{Sample table title. This is where the description of the table should go.}
      \begin{tabular}{cccc}
        \hline
           & B1  &B2   & B3\\ \hline
        A3 & ..  & .   & .\\ \hline
      \end{tabular}
\end{table}

\begin{longtable}{|c|c|c|c|}
\caption{Statistically significant Gene Ontology terms from enrichment tests for 
    each gene class. Adjusted \mbox{p-value} < 0.01, N/A indicates no terms at 
    this level of significance.}\\
\hline
    \textbf{Class}
    & \textbf{Ontology}
    & \textbf{Term}
    & \textbf{Adj. p-value}\\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continues from previous page}}\\
\hline
    \textbf{Class}
    & \textbf{Ontology}
    & \textbf{Term}
    & \textbf{Adj. p-value}\\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continues on next page}} \\
\endfoot
\hline
\endlastfoot

\multirow{8}{*}{\textbf{1}}
        & \multirow{2}{*}{\textbf{\textit{BP}}}
        & \textit{{\scriptsize positive regulation of cell migration}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize cell-cell adhesion}}
        & 6.10E-03\\
\cline{2-4}
        \multicolumn{1}{|c|}{}
        & \multirow{2}{*}{\textbf{\textit{CC}}}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{2-4}
        \multicolumn{1}{|c|}{}
        & \multirow{4}{*}{\textbf{\textit{MF}}}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\cline{3-4}
        \multicolumn{1}{|c|}{}
        & \multicolumn{1}{|c|}{}
        & \textit{{\scriptsize texttexttexttext}}
        & 2.20E-03\\
\hline
\end{longtable}
\end{document}

相关内容