0

I try to place images with a fixed width from the section title. My question somehow is close to this one, though not covered in the response: How do I remove white space before or after the figures and tables?

I slightly modify the MWE from there, so that it just has a section and a figure. I want the distance between section and figure to be always \baselineskip, not more or less. The image is not allowed to float so I use the package float and [H] for placement. In the case an image is at the end of the page it should move the title and the image to the next page.

\documentclass[11pt,a4paper,twoside,openany]{scrbook}


\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[demo]{graphicx}

\raggedbottom 
\RedeclareSectionCommand[
  beforeskip=2\baselineskip,
  afterskip=\baselineskip
]{section}

% provides the H option
\usepackage{float}

% produces random text for testing
\usepackage{blindtext}

\begin{document}

\section{Test}

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\end{figure}

\blindtext[2]

\section{Test}

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\end{figure}

\end{document}
  • 2
    why use figure at all here? You do not want it to float, and you have no caption so just use \includegraphics directly – David Carlisle Jan 3 '18 at 9:42
  • note if you supply both height and width keys then the image will be distorted, it is usually best to just use one or the other. – David Carlisle Jan 3 '18 at 9:43
  • you're so right! sometimes the obvious is too close to see! – Martin Mueller Jan 3 '18 at 10:00
1

You do not want it to float, and you have no caption so you do not need figure just use \includegraphics directly, perhaps centred using

\makebox[\textwidth]{\includegraphics.....

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.