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.
\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}
I just ran into the same issue. (It's really annoying when trying to produce print-quality preprint versions of the paper.) Poking around in pnastwo.cls, I found the following fix:
Find the first line in pnastwo.cls which says
\ifx\@captype\xtable
Change this to
\ifx\@captype\table
Alternatively, if you don't want to touch the class file, you can
put the following into the preamble of your document:
% Fix wierd behavior which prevents table captions from appearing for
% tables in the body of the article
\makeatletter
\long\def\@makecaption#1#2{%
\ifx\@captype\table
\let\currtabcaption\relax
\gdef\currtabcaption{
\tabnumfont\relax #1. \tabtextfont\relax#2\par
\vskip\belowcaptionskip
}
\else
\vskip\abovecaptionskip
\sbox\@tempboxa{\fignumfont#1.\figtextfont\hskip.5em\relax #2}%
\ifdim \wd\@tempboxa >\hsize
\fignumfont\relax #1.\figtextfont\hskip.5em\relax#2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\fi
}
\makeatother
One additional comment: once this bug is fixed, you'll almost certainly run into another issue which you'd want fixed if you use the PNAS two-column class to produce production-quality output: Unless you define floats with the h "here" placement, it loses the labels, so all cross-referencing of figures and tables breaks. Here is the fix, for direct pasting into the document preamble. You can also patch up the macro \DonormalEndcol pnastwo.cls, it's the same mistake 6 times over...
% And another fix. PNAS class loses the label of floats unless they
% were defined with the [h] option (so not really floats at all). It
% all comes down to wrong scope in the following routine which pushes
% out the floats onto the page. This is the fixed version:
\makeatletter
\def\DonormalEndcol{%
%% top float ==>
\ifx\toporbotfloat\xtopfloat%
%% figure ==>
\ifcaptypefig%
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopFig%
\unvbox\csname figandtabbox\the\loopnum\endcsname%
\vskip\abovefigcaptionskip%
\csname caption\the\loopnum\endcsname%
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname
\ifredefining%
\csname label\the\loopnum\endcsname%
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi}%
\vskip\intextfloatskip%%
\vskip-4pt %% probably an artifact of topskip??
}%
\else%
%% plate ==>
\ifcaptypeplate%
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopFig%
\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname
\ifredefining
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi}
\vskip\intextfloatskip %%
\vskip-4pt %% probably an artifact of topskip??
}%
\else% table ==>
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopTab %%
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname
\vskip\captionskip
\unvbox\csname figandtabbox\the\loopnum\endcsname
\ifredefining
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi
}\vskip\intextfloatskip %% why don't we need this?
\vskip-10pt}
\fi\fi%
%
\else% bottom float
%
\ifcaptypefig
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip\PushOneColBotFig%%
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\else
\ifcaptypeplate
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip\PushOneColBotFig%%
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\else% TABLE
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip.5\intextfloatskip
\unvbox\csname figandtabbox\the\loopnum\endcsname%
\vskip\PushOneColBotTab
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\fi\fi\fi}
\makeatother
Best Answer
You can patch
\@makecaption
. But be aware that such journal styles are like the journal wants them and you normally shouldn't change the style.