5

I'm looking for a method to center the figure captions in single- and double-column mode. Here is my code

\documentclass[journal]{IEEEtran}

\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\begin{document}
\begin{figure*}
\tikz \draw [black] (0,0) rectangle (\linewidth,1cm);
\caption{caption}
\end{figure*}
\begin{figure*}
\subfloat[]{\tikz \draw [black] (0,0) rectangle (\linewidth/2,1cm);}
\subfloat[]{\tikz \draw [black] (0,0) rectangle (\linewidth/2,1cm);}
\caption{title}
\end{figure*}
\begin{figure}
\tikz \draw [black] (0,0) rectangle (\linewidth,1cm);
\caption{caption}
\end{figure}
\end{document}

which gives: enter image description here enter image description here enter image description here

bonanza
  • 2,141
  • 2
  • 26
  • 37
  • 1
    Most often, you don't have to: IEEE class is designed for having left aligned captions. Some conferences wants centered captions and there is a compsocconf option, but you have to check what to use. – Claudio Fiandrino Mar 10 '14 at 14:33
  • Have you tried to remove the [caption=false] for the subfig package. – Jesse Mar 10 '14 at 14:41
  • @Jesse, yes removing this results in an warning: Package caption Warning: "Unsupported document class (or package) detected" Also, this changes the caption style (font etc) of table headings which I do not want to change. – bonanza Mar 10 '14 at 15:17
  • Yes, did not notice that. Sorry. – Jesse Mar 10 '14 at 15:21

2 Answers2

4

It's not that difficult to fake.

\documentclass[journal]{IEEEtran}
\usepackage{tikz}

\newcommand{\mycaption}[1]{\stepcounter{figure}\raisebox{-7pt}
  {\footnotesize Fig. \thefigure.\hspace{3pt} #1}}

\begin{document}
\begin{figure*}
\tikz \draw [black] (0,0) rectangle (\linewidth,1cm);
\centering\mycaption{caption}
\end{figure*}

\begin{figure}
\tikz \draw [black] (0,0) rectangle (\linewidth,1cm);
\centering\mycaption{caption}
\end{figure}
\end{document}

fig 1 fig 2

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
0

It seems to me that this behaviour comes with the IEEEtran.cls v1.8c style that I retrieved from the IEEE homepage. The figure captions are centred when using the v1.8 installed on my Fedora Linux distribution or the latest v1.8a from CTAN.

This is the version information from the IEEEtran.cls from the IEEE homepage:

pdflatex> Document Class: IEEEtran 2012/11/21 V1.8c by Harald Hanche-Olsen and Anders Chr
pdflatex> istensen
pdflatex> -- Based on V1.7a by Michael Shell

This is the one from my F21 distribution:

pdflatex> Document Class: IEEEtran 2012/12/27 V1.8 by Michael Shell

And this the latest from CTAN

pdflatex> Document Class: IEEEtran 2014/09/17 V1.8a by Michael Shell
  • There seem to be huge differences in document spacing between the versions above. The ones from Michael Shell are much wider. – Bernd Gloss Jan 21 '15 at 18:01
  • 1
    I'm using "IEEEtran 2014/09/17 V1.8a by Michael Shell" which comes with TexLive 2014 and the centering does not work when using the subfig package as mentioned in the IEEEtran template:\usepackage[caption=false,font=footnotesize]{subfig} When changing to caption=true it works – bonanza Jan 26 '15 at 07:56
  • But, as mentioned in my above comment then I get a warning. Do you use this package? If so, which options do you use? – bonanza Jan 26 '15 at 08:02
  • Sure? In my current project it is exactly as it should be: {caption=false} works fine, {caption=true} produces warnings and doesn't respect the IEEE formatting in the caption headers, such as the font size. – Bernd Gloss Jan 26 '15 at 10:28
  • Unfortunately, I don't get it working. Can you upload somewhere a MWE including your IEEEtran.cls file for me to give it a try? – bonanza Jan 27 '15 at 07:54
  • 1
    I just ran again your example. The difference probably is that I prepare a conference paper while you use the journal mode. In conference mode, it is as I said. In journal mode, as you said --- so, I am sorry. I think I cannot help. – Bernd Gloss Jan 27 '15 at 08:23
  • If you look to papers in IEEE journals, they are formatted with the main caption of the figure aligned left and the subfig captions (a) (b) ... aligned centered. Maybe you should just stick to the style. Its a feature, not an error! – Bernd Gloss Jan 27 '15 at 08:29