1

I am putting two images side-by-side using the subfig package and the subfloat command. Here is my MWE:

\documentclass[varwidth]{standalone}
\usepackage{mwe}
\usepackage[
    labelfont=bf,
    labelformat=parens,
    justification=raggedright,
    position=top,
    ]{caption,subfig}

\begin{document}

\begin{figure}
    \subfloat[]{%
        \includegraphics[width=0.4\textwidth]{example-image-a}%
    }\quad
    \subfloat[]{%
        \includegraphics[width=0.4\textwidth]{example-image-golden}%
    }
\end{figure}

\end{document}

which produces this result:

resulting pdf

The label (b) however is noticeably smaller than (a) and I have no idea why or how to fix it.

Bonus question: How can I change the labels to use a) instead of (a)?

Any hints are appreciated!

1
  • 1
    As far as the special document class standalone is replaced by, for example article, size of figure captions is the same. Using standalone, I also find adding \leavevmode just before the first \subfloat seems to fix the problem. Commented Jun 18, 2022 at 4:00

2 Answers 2

1

Today is not my day, three times I upload the wrong version of my answer! What an embarrassing 😢!!

Hopefully, now at forth attempt I upload correct version of answer:

Edit: I do not know what is cause of your problem, but remedy for it can be:

  • Use of `subcaption`` with own, from caption separated settings (it is not clear, how should be set caption, I assume that caption number is not in parenthesis and that it is followed by colon):
\usepackage[labelfont=bf,
            justification=raggedright,
            labelsep=colon,    % <---
            ]{caption}
\usepackage[labelformat=brace,  % <---
            singlelinecheck=off,% <---
            position=top,
            ]{subcaption}
  • use subfig which also have own settings, which are the same as at subcaption
\usepackage[labelformat=brace,% <---
            font=normalsize,
            position=top,
            ]{subfig}

In both cases the result is the same:

enter image description here

Complete MWE is:

\documentclass[border=3.141592, preview]{standalone}
\usepackage{mwe}
\usepackage[font=small,
            labelfont=bf,
            justification=raggedright,
            labelsep=colon,
            ]{caption}
\usepackage[labelformat=brace,  %
            singlelinecheck=false,
            position=top,
            ]{subcaption}       % or subfig

\begin{document}

\begin{figure}
\centering
\subfloat[]{\includegraphics[width=0.4\textwidth]{example-image-a}}
\hfil
\subfloat[]{\includegraphics[width=0.4\textwidth]{example-image-golden}}
%
\caption{Figure caption}
\label{fig:??}
\end{figure}

\end{document}
2
  • almost - if I use caption, subcaption, the size is right, but there is the extra bracket and colon around (a): but in your bonus answer, the a) looks good, but b) is too small again.
    – John Smith
    Commented Jun 17, 2022 at 19:46
  • @JohnSmith, you are right. Please check edited answer. Now it should be such as you want to be :-)
    – Zarko
    Commented Jun 17, 2022 at 21:56
2

\subfloat is also supported by subcaption.

\documentclass[varwidth]{standalone}
\usepackage{mwe}
\usepackage[
    labelfont=bf,
    labelformat=brace,
    labelsep=space,
    justification=raggedright,
    position=top,
    ]{caption,subcaption}

\begin{document}

\begin{figure}
    \subfloat[]{%
        \includegraphics[width=0.4\textwidth]{example-image-a}%
    }\quad
    \subfloat[]{%
        \includegraphics[width=0.4\textwidth]{example-image-golden}%
    }
\end{figure}

\end{document}

demo

You must log in to answer this question.

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