[Tex/LaTex] Is it possible to add subtitles of a figure which contains subfigures

floatsgraphicssubfloats

I have a single image which contains two sub-images. I want the following subtitles (a) and (b) to be shown correctly.
enter image description here

In which, left sides is my current image which contains two rectangular. And right sides is my expected result. I found a solution is that we can use subfig package. However, it requires separating the original figure into two subfigure. In that question, I am regarding that we do not need split original figure, I want to write (a),(b) directly below figure. Thanks
Current solution is

\begin{figure}[H]
\captionsetup{labelfont={bf}}
  \centering
    \subfloat[]{\centering\includegraphics[scale=0.5]{Fig1a.png}} \\
    \subfloat[]{\centering\includegraphics[scale=0.5]{Fig1b.png}}
  \caption{This is main figure}
  \label{fig:9}
\end{figure}

Best Answer

My suggestion would be to clip the image contents within LaTeX; graphicx allows for that:

enter image description here

\documentclass{article}

\usepackage{graphicx,subcaption}

\begin{document}

\begin{figure}
  \centering
  \setbox1=\hbox{\includegraphics{example-image-a}}%
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.5\wd1 0 \wd1 \ht1,clip]{example-image-a}}%
  \qquad
  \setbox1=\hbox{\includegraphics{example-image-b}}%
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=0 0 .5\wd1 \ht1,clip]{example-image-b}}
  \caption{This is main figure}
\end{figure}

\end{document}

I've used example-image-a and example-image-b (from mwe) above, although you will use the same image. As such, you'll only need to capture the image in box 1 once. Note how the image is split in half (at the .5\wd1 mark) with the viewport and clip combination.

Additionally, I've used subcaption, but you can manage the same with subfig.


Here is an example of breaking up a single image into six equal parts (perhaps synonymous to your situation):

enter image description here

\documentclass{article}

\usepackage{graphicx,subcaption}

\begin{document}

\begin{figure}
  \centering
  \setbox1=\hbox{\includegraphics{example-image}}%
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=0 0 .16667\wd1 \ht1,clip]{example-image}}%
  \quad
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.16667\wd1 0 .3333\wd1 \ht1,clip]{example-image}}%
  \quad
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.3333\wd1 0 .5\wd1 \ht1,clip]{example-image}}%
  \quad
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.5\wd1 0 .66667\wd1 \ht1,clip]{example-image}}%
  \quad
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.6667\wd1 0 .8333\wd1 \ht1,clip]{example-image}}%
  \quad
  \subcaptionbox{}{\centering\includegraphics[scale=0.5,viewport=.8333\wd1 0 \wd1 \ht1,clip]{example-image}}%
  \caption{This is main figure}
\end{figure}

\end{document}

Each component is extracted as a sixth of the total width \wd1, one step at a time.

Related Question