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}
When using the caption
package with the IEEEtran
class you receive the following package warning:
Package caption Warning: Unsupported document class (or package) detected,
(caption) usage of the caption package is not recommended.
See the caption package documentation for explanation.
So let's not use caption
.
You can set the image-and-caption inside a minipage
of fixed width. This fixed width would match what you want the image width to be, and then set width=\linewidth
for your \includegraphics
. This will ensure that the image is the same width as the width specified for the minipage
:
\documentclass[journal]{IEEEtran}
\usepackage{graphicx,lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[h!]
\centering
\begin{minipage}{2.5in}
\includegraphics[height=2.1in,width=\linewidth]{example-image}
\caption{This is some figure caption}
\end{minipage}
\end{figure}
\lipsum[2]
\end{document}
When working with a table that you want the same to happen, you could use the varwidth
package's varwidth
environment; use \columnwidth
as your "fixed-width specification". It's similar to minipage
, but will shrink if the contents is narrower than specified.
Best Answer
Just issue a
\raggedright
within the\caption
in question:Since the captions are long, you're bound to use the optional argument to set something shorter in the LoT. As such, there should be no concern about
\protect
ion for the alignment.