I want to have a figure with subfigures like this:
I tried to use \usepackage{subfig} but I get an error:
! Package subcaption Error: This package can't be used in cooperation(subcaption) with the subfig package.
Best Answer
Something like the following? The code uses the subcaption package, which may (or may not) be compatible with the document class you use. Which document class do you use?
\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}
\begin{document}
\begin{figure}
\begin{minipage}{0.6\textwidth}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{first}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{second}
\caption{}
\end{subfigure}
\bigskip % some vertical space between subfigures a/b and c/d...
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{third}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{fourth}
\caption{}
\end{subfigure}
\end{minipage}
\hfill
\begin{subfigure}{0.33\textwidth}
\includegraphics[width=\linewidth,height=2\linewidth]{fifth}
\caption{}
\end{subfigure}
\end{figure}
\end{document}
The subfig and subcaption packages can not be used in cooperation with each other. Instead, you can usecaption package with subfig to add some flavor to the captions and subcaptions (or you can use caption along with subcaption (which gives a subfigure command also).
\documentclass{memoir}
\usepackage[demo]{graphicx} % remove [demo] in your file
\usepackage{subfig} % for subfigures
\usepackage{caption}
\usepackage{lipsum}
\captionsetup[figure]{labelfont={bf,small},textfont={it,small}}
\captionsetup[subfloat]{labelfont={bf,small},textfont={it,small},
subrefformat=parens} %<-----designing subcaption
\newcommand{\myfigref}[2]{~\ref{#1}.\subref{#2}}% <---- a new macro for referring to a subfigure
%
\begin{document}
%=========================
\chapter{First chapter}
\lipsum[1-4]
%=========================
\begin{figure}[ht]
\includegraphics[width=1\textwidth]{my figure}
\caption{My single picture}\label{fig:figures}
\end{figure}
%=========================
\begin{figure}[ht]
\centering
\subfloat[My first picture]{\label{fig:mdleft}{\includegraphics[width=0.4\textwidth]{my figure}}}\hfill
\subfloat[My second picture]{\label{fig:mdright}{\includegraphics[width=0.4\textwidth]{my figure}}}
\caption{My two big pictures}
\label{fig:subfigures}
\end{figure}
%===========================
From figure~\ref{fig:subfigures}.\subref{fig:mdleft}, we can see a small cat, in
\myfigref{fig:subfigures}{fig:mdright} both can be used to refer figures.
\end{document}
Best Answer
Something like the following? The code uses the
subcaption
package, which may (or may not) be compatible with the document class you use. Which document class do you use?