1

so my problem right now is that I don't find a proper way of inserting my pictures correctly inside my text. I tried using \begin{figure*}, \begin{figure}, \begin{center} and I tried using subfigures and \maketable and nothing really works. Right now I am having this code:

\begin{figure}
  \centering
    \includegraphics[width=\textwidth, height=1.5]{OneK.png}
     \caption{Screenshot with k = 1}
  \end{figure}
\FloatBarrier

  \begin{figure}
    \includegraphics[width=\linewidth, height=0.5]{FourK.png}
    \caption{k = 4}
  \end{figure}
  \FloatBarrier

  \begin{figure}
    \includegraphics[width=\textwidth, height=0.5]{FinalScreenshot.png}
    \caption{k = 12 + curve}
  \end{figure}    
\FloatBarrier

However, the first figure is floating to the other section, even though I want all these images to be in the other subsection. Moreover, I want to change size, it doesn't, so I am having a two column text and want to fit these three figures as such they are readable, but do not take more than half a page. All three images are screenshots. So basically, I want the first two pictures to be side by side, and the last pictures to be below the first two but then with all the width of the two columns. Can you help me please?

My document looks as follows (I deleted the text):

\documentclass[11pt,a4paper]{article}
\usepackage[hyperref]{acl2020}
\usepackage{times}
\usepackage{latexsym}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\usepackage{placeins}
\renewcommand{\UrlFont}{\ttfamily\small}


\usepackage{microtype}

% Determine if the image is too wide for the page.
\makeatletter
\def\ScaleIfNeeded{%
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother

% Resize figures that are too wide for the page.
\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
  \oldincludegraphics[width=\ScaleIfNeeded]{#2}
}


\aclfinalcopy % Uncomment this line for the final submission
%\def\aclpaperid{***} %  Enter the acl Paper ID here


\newcommand\BibTeX{B\textsc{ib}\TeX}

\title{Coursework 1}

\begin{document}

%\maketitle
 \thispagestyle{plain}%
\section{Task A: k-means clustering}
Text in here

\subsection{Task A: Screenshots of running program}

\begin{figure}
  \centering
    \includegraphics[width=\textwidth, height=1.5]{OneK.png}
     \caption{Screenshot with k = 1}
     \label{fig:Figure 1}
  \end{figure}
\FloatBarrier

  \begin{figure}
  \centering
    \includegraphics[width=\linewidth, height=0.5]{FourK.png}
    \caption{k = 4}
    \label{fig:Figure 2}
  \end{figure}
  \FloatBarrier

  \begin{figure}
  \centering
    \includegraphics[width=\textwidth, height=0.5]{FinalScreenshot.png}
    \caption{k = 12 + curve}
    \label{fig:Figure 3}
  \end{figure}

\FloatBarrier

\subsection{Task A: Figure and Analysis}

\begin{figure}[!htbp]
    \begin{center}
    \includegraphics[width=.4\textwidth]{elbow_curve.png}
    \end{center}
    \caption{Elbow curve}
    \label{fig:Figure 4}
\end{figure}
\FloatBarrier



\section{Task B: Classification with k-nearest neighbor}






%References - needs no heading
\bibliography{bib}
\bibliographystyle{apa}

\end{document}
  • Welcome to TeX.SX! Can you post the code of a small complete document, beginning with \documentclass and ending with \end{document}, such that we see the general document setup, like document class, settings, packages? – gernot says Reinstate Monica Nov 8 at 19:17
  • I edited my text thank you – darned7 Nov 8 at 19:21
  • not directly related to the question but don't do: width=\textwidth, height=1.5 don't supply both height and width or you will distort the image, use one or the other. Also the default units are bp (PostScript Points) so height=1.5 will be barely visible around a 1/3 the height of an x – David Carlisle Nov 8 at 19:21
1

As far as I understand the question you want a layout like:

enter image description here

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{figure}[htp]

\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Zzzz}
\end{minipage}\hfill
\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{Zzz zz}
\end{minipage}

\bigskip

\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{Zz Zzz z}
\end{minipage}\hfill
\begin{minipage}{.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Zz zz zz z}
\end{minipage}

\end{figure}
\end{document}
  • almost, yes, thank you. However, I want Figure 1 to be the size of the first column, Figure 2 on the side of the second column, and Figure 3 as large as figure 1 and 2 combined. But this looks definitely better than before. Thank you! – darned7 Nov 8 at 19:49
  • so get rid of the two minipages in the second row and have the \includegraphics and \caption directly in figure so they are full width. @darned7 – David Carlisle Nov 8 at 19:57
  • this works so far. Thank you! – darned7 Nov 9 at 8:29

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.