I have a few narrow figures for which I want to center the caption. I have to use a LaTeX template from Springer (svmult.cls
). This makes captions left-aligned by default. I took a look at this question which suggest to add the captions
package and then locally use
\captionsetup{justification=centering}
But this has no effect in this case. The relevant part from the class file looks like this:
\usepackage{subfig}
% redefininition of the captions for "figure" and "table" environments
%
\@ifundefined{floatlegendstyle}{\def\floatlegendstyle{\bfseries}}{}
\def\floatcounterend{\enspace}
\def\capstrut{\vrule\@width\z@\@height\topskip}
\@ifundefined{captionstyle}{\def\captionstyle{\normalfont\small}}{}
\@ifundefined{instindent}{\newdimen\instindent}{}
\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname
ext@#1\endcsname}{#1}{\protect\numberline{\csname
the#1\endcsname}{\ignorespaces #2}}\begingroup
\@parboxrestore\if@minipage\@setminipage\fi
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\def\twocaptionwidth#1#2{\def\first@capwidth{#1}\def\second@capwidth{#2}}
% Default: .46\textwidth
\twocaptionwidth{.46\textwidth}{.46\textwidth}
\def\leftcaption{\refstepcounter\@captype\@dblarg%
{\@leftcaption\@captype}}
\def\rightcaption{\refstepcounter\@captype\@dblarg%
{\@rightcaption\@captype}}
\long\def\@leftcaption#1[#2]#3{\addcontentsline{\csname
ext@#1\endcsname}{#1}{\protect\numberline{\csname
the#1\endcsname}{\ignorespaces #2}}\begingroup
\@parboxrestore
\vskip\figcapgap
\@maketwocaptions{\csname fnum@#1\endcsname}{\ignorespaces #3}%
{\first@capwidth}\ignorespaces\hspace{.073\textwidth}\hfill%
\endgroup}
\long\def\@rightcaption#1[#2]#3{\addcontentsline{\csname
ext@#1\endcsname}{#1}{\protect\numberline{\csname
the#1\endcsname}{\ignorespaces #2}}\begingroup
\@parboxrestore
\@maketwocaptions{\csname fnum@#1\endcsname}{\ignorespaces #3}%
{\second@capwidth}\par
\endgroup}
\long\def\@maketwocaptions#1#2#3{%
\parbox[t]{#3}{{\floatlegendstyle #1\floatcounterend}#2}}
\def\fig@pos{l}
\newcommand{\leftfigure}[2][\fig@pos]{\makebox[.4635\textwidth][#1]{#2}}
\let\rightfigure\leftfigure
\newdimen\figgap\figgap=0.5cm % hgap between figure and sidecaption
%
\long\def\@makesidecaption#1#2{\@tempdimb=3.6cm
\setbox0=\vbox{\hsize=\@tempdimb
\captionstyle{\floatlegendstyle
#1\floatcounterend}#2}%
\ifdim\instindent<\z@
\ifdim\ht0>-\instindent
\advance\instindent by\ht0
\typeout{^^JClass-Warning: Legend of \string\sidecaption\space for
\@captype\space\csname the\@captype\endcsname
^^Jis \the\instindent\space taller than the corresponding float -
^^Jyou'd better switch the environment. }%
\instindent\z@
\fi
\else
\ifdim\ht0<\instindent
\advance\instindent by-\ht0
\advance\instindent by-\dp0\relax
\advance\instindent by\topskip
\advance\instindent by-11\p@
\else
\advance\instindent by-\ht0
\instindent=-\instindent
\typeout{^^JClass-Warning: Legend of \string\sidecaption\space for
\@captype\space\csname the\@captype\endcsname
^^Jis \the\instindent\space taller than the corresponding float -
^^Jyou'd better switch the environment. }%
\instindent\z@
\fi
\fi
\parbox[b]{\@tempdimb}{\captionstyle{\floatlegendstyle
#1\floatcounterend}#2%
\ifdim\instindent>\z@ \\
\vrule\@width\z@\@height\instindent
\@depth\z@
\fi}}
\def\sidecaption{\@ifnextchar[\sidec@ption{\sidec@ption[b]}}
%
\newbox\bildb@x
%
\def\sidec@ption[#1]#2\caption{%
\setbox\bildb@x=\hbox{\ignorespaces#2\unskip}%
\if@twocolumn
\ifdim\hsize<\textwidth\else
\ifdim\wd\bildb@x<\columnwidth
\typeout{Double column float fits into single column -
^^Jyou'd better switch the environment. }%
\fi
\fi
\fi
\instindent=\ht\bildb@x
\advance\instindent by\dp\bildb@x
\if t#1
\else
\instindent=-\instindent
\fi
\@tempdimb=\hsize
\advance\@tempdimb by-\figgap
\advance\@tempdimb by-\wd\bildb@x
\ifdim\@tempdimb<3.6cm
\ClassWarning{SVMult}{\string\sidecaption: No sufficient room for the legend;
^^Jusing normal \string\caption}%
\unhbox\bildb@x
\let\@capcommand=\@caption
\else
% \ifdim\@tempdimb<4.5cm
% \ClassWarning{SVMono}{\string\sidecaption: Room for the legend very narrow;
% ^^Jusing \string\raggedright}%
\toks@\expandafter{\captionstyle\sloppy
\rightskip=\z@\@plus6mm\relax}%
\def\captionstyle{\the\toks@}%
% \fi
\let\@capcommand=\@sidecaption
% \leavevmode
% \unhbox\bildb@x
% \hfill
\fi
\refstepcounter\@captype
\@dblarg{\@capcommand\@captype}}
\long\def\@sidecaption#1[#2]#3{\addcontentsline{\csname
ext@#1\endcsname}{#1}{\protect\numberline{\csname
the#1\endcsname}{\ignorespaces #2}}\begingroup
\@parboxrestore
\@makesidecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}%
\hfill
\unhbox\bildb@x
\par
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As far as I understand, it merely defines extra captions for figures composed of two horizontal sub figures?
Any idea why the captionsetup
doesn't work in this case, and if there is a work around (perhaps using something in subfig
as that package is already included).
EDIT: Here is a minimal example:
\documentclass[graybox]{svmult}
\begin{document}
\begin{figure}
\centering
My graphics
\captionsetup{justification=centering}
\caption{My caption}
\end{figure}
\end{document}
Where svmult.cls
is available from Springer.
\textwidth
, believe me it looks crap. I would just like to know why nothing incaptionsetup
has any effect.