I am trying to to get the smaller images in the second row to center align with the bigger images in the first row: (this using MS word) Fig_word

I tried the following code:

\subcaptionbox{} [4em] {\includegraphics[width=8em]{4a.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=8em]{4b.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=8em]{4c.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=8em]{4d.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=8em]{4e.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=8em]{4f.png}}\\

\subcaptionbox{} [4em] {\includegraphics[width=4em]{4g.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=4em]{4h.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=4em]{4i.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=4em]{4j.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=4em]{4k.png}}\hfill
\subcaptionbox{} [4em] {\includegraphics[width=4em]{4l.png}}
        \caption {My caption}

This gives: Fig_latex

But, as you see, I have to manually adjust the hspace values to make each of the smaller images center aligned with their corresponding bigger images. How should I go about it?


Rather use the subcaption package which allows you to specify the width of the sub-figure block. Here's an example with \subcaptionbox{<caption>}[<width>]{<stuff>}:

enter image description here






  \caption{My caption}


If you're sold on (the obsolete) subfigure, you can measure the width of your widest element and then use that as the width for the less-wide images:


  \settowidth{\widestimg}{\includegraphics{4a.png}}% Measure width of widest image


  \caption{My caption}
  • As you see (in the edited post), the problem remains. I cannot get the smaller figures and captions to align at the same time. – n.gaurav Nov 2 '18 at 20:19
  • @n.gaurav: I used 4em because that is the width of the widest image I worked with. If you don't know the width of the widest image, add \newlength{\widestimg} somewhere in your preamble and set it using \settowidth{\widestimg}{\includegraphics{<widest image>}}. Then, instead of 4em, use \widestimg (in the second row of smaller images). – Werner Nov 2 '18 at 20:28
  • That worked, fantastic! As you said, all I needed to do was to find the width of the images in the first row (which are all of same width), and set the subcaption box width for all 12 figures to this width. Thanks! – n.gaurav Nov 2 '18 at 20:38

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.