# package subfig interfering with caption setup of package caption

Consider this example identified as a solution for remove colon in captions:

\documentclass{report}
%\usepackage{subfig}
\usepackage{graphicx}
\usepackage[latvian]{babel}
\usepackage{caption}
\captionsetup[figure]{labelsep=space}
\begin{document}
\begin{figure}
\includegraphics{example-image-a}
\caption{Case of A.}
\end{figure}
\end{document}


The command

\captionsetup[figure]{labelsep=space}

fails once the line

%\usepackage{subfig}

is uncommented, i.e. the separator once again is :. How to solve?

• Load the subcaption package instead, and use its subfigure environment. – Bernard Feb 3 at 14:57
• @Bernard, I am fixed to use \subfloat instead of \subfigure. – Viesturs Feb 3 at 14:59
• Use labelsep=space as an option on loading subfig then (cf. p. 31 of the documentation), if I've well understood the problem. – Bernard Feb 3 at 15:05
• @Bernard, using \usepackage[labelsep=space]{subfig} didn't work, except when this line is moved after the line \usepackage[latvian]{babel}. – Viesturs Feb 3 at 15:07
• Load subfig after caption. – Bernard Feb 3 at 15:11

The latvian.ldf redefines \@makecaption. So load subfig after babel (you don't need to load caption, subfig is doing it):

\documentclass{report}

\usepackage{graphicx}

\usepackage[latvian]{babel}
\usepackage{subfig}

\captionsetup{labelsep=space}
\begin{document}
\begin{figure}\tracingmacros=1
\includegraphics{example-image-a}
\caption{Case of A.}
\end{figure}
\end{document}


• Is that a general recommendation? – Viesturs Feb 3 at 15:15
• No, also it is actually nonsense. subfig loads caption anyway. The problem is the latvian option of babel. I need to check this. – Ulrike Fischer Feb 3 at 15:20
• @Viesturs I edited the answer. – Ulrike Fischer Feb 3 at 15:25

You can replace \subfloat easily enough using a subfigure and a savebox. Admittedly this version does not implement the list option, but that can be done using xparse or \@ifnextchar[.

\documentclass{report}
\usepackage{graphicx}
\usepackage[latvian]{babel}
\usepackage{subcaption}
\captionsetup[figure]{labelsep=space}

\newcommand{\subfloat}[2][\empty]% #1=caption (optional), #2=body
{\bgroup
\sbox0{#2}% measure image
\begin{subfigure}[b]{\wd0}
\usebox0
\ifx\empty#1\relax
\else\caption{#1}
\fi
\end{subfigure}
\egroup}

\begin{document}
\begin{figure}
\subfloat[Case of A.]{\includegraphics{example-image-a}}
\end{figure}
\end{document}