[Tex/LaTex] Alignment of pictures and captions inside minipages

diagramshorizontal alignment

I need to display two pictures side by side any make them wider than textwidth.

I read a solution to use something like the following and have successfully used it with pdf images:

\begin{figure}[htb]
  \centering
  \makebox[\textwidth]{%
    \begin{minipage}[b]{0.7\textwidth}
      \includegraphics[width=\textwidth]{myimage.pdf}
      \caption{First Image}
    \end{minipage}
    \begin{minipage}[b]{0.7\textwidth}
      \includegraphics[width=\textwidth]{myimage2.pdf}
      \caption{Second Image}
    \end{minipage}
  }%
\end{figure}%

I am now trying to use it with images created using the picture environment. It mostly works fine, except that the image on the left is not centered on its caption.

I am using the same code as the above example, except that \includegraphics... is replaced with \begin{picture}...\end{picture}.

The images are different sizes (the first image is narrower), but even if I change the size of the first image, the display is the same.

Any recommendations?

Best Answer

You have to use \centering

\documentclass{article}
\usepackage{graphicx}
\begin{document}
  \begin{figure}[htb]
  \makebox[\textwidth]{%
    \begin{minipage}[b]{0.7\textwidth}
      \centering
      \includegraphics[width=0.7\linewidth]{example-image}  %% change 0.7\linewidth to \linewidth in your file
      \caption{First Image}
    \end{minipage}%
    \begin{minipage}[b]{0.7\textwidth}
      \centering      %% just in case if this too is narrower.
      \includegraphics[width=\linewidth]{example-image-a}
      \caption{Second Image}
    \end{minipage}
  }%
\end{figure}%
\end{document}

enter image description here