# Caption format changing

I want my captions of figures to be formated like this:

1 pav. First Caption

2 pav. Second Caption

Furthermore, I need my captions to be centered.

How can I redefine this?

-
What document class are you using? – Ian Thompson Mar 6 '13 at 20:38
\documentclass[journal]{IEEEtran} – Pavasaris Mar 6 '13 at 20:40

To get '1 pav' instead of 'Fig. 1', you can hack the IEEE document class as follows (but be warned that publishers probably won't like this).

\documentclass[journal]{IEEEtran}
\renewcommand\figurename{pav}
\makeatletter
\def\fnum@figure{\thefigure\ \figurename}
\makeatother
\begin{document}
\begin{figure}
\rule{4cm}{4cm}
\caption{A nice figure}
\end{figure}
\begin{figure}
\rule{4cm}{4cm}
\caption{Another nice figure}
\end{figure}
\end{document}


Centering the caption is more difficult. One possibility is to copy the definition of \@makecaption from the cls file and adjust it so that captions behave as they do in IEEE conference papers (centred if they fit on a single line).

\documentclass[journal]{IEEEtran}
\makeatletter
%
\long\def\@makecaption#1#2{%
% test if is a for a figure or table
\ifx\@captype\@IEEEtablestring%
% if a table, do table caption
\footnotesize\begin{center}{\normalfont\footnotesize #1}\\{\normalfont\footnotesize\scshape #2}\end{center}%
\@IEEEtablecaptionsepspace
% if not a table, format it as a figure
\else
\@IEEEfigurecaptionsepspace
% 3/2001 use footnotesize, not small; use two nonbreaking spaces, not one
\setbox\@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ #2}%
\ifdim \wd\@tempboxa >\hsize%
% if caption is longer than a line, let it wrap around
\setbox\@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ }%
\parbox[t]{\hsize}{\normalfont\footnotesize\noindent\unhbox\@tempboxa#2}%
% if caption is shorter than a line, center
\else%
\hbox to\hsize{\normalfont\footnotesize\hfil\box\@tempboxa\hfil}%
\fi\fi}
%
\renewcommand\figurename{pav}
\def\fnum@figure{\thefigure\ \figurename}
\makeatother
\begin{document}
\begin{figure}
\centering\rule{4cm}{4cm}
\caption{A nice figure}
\end{figure}
\begin{figure}
\centering\rule{4cm}{4cm}
\caption{Another nice figure}
\end{figure}
\end{document}

-

This solution, involving the boxhandler package, gives you maximal control over the captions, as shown in three examples.

\documentclass{article}
\usepackage{boxhandler}

\makeatletter
\def\figurename{pav}
\def\fnum@figure{\thefigure\nobreakspace\figurename}
\makeatother

\begin{document}
\captionStyle{o}{c}
\bxfigure{This is the caption to the figure, which I am making very long
to show a point}{\fbox{This is the figure right here}}

\captionStyle{n}{c}
\bxfigure{This is the caption to the figure, which I am making very long
to show a point}{\fbox{This is the figure right here}}

\constrainCaptionWidth{\textwidth}
\bxfigure{This is the caption to the figure, which I am making very long
to show a point}{\fbox{This is the figure right here}}

\end{document}


-