# Centering figure captions in IEEEtran

I am working on a paper using the IEEEtran template in LyX.

I have run into a problem: While the contents (in this case, a table) of the figure float are centered, the caption is aligned to the left (see screenshot below). How can I center the caption as well?

This is generated by the following LyX document:

What I've tried:

1. Center the table (the table is centered)
2. Center all the contents in the float (only the table is centered)
3. Select the caption and center it (no effect)

Technical details:

• LyX 2.0.5.1
• Mac OS X 10.7.5 (Lion)
• All centering was performed by Right Click>Paragraph Settings>Align: Center
-

## migrated from stackoverflow.comMar 1 '13 at 14:36

This question came from our site for professional and enthusiast programmers.

The IEEEtran class aligns figure captions to the left. Since it's thought for submissions to IEEE journals or conferences, you shouldn't tamper with the positioning. – egreg Mar 1 '13 at 14:45
I think you have a level to use an other Editor than LyX. Please see this small discuss meta.tex.stackexchange.com/questions/1883/… and here is a small collection of editors: tex.stackexchange.com/questions/339/latex-editors-ides – Marco Daniel Mar 1 '13 at 14:57
@MarcoDaniel I don't think LyX is a LaTeX editor. I do think though that a good understanding of LaTeX should be achieved before using LyX, not as a reason to leave LyX. See also yihui.name/en/2012/10/lyx-vs-latex. There are many good reasons to not use LyX, but I don't think knowing a lot of LaTeX should be one of them. Of course this is a personal opinion, but since you gave yours I gave mine :) – scottkosty Mar 1 '13 at 15:39
@scottkosty: Indeed. I completely agree with you. – Marco Daniel Mar 1 '13 at 17:46
@inspectorG4dget: I've added an answer. We should clean up our comments... – Werner Mar 1 '13 at 22:01

\usepackage{caption}% http://ctan.org/pkg/caption


to your document preamble (using the menus Document > Settings... > LaTeX Preamble) centres the captions by default. Although this also changes the default formatting, it would be possible to adapt it to match that of the default IEEEtran document class.

If this is for a journal submission, it is advised to stick to their formatting.

-

IEEEtran has a conference mode which automatically centers all the captions. Adding following to your LaTeX code would center all the captions.

\documentclass[conference]{IEEEtran}


Although, I would also agree with @Werner, that it's best to stick to the format specified by the journal you are submitting.

-

Just Put the following code after \documentclass[journal]{IEEEtran}

\makeatletter
\long\def\@makecaption#1#2{\ifx\@captype\@IEEEtablestring%
\footnotesize\begin{center}{\normalfont\footnotesize #1}\\
{\normalfont\footnotesize\scshape #2}\end{center}%
\@IEEEtablecaptionsepspace
\else
\@IEEEfigurecaptionsepspace
\setbox\@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ #2}%
\ifdim \wd\@tempboxa >\hsize%
\setbox\@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ }%
\parbox[t]{\hsize}{\normalfont\footnotesize \noindent\unhbox\@tempboxa#2}%
\else
\hbox to\hsize{\normalfont\footnotesize\hfil\box\@tempboxa\hfil}\fi\fi}
\makeatother

% will definitely work.


This is the above code for JOURNAL class. Thanks to http://www.michaelshell.org/tex/ieeetran/

-
this is already the code inside IEEEtran no? – percusse Dec 24 '15 at 13:00