[Tex/LaTex] How to center listings caption

captionshorizontal alignmentieeetranlistings

I would like to know how to center the listings gerenated caption in LaTeX. It always go to the left of the code. The rest of the captions (tables) are OK.

\documentclass[11pt,a4paper,oneside, onecolumn]{IEEEtran}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
fileName = 'CorelGCH.arff';
features = CorelDB(@NormalizedGCH);
dlmwrite(fileName, features, ',');
\end{lstlisting}
\end{document}

I think the problem is with the IEEEtran…

Best Answer

To center the caption in the class IEEEtran you have two possibilities:

  1. Load the class with the option conference. This was discussed at LaTeX Community: Cannot align caption to the center,

  2. Load the package caption with the option justification=centering:

    \usepackage[justification=centering]{caption}
    
Related Question