0

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}
\addto\captionslatvian{\renewcommand{\figurename}{att.}}
\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?

  • 1
    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
  • 1
    Load subfig after caption. – Bernard Feb 3 at 15:11
3

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}
\addto\captionslatvian{\renewcommand{\figurename}{att.}}
\begin{document}
\begin{figure}\tracingmacros=1
  \includegraphics{example-image-a}
  \caption{Case of A.}
\end{figure}
\end{document}

enter image description here

  • Is that a general recommendation? – Viesturs Feb 3 at 15:15
  • 1
    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
2

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}
\addto\captionslatvian{\renewcommand{\figurename}{att.}}

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.