The code you provided does indeed center them as you desire. Its just that the page is not wide enough. If I add \usepackage[paperwidth=25.0cm,showframe]{geometry}
then you get:
Furthermore, you don't need to use the array
environment as you don't have math content, simple tabular
will suffice. Also, you should use \centering
instead of the center
environment as per When should we use \begin{center} instead of \centering?.
Notes:
- The
[showframe]
option was applied to the geometry
package
was just to show the page margins.
- The
@{}
at the start and end of the tabular
columns eliminates the column padding that is added at the start and end of the table.
- The
tabular
solution is useful if you want the figures horizontally aligned. If you don't need to align the figures (ie., you just want them distributed horizontally), the Werner's or egreg's solution is the way to go.
Code:
\documentclass{article}
\usepackage{graphicx}
\usepackage[paperwidth=25.0cm,showframe]{geometry}
\begin{document}
\begin{figure}[h]
\begin{center}$
\begin{array}{lll}
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}
\end{array}$
\end{center}
\begin{center}$
\begin{array}{rr}
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}
\end{array}$
\end{center}
\caption{Figure caption}
\label{pics:blablabla}
\end{figure}
\end{document}
Code: \centering
\documentclass{article}
\usepackage{graphicx}
\usepackage[paperwidth=25.0cm,showframe]{geometry}
\begin{document}
\begin{figure}[h]
{\centering%
\begin{tabular}{@{}lll@{}}
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}
\end{tabular}\par}
{\centering%
\begin{tabular}{@{}rr@{}}
\includegraphics[width=50mm]{example-image-b}&
\includegraphics[width=50mm]{example-image-b}
\end{tabular}
\caption{Figure caption}
\label{pics:blablabla}\par}
\end{figure}
\end{document}
usepackage{showframe}
and you will see that the page is not wide enough. The second line is centered within the\linewidth
. Also, you should usecentering
instead of thecenter
environment as per When should we use \begin{center} instead of \centering?.