2

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}
Jame
  • 689

2 Answers2

3

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.

Werner
  • 603,163
1
\begin{tabular}{@{}l@{}}
\includegraphics{zzz}\\
\hspace{1cm}(a)\hspace{2cm}(b)
\end{tabular}

Adjust the lengths to fit.

David Carlisle
  • 757,742
  • Thank your solution. I tested it but the margin top between (a),(b) so big. Do we have option to reduce it. And how to crate a main caption for that figure – Jame Nov 08 '15 at 01:50
  • \\[-10pt] will reduce the vertical space and just use \caption{} as normal after this tabular for any main caption – David Carlisle Nov 08 '15 at 10:12