1

I have the following MWE with a table and a longtable, and I just want that the longtable caption looks exactly as the table caption without modifying anything from the table above (just the longtable).

I actually have the table caption settings in a .cls file that I am not supposed to change, and they look like the following (the complete .cls file can be found here: 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
}

So I just want to make the longtable caption look like the table caption as specified in the .cls file, but introducing the required changes in the .tex file only. I do not understand why the .cls file affects only table captions but not longtable captions, but if I write \usepackage{caption} in the preamble, it affects everything... How can I make local changes in certain specific captions (the longtable ones), so that they look exactly as specified in the .cls file??

This is the 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}
3
  • 1
    longtable does by default use the standard caption setting (you may want to set LTcapwidth to textewidt) your initial fragment suggests you are using some caption formatting package (\setattribute{floatcaption} isn't a standard command) which may or may not apply to longtable, depending how it's defined. You probably ought to include that inn the MWE Jan 27, 2014 at 10:22
  • What I do not understand is why the .cls file affects only table captions but not longtable captions, but if I write \usepackage{caption} in the preamble, it affects everything... How can I make the .cls file affect also the longtable captions, or how can I make local changes in certain specific captions (the longtable ones), so that they look exactly as specified in the .cls file?? The complete .cls file can be found here biomedcentral.com/download/tex/bmc_article.zip
    – DaniCee
    Jan 27, 2014 at 20:29
  • caption package explicitly picks up the longtable caption hook and includes it in its settings. No sorry I'm not downloading the zip file:-) Jan 27, 2014 at 21:30

1 Answer 1

2

You could replicate the (admittedly opaquely defined) caption-related settings of the bmc_article class file, using the syntax of the caption package:

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

Separately, you should also set

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

With these instructions inserted in the preamble, the captions of "ordinary" table environments as well as of longtable environments should conform to the look-and-feel of what's prescribed by the class file.

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .