2

I have a lot of figures in my document and unfortunately used the deprecated subfigure package. Now, I don't want to change all figures to the better subfig package, but instead, want to use it for new figures and in order to make the caption of a subfigure wider than the subfigure (using \makebox). But only one package works either subfigure or subfig. Is there a way to use both packages in parallel?

Here is a MWE:

\documentclass[a4paper,12pt,openrigth,oneside,bibliography=totoc,headspline]{scrreprt}
\usepackage[utf8]{inputenc}
%\usepackage{subfigure}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{mwe}


\begin{document}
%   \begin{figure}
%       \centering
%       \subfigure[Subigure 1]{\includegraphics[scale=0.5]{example-image-a}
%       \label{fig10}}
%       \subfigure[Subfigure2]{\includegraphics[scale=0.5]{example-image-a}
%       \label{fig11}}
%       \caption{Test figure 1 with subfigure command.}
%       \label{fig1}
%   \end{figure}
    \begin{figure}
        \subfloat[Subfloat 1]{\makebox[1.2\width][c]{\includegraphics[scale=0.5]{example-image-a}\label{fig20}}}
        \subfloat[Subfloat 2]{\makebox[1.2\width][c]{\includegraphics[scale=0.5]{example-image-a}\label{fig21}}}
        \caption{Test figure 2 with subfloat command.}
        \label{fig2}
    \end{figure}
\end{document}

The goal would be that the MWE also compiles when all text is uncommented.

  • It doesn't make sense to use both, imho. Decide for one. If you want to update to subfig, you could just as well consider upgrading to subcaption and update all subfigures of your document. Or just stay with the old package. – Johannes_B Jan 8 at 14:13
4

I'm not sure where's the problem with changing \subfigure into \subfloat.

Anyway, you can use the old command:

\documentclass[a4paper,12pt,openright,oneside,bibliography=totoc,headsepline]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[config=altsf]{subfig}
\usepackage{graphicx}
\usepackage{mwe}


\begin{document}

\begin{figure}
\centering

\subfigure[Subfigure 1\label{fig10}]{\includegraphics[scale=0.5]{example-image-a}}
\subfigure[Subfigure 2\label{fig11}]{\includegraphics[scale=0.5]{example-image-a}}

\caption{Test figure 1 with subfigure command.}\label{fig1}

\end{figure}

\begin{figure}
\centering

\subfloat[Subfloat 1\label{fig20}]{\makebox[1.2\width]{\includegraphics[scale=0.5]{example-image-a}}}
\subfloat[Subfloat 2\label{fig21}]{\makebox[1.2\width]{\includegraphics[scale=0.5]{example-image-a}}}

\caption{Test figure 2 with subfloat command.}\label{fig2}

\end{figure}

\end{document}

Note that I made several fixes.

enter image description here

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.