1

Please help me! I have this code:

    \centering
    \subfloat[\centering textblabla1]{{\includegraphics[trim={0 0 34.5cm 0},clip, width=5cm]{mypng1.png} }}%
    \label{fig:bla1}
    \qquad
    \subfloat[\centering textblabla2]{{\includegraphics[trim={0 0 34.5cm 0},clip, width=5cm]{mypng2.png} }}%
    \label{fig:bla2}%
\end{figure}```
5

2 Answers 2

1

I understand your document loads the subcaption package, which provides the command \subfloat. The syntax of this command is patterned after the \subfloat macro of the older (and possibly no longer maintained) subfig package.

According to pp. 36f. of the user guide of the subfig package, the \label command has to be included in either the mandatory or (if provided) the optional argument of \subfloat. Both possibilities are explored in the following MWE (mininum working example).

enter image description here

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{subcaption,graphicx}
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage[noabbrev,capitalize]{cleveref}

\begin{document}
\begin{figure}
\centering
    \subfloat[textblabla1]{%
              \includegraphics[trim={0 0 34.5cm 0},clip, width=5cm]{mypng1.png}\label{fig:bla1}}
    \qquad
    \subfloat[textblabla2\label{fig:bla2}]{%
              \includegraphics[trim={0 0 34.5cm 0},clip, width=5cm]{mypng2.png}}

    \caption{Overall figure caption}\label{fig:overall}
\end{figure}

Cross-references to \cref{fig:bla1,fig:bla2}.
\end{document}
0

Try this one, it works easily.

     \begin{figure}
\caption{bla bla ..}
        \begin{subfigure}{t}{0.3\textwidth}
\caption{bla bla ..}
            \centering
        \includegraphics[width=0.333\textwidth,height=0.25\textwidth]{mypng1.png} 
            \label{fig:bla1}
         \end{subfigure}
        \begin{subfigure}{t}{0.3\textwidth}  
\caption{bla ...}
           \centering
    \includegraphics[width=0.333\textwidth,height=0.25\textwidth]{mypng2.png} 
            \label{fig:bla2}%
        \end{subfigure}
        \end{figure}

the size is tunable

You must log in to answer this question.

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