17

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?

enter image description here

This is generated by the following LyX document:

enter image description here

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
5
  • 3
    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
    Commented Mar 1, 2013 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 Commented Mar 1, 2013 at 14:57
  • 1
    @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
    Commented Mar 1, 2013 at 15:39
  • @scottkosty: Indeed. I completely agree with you. Commented Mar 1, 2013 at 17:46
  • @inspectorG4dget: I've added an answer. We should clean up our comments...
    – Werner
    Commented Mar 1, 2013 at 22:01

4 Answers 4

12

Adding

\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.

3

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/

1
  • 1
    this is already the code inside IEEEtran no?
    – percusse
    Commented Dec 24, 2015 at 13:00
1

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.

1

Hinted by @Shaun , I tested on my computer and found that: for ieeetran, the caption is aligned at center in conference mode

    \documentclass[conference]{IEEEtran}

while it is left aligned in journal mode

    \documentclass[journal]{IEEEtran}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .