2

I am using images to provide visual support to a user-guide. I "hide" captions since they are not really relevant in this situation but that leaves a big space after each figures.

I tried reducing the space with commands such as \setlength{\intextsep}{0pt} but that reduce top spacing as well which means my figures are too close up to the text, and I still have a big space at the bottom.

The current fix I use is forcing a negative vspace after each figures, which does not seem quite appropriate.

MWE

Test package
\ProvidesPackage{test}
% Floats
\floatplacement{figure}{H} % Forces default figure position to here
% Resize small figures not to stretch
\def\autoscale{
  \ifdim\Gin@nat@width<\linewidth
    \Gin@nat@width
  \else
    \linewidth
  \fi
}
\newcommand{\includeimage}[1]{
  \IfFileExists{#1}{\includegraphics[width=\autoscale]{#1}}{\break}
}
Document
\documentclass[10pt, a4paper, titlepage, draft]{article} % A4 = 210x297mm
\usepackage{caption}
\usepackage{etoolbox}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage[
  margin          = 2cm,
  top             = 75pt,
  bottom          = 75pt,
  headheight      = 28.5pt,
  headsep         = 12pt,
  footskip        = 36pt,
  heightrounded,
  marginparwidth  = 0pt,
  marginparsep    = 0pt,
  verbose,
]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{pdftexcmds}
\usepackage{subcaption}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{xifthen}
\usepackage{test}
\begin{document}
\lipsum[4]
\begin{figure}[h]
  \centering
  \includeimage{img/1.png}
  % \caption{no caption}
  \label{fig:1}
\end{figure}
\lipsum[11]
\begin{figure}[h]
  \centering
  \includeimage{img/2.png}
  % \caption{no caption}
  \label{fig:2}
\end{figure}
\end{document}

The images are ~1350px by ~700px.

Screenshots

Here are some screenshots describing the issue:

  1. Current situation

Current situation

  1. Expected output

Expected output

Grey shapes are text, white ones are figures. I would like to have both of them fitting in the same page by reducing the bottom padding after the first one.

I am open to using any useful package to do so.

  • @CarLaTeX I added a MWE that should reproduce the issue as described. – Florian Feb 27 '17 at 15:37
  • Thank you for adding a MWE, but: 1) what is test package? 2) do you intend \includegraphics instead of \includeimage? 3) put example-image-a (or similar) from graphicx package instead of your own images, because we don't have them. – CarLaTeX Feb 27 '17 at 17:32
  • Did you try adding the\raggedbottom directive in your preamble? B.t.w., what's the point of adding a \label if you can't cross-reference the figure? – Bernard Feb 27 '17 at 21:01
  • @CarLaTeX My bad, forgot to add the package to my MWE. It is a simple rework of the includegraphics function to automatically format figures properly (for the purpose of my document). – Florian Feb 28 '17 at 9:43
  • You do not use a caption, and from the code for package test I deduce that you do not want your images to be placed by the LaTeX algorithm either, but to occur were you put them (hence placement specification H). My question would then be, why bother with the figure environment at all. Instead, just call \includegraphics{} (without \begin{figure}...\end{figure} directly in the text. That will place your image where you put it (i.e. not floating) and should IMHO also get rid of any additional spacing around it. – Manuel Weinkauf Feb 28 '17 at 11:08
2

How about not using the figure environment.

\documentclass[10pt, a4paper]{article}
\usepackage{graphicx}
\usepackage{mwe}
\usepackage{float}


\begin{document}
\section{With \texttt{figure} environment}
\lipsum[4]

\begin{figure}[H]
\centering
\includegraphics{example-image-a}
\end{figure}

\lipsum[2]

\clearpage
\section{Without \texttt{figure} environment}
\lipsum[4]

\includegraphics{example-image-a}

\lipsum[2]

\end{document}

However, in this true minimal working example you will see, that the space around figure is not extraordinarily large, and not larger below the figure than above, when there is no caption. I personally find the space introduced by figure quite appropriate, more so than with a simple \includegraphics{} (no space at all). This suggests that something else in your code messes around with those spaces, if you get such weird results.

  • You are right. I guess I was used to wrapping images in a figure environment so I did not think about just including the picture. Thank you very much for your help. – Florian Feb 28 '17 at 13:04

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.