Centering table caption not working

captionshorizontal alignmenttables

I cannot make my table caption centered (it keeps staying on the left side) in a two-column manuscript. Here is the code I am using:

\documentclass[twocolumn]{autart}
\usepackage{graphicx} 
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[justification=centering]{caption}

\begin{document}

\begin{table}
  \centering
  \caption{Nomenclature used in the model.} 
  \label{nomenclature}
  \vskip\baselineskip % Leave a vertical skip below the figure
  \begin{tabular}{|cc|} 
  \hline
          Col 1  &  Col 2          \\
          \hline
          1  &   4         \\
          2  &    5       \\
          3  &     6       \\
  \hline
  \end{tabular}
\end{table}
\end{document}

enter image description here

Can someone help me fix this?

Best Answer

The following code is copied from the autart.cls file.

\long\def\@maketablecaption#1#2{\@tablecaptionsize
    \global \@minipagefalse
    \hbox to \hsize{\parbox[t]{\hsize}{#1 \\ #2}}}

This typesets the caption in a box over the complete horizontal space. Therefore \centering has no effect for your caption.

You could change the code of the autart.cls file, but I would not recommend doing this, since the current style is probably required.

If you insist doing this, you could add the following to your preamble.

\makeatletter
\long\def\@maketablecaption#1#2{\@tablecaptionsize
  \setbox\@tempboxa\hbox{#1. #2}
  \ifdim \wd\@tempboxa >\hsize              % IF longer than one line THEN
    \unhbox\@tempboxa\par                   %   set as justified paragraph
  \else                                     % ELSE
    \global \@minipagefalse
    \hbox to\hsize{\hfil\box\@tempboxa\hfil}%   center single line.
  \fi}
\makeatother

The code is copied from @makefigurecaption. The caption will be centered if it fits on one line, otherwise it will be a justified paragraph. See the examples I provided.

table output

Related Question