Generalfigure doesn't use default margin

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
dp_
Posts: 6
Joined: Sat Jun 07, 2008 8:14 pm

figure doesn't use default margin

Post by dp_ »

Hi,

I encountered another problem during my work with Latex.

My figures don't use default margins.

My margin setting looks that:

Code: Select all

\usepackage[lmargin=3cm,rmargin=2cm,tmargin=2.5cm,bmargin=2.5cm]{geometry}
This is my default figure:

Code: Select all

\begin{figure} [h]
\counterwithin{figure}{section}
\footnotesize
\begin{verbatim}
some code
\end{verbatim}
\normalsize
\caption{some caption}
\end{figure}
And the problem is, that my figure goes to the left and doesn't use any of margins defined in geometry package. I was trying to find some solution for this issue, but I have some problems with creating query to google, because I don't know how to call this problem.

I will be grateful for any help,

Best regards

Recommended reading 2024:

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

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

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

figure doesn't use default margin

Post by Stefan Kottwitz »

Hi,

can you give a minimal working example, that shows the problem?

After I completed your tex code to make it compilable I tested this:

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage[lmargin=3cm,rmargin=2cm,tmargin=2.5cm,bmargin=2.5cm]{geometry}
\usepackage{chngcntr}
\begin{document}
\section{One}
\begin{figure} [h]
\counterwithin{figure}{section}
\footnotesize
\begin{verbatim}
some code
\end{verbatim}
\normalsize
\caption{some caption}
\end{figure}
\end{document}
The left margin is used. What happens if you compile this example?

By the way perhaps the listings package could be useful for you to typeset code.

Stefan
LaTeX.org admin
dp_
Posts: 6
Joined: Sat Jun 07, 2008 8:14 pm

Re: figure doesn't use default margin

Post by dp_ »

Hi,

OMG, I feel so stupid now..

After your post I looked carefully at my document, and I saw the difference. Everything with margins is OK, I didn't end description list on the previous page and on the page with figure everything was moved to the right except for figure, and it looked like problem with left margin :) After correction everything works great.

Sorry for that and thanks for response.
Post Reply