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?

5
  • 1
    Load the subcaption package instead, and use its subfigure environment.
    – Bernard
    Commented Feb 3, 2019 at 14:57
  • @Bernard, I am fixed to use \subfloat instead of \subfigure.
    – Viesturs
    Commented Feb 3, 2019 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
    Commented Feb 3, 2019 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
    Commented Feb 3, 2019 at 15:07
  • 1
    Load subfig after caption.
    – Bernard
    Commented Feb 3, 2019 at 15:11

2 Answers 2

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

3
  • Is that a general recommendation?
    – Viesturs
    Commented Feb 3, 2019 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. Commented Feb 3, 2019 at 15:20
  • @Viesturs I edited the answer. Commented Feb 3, 2019 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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .