Graphics, Figures & Tablesunwanted margin after a figure

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Maxim22
Posts: 3
Joined: Sat Jan 05, 2013 4:26 pm

unwanted margin after a figure

Post by Maxim22 »

Hi, I'm new to latex. I have the following problem:
After I have inputted a figure, I get a weird margin space on the next line. I'm just using this standard figure code so I don't think the problem lies there.

Code: Select all

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{image}
\caption{Image}
\label{fig:image}
\end{figure}
Maybe the problem lies in my header since I just copied that from a Latex template.. can anyone help me with this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

unwanted margin after a figure

Post by Stefan Kottwitz »

Hi Maxim,

welcome to the board!
Maxim22 wrote:Maybe the problem lies in my header since I just copied that from a Latex template..
So why don't you post the header? ;-) Yes, the figure code is pretty common and should not cause that problem. But I also think the header doesn't either. Could it be that the image itself has a margin?

Perhaps post a Infominimal working example and attach the image to a post. So we can really test the issue. Otherwise it's quite theoretical.

Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

unwanted margin after a figure

Post by cgnieder »

Hi Maxim22,

Welcome to the LaTeX community!

Unfortunately this piece of code won't tell us why that's happening to you. To be honest I'm not sure I even completely understood what you mean. Can you extend the code to a complete but minimal example (= Infominimal working example) that reproduces the behaviour so that we can compile and see for ourselves? Probably we will then be able to figure out what the problem is.

Regards

PS: Stefan was a minute faster :)
site moderator & package author
Maxim22
Posts: 3
Joined: Sat Jan 05, 2013 4:26 pm

unwanted margin after a figure

Post by Maxim22 »

Code: Select all

\documentclass[12pt]{article}
\usepackage[dutch]{babel}
\usepackage{amsmath}    % need for subequations
\usepackage{graphicx}   % need for figures
\usepackage{verbatim}   % useful for program listings
\usepackage{color}      % use if color is used in text
\usepackage{subfigure}  % use for side-by-side figures
\usepackage{hyperref}   % use for hypertext links, including those to external documents and URLs
\hypersetup{pdfborder={0 0 0}}
\usepackage{float}


% don't need the following. simply use defaults
\setlength{\baselineskip}{16.0pt}    % 16 pt usual spacing between lines

\setlength{\parskip}{3pt plus 2pt}
\setlength{\parindent}{20pt}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\evensidemargin}{0.5cm}
\setlength{\marginparsep}{0.75cm}
\setlength{\marginparwidth}{2.5cm}
\setlength{\marginparpush}{1.0cm}
\setlength{\textwidth}{150mm}

\begin{document}

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{senior}
\caption{Image}
\label{fig:image}
\end{figure}

text texttexttexttexttexttexttexttext text text text text text v v v v v vtexttexttexttexttexttexttexttexttext

\end{document}
here you go :)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

unwanted margin after a figure

Post by Stefan Kottwitz »

Do you mean by margin after the figure the white space below the figure, or the paragraph indentation?
figure.png
figure.png (4.47 KiB) Viewed 16603 times
The first one is pretty normal, the latter is also normal, since a new paragraph starts. It's width is caused by:

Code: Select all

\setlength{\parindent}{20pt}
You could set it to 0pt if you don't want paragraph indentation.

However it seems to me that the whole LaTeX template is old, outdated or just bad, as I can see in the preamble code. Perhaps have a look a latex-templates.com for a newer one.

Stefan
LaTeX.org admin
Maxim22
Posts: 3
Joined: Sat Jan 05, 2013 4:26 pm

Re: unwanted margin after a figure

Post by Maxim22 »

thank you, it was the paragraph indentation. I find it weird because it was the only place where I had the problem, not with the other paragraphs...
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

unwanted margin after a figure

Post by cgnieder »

Maxim22 wrote:I find it weird because it was the only place where I had the problem, not with the other paragraphs...
I'm quite surprised by that since it really is the default behaviour! See the following example:

Code: Select all

\documentclass{article}

\begin{document}

This is a paragraph which is indented like it is the default for most document
classes. This is a paragraph which is indented like it is the default for most
document classes. This is a paragraph which is indented like it is the default
for most document classes.

This is a paragraph which is indented like it is the default for most document
classes. This is a paragraph which is indented like it is the default for most
document classes. This is a paragraph which is indented like it is the default
for most document classes.

\section{A section title}
This is a paragraph which is not indented like because it follows a section
title. This is normal for most document classes but may change if one uses
specific language settings.

This is a paragraph which is indented like it is the default for most document
classes. This is a paragraph which is indented like it is the default for most
document classes. This is a paragraph which is indented like it is the default
for most document classes.
\end{document}
paragraphs.png
paragraphs.png (57.04 KiB) Viewed 16600 times
Regards
site moderator & package author
Post Reply