3

I'm trying to insert three images, next to each other horizontally, across the width of a page. At the moment they are going on top of each other and not next to each other.

\begin{figure}[H]  
   \centering  
   \includegraphics{"Plot 2".png}  
  \includegraphics{"Plot 3".png}  
  \includegraphics{"Plot 4".png}  
  \caption{Data Set 1 - split by country}  
  \label{fig:Data Set 1 - split by country}  
\end{figure}
3

or simply:

\documentclass{article}
\usepackage{graphicx} % to use example images
%---------------------------------------------------------------%
\usepackage{showframe}% fro whow page layout
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{figure}[ht]
    \centering
\includegraphics[width=0.3\linewidth]{example-image}\hfil
\includegraphics[width=0.3\linewidth]{example-image}\hfil
\includegraphics[width=0.3\linewidth]{example-image}
\caption{Data Set 1 - split by country}
\label{fig:Data Set 1 - split by country}
\end{figure}
\begin{figure}[ht]
\includegraphics[width=0.3\linewidth]{example-image}\hfill
\includegraphics[width=0.3\linewidth]{example-image}\hfill
\includegraphics[width=0.3\linewidth]{example-image}
\caption{Data Set 1 - split by country}
\label{fig:Data Set 1 - split by country}
\end{figure}
\end{document}

enter image description here

  • This is a great solution. Do you have more information (in the form of a link, maybe) about the differences between different types of horizontal/vertical spaces? – El Andi May 15 '17 at 0:10
  • @ElAndi, for starting point can serve "No so short introduction to LaTeX ...", it can be easily find with google :). Here on site is plenty of similar question, search for them. – Zarko May 15 '17 at 0:23
3

You can use horizontal fills to get that, but you need to give the images a relative width, check this out:

\documentclass{article}
\usepackage{graphicx} % to use example images
\usepackage{showframe} % to show magins

\begin{document}
\begin{figure}
\includegraphics[width=0.3\linewidth]{example-image}\hspace*{\fill}%
\includegraphics[width=0.3\linewidth]{example-image}\hspace*{\fill}%
\includegraphics[width=0.3\linewidth]{example-image}
\caption{Data Set 1 - split by country}
\label{fig:Data Set 1 - split by country}
\end{figure}
\end{document}

enter image description here

It's also possible to center the group of images, if you don't want them to hit the margin (or you want to show them at smaller sizes). Just add more horizontal fills at the beginning and the end:

% Same preamble as above
\begin{document}
\begin{figure}
\hspace*{\fill}\includegraphics[width=0.3\linewidth]{example-image}
\hspace*{\fill}\includegraphics[width=0.3\linewidth]{example-image}
\hspace*{\fill}\includegraphics[width=0.3\linewidth]{example-image}\hspace*{\fill}%
\caption{Data Set 1 - split by country}
\label{fig:Data Set 1 - split by country}
\end{figure}
\end{document}

enter image description here

  • 1
    note you are adding 1 word space + fill in the first case which is OK so long as 2 word spaces are less than .9\lineskip, but safer to comment out the extra space \hspace*{\fill}% – David Carlisle May 15 '17 at 6:41

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.