0

I am using this method to add 3 images as a single figure in a column such that each image appears in a different row and there's nothing else in the row. The overall figure should be in center. However, currently it's towards the left of the screen and it is starting from almost the middle of the screen instead of starting from the top (eg first line). How can I fix this? I

Currently, I get the overfull hbox too wide in paragraph error on all 3 \includegraphics lines. What might be causing it? I have looked through similar solutions but nothing seems to work.

\begin{figure}
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[width=1.5\linewidth]{standard.png}
  \caption{1a}
  \label{fig:sfig1}
\end{subfigure}%
 \newline
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[width=1.5\linewidth]{depthwise.png}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
 \newline
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[width=1.5\linewidth]{Pointwise.png}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}

I added \newline to ensure that each fig comes on the next line.

3
  • it is far more efficient to use a blank line rather than use \newline (which forces text to consider all of the figures as a single paragraph and run its line breaking algorithm to finally end up with one per line.) Commented Nov 26, 2020 at 17:46
  • I tried following the answer given below but it doesn't seem to work for me. Could you maybe take a look here? overleaf.com/5329187891vxqmmwsfgngr @DavidCarlisle
    – x89
    Commented Nov 26, 2020 at 21:22
  • did you get a chance to go through the link @DavidCarlisle
    – x89
    Commented Nov 28, 2020 at 10:07

1 Answer 1

2

The overfull \hbox comes from [width=1.5\linewidth]. Inside figure \parskip=0pt so use \par (blank line) instead of \newline. I added the [height=4cm] simply to get the example images to fit on the page.

If you remove the \topfraction definition, it will move to the next page.

\documentclass[letter]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% MWE only

\def\topfraction{0.9}

\begin{document}
 \begin{figure}
\centering% in case you want to use a narrower subfigure
\begin{subfigure}{\textwidth}
  \centering
  \includegraphics[width=0.75\linewidth, height=4cm]{example-image-a}
  \caption{1a}
  \label{fig:sfig1}
\end{subfigure}%

\begin{subfigure}{\textwidth}
  \centering
  \includegraphics[width=0.75\linewidth, height=4cm]{example-image-b}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}

\begin{subfigure}{\textwidth}
  \centering
  \includegraphics[width=0.75\linewidth, height=4cm]{example-image-c}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}

Some text to be on top of.
\end{document}
6
  • If I try your code, the alignment is fine but the height of images is smaller than desired. When I increase the height to for eg 1.5, all images move down again. It is starting from almost the middle of the screen instead of starting from the top (eg first line). However, if I only change the height of the first image, then it's starting from the top
    – x89
    Commented Nov 26, 2020 at 16:04
  • I create a demo here overleaf.com/5329187891vxqmmwsfgngr
    – x89
    Commented Nov 26, 2020 at 16:24
  • There is a limit on how large a [t] float can be (default is \def\topfraction{0.7}). Exceed that and it will become a [p] float. Commented Nov 26, 2020 at 16:48
  • Sorry, I am still not being able to comprehend how I can fix this
    – x89
    Commented Nov 26, 2020 at 21:22
  • did you get a chance to go through the link ?
    – x89
    Commented Nov 28, 2020 at 10:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .