1

For a paper, I am using the following class:

\documentclass[utf8]{frontiersSCNS}

Within this class, I would like to place two images next to each other. None of these answers work for me.

The code below works, but locates pictures below each other instead of next to each other.

\begin{figure}[!tbp]
  \centering
  {\includegraphics[width=0.5\textwidth]{Interpretability VS. AUC_20.pdf}}
  \hfill
  {\includegraphics[width=0.5\textwidth]{Interpretability VS. AUC_all.pdf}}
  \caption{Coherence scores for topic models with the top 10 and 20 words.}
  \label{fig:coherence_linechart}
\end{figure}

How can I get my images next to each other into one picture?

Werner
  • 603,163
Emil
  • 370

1 Answers1

3

Consider your code (with line numbers added for reference):

1: \begin{figure}[!tbp]
2:   \centering
3:   {\includegraphics[width=0.5\textwidth]{Interpretability VS. AUC_20.pdf}}
4:   \hfill
5:   {\includegraphics[width=0.5\textwidth]{Interpretability VS. AUC_all.pdf}}
6:   \caption{Coherence scores for topic models with the top 10 and 20 words.}
7:   \label{fig:coherence_linechart}
8: \end{figure}

Without a line-ending % on line 3 you're effectively introducing an additional space after the first image. Since you're scaling both images to 0.5\textwidth, together they won't fit within the text block horizontally since the additional space makes the entire line wider than \textwidth. Either introduce a line-ending % after the first image (and remove the unnecessary \hfill), or reduce the scaling to tolerate a space between the two images:

\begin{figure}
  \centering
  \includegraphics[width=0.49\linewidth]{<image_1>}%
  \hfill
  \includegraphics[width=0.49\linewidth]{<image_2>}%

\caption{<caption>} \label{<label>} \end{figure}

Werner
  • 603,163