[Tex/LaTex] compare two diagrams side by side


I'm trying to compare two diagrams in pdf format side by side.
I have this post – Two figures side by side to get some hint.

This is the code that I'm coming up with.

\caption{(a) Before}

\caption{(b) After}

And this is the result, which is not exactly what I expected.

enter image description here

  • What modifications are needed to make the pictures sit side by side?
  • I just want the caption (a) Before and (b) After without any Figure prepended. What should I do?

Best Answer

Although you can solve perfectly the problem with minipages, for sub-figures with captions enumerated with letters (a,b,..) you can use also the package subcaption to simplify a little your code, as you do not need write "(a)" and "(b)", but mainly because the flexibility that you have with this package, as listing the subfigures. Note that neither is it necessary in the MWE the use of \centering nor include file extension (.pdf).

Note: Remove the demo option in graphicx package to use your diagrams instead of the black boxes:

\usepackage[demo]{graphicx} % remove option for real images




\caption[Hello]{Hello, this a minimal working example}

enter image description here

Alternatively you can use also subfig or subfigure packages for the same reasons. See Setting default distance between subfigures for examples with these packages.