General ⇒ adusting figures
adusting figures
I am not sure what is wrong, but I am having some problems in getting figures adjusted in latex-pdf files. Let me explain what I am doing.
I draw figures in MS-Word with margins of 1 inch on all the sides. The figures are centered in Word. Then I convert this file into pdf. Still the figures are centered and well-placed on the page in pdf.
In the preamble of latex code I use
\usepackage{geometry}
\usepackage{graphicx}
I use following command in latex to import this figure....
\begin{figure}[hpt]
\centering
\includegraphics[width=20cm]{figure1}
\caption{Best Response Function}
\end{figure}
However, the figure is not in the center when latex-file is created. For some figures I even lose some portion on the right side when there is too much space left empty. By the way, I am keeping 25mm margins on all sides of latex-pdf file.
Where is the problem? How do I get figures well-placed in latex-pdf?
Thank you in advance. Regards,
Omkar
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
adusting figures
your code seems to be ok!
Which paper size do you use? One earlier posting of you mentioned a4paper as documentclass option. a4 has the size 210x297mm, the figure of your example code has a width of 20cm, together with the margin of 25mm that seems to big. Or do you use landscape orientation?
Check if the size of the picture is not too big. Try to make it smaller and look if it is centered then. Oversized pictures may be not centered, there's one trick to include and center them though, use \makebox:
Code: Select all
\makebox[0cm]{\includegraphics{widepicture}}
Re: adusting figures
I use a4 paper for latex-pdf. I am using portrait style for documentation. The figure with width of 20cm with left-right margins of 25 mm is also fitting in the latex-pdf, however, it is does not get placed at the center from left and right side. I guess it is getting right aligned. I do not need the figure to be in center from top and bottom. If I reduce the width to 18cm, then there is too much of gap between the end of figure in the bottom and the caption. For 20cm width, caption would not print.
I am having similar issues with other figures which are too small. I don't need entire page for
the figure. I should be able to have text below or above the figure.
Please find the attached files and how it looks.
Thank you,
Omkar
- Attachments
-
- with 18cm width.JPG (26.17 KiB) Viewed 11425 times
-
- fig1.pdf
- (34.28 KiB) Downloaded 289 times
Re: adusting figures
I use a4 paper for latex-pdf. I am using portrait style for documentation. The figure with width of 20cm with left-right margins of 25 mm is also fitting in the latex-pdf, however, it is does not get placed at the center from left and right side. I guess it is getting right aligned. I do not need the figure to be in center from top and bottom. If I reduce the width to 18cm, then there is too much of gap between the end of figure in the bottom and the caption. For 20cm width, caption would not print.
I am having similar issues with other figures which are too small. I don't need entire page for
the figure. I should be able to have text below or above the figure.
Please find the attached files and how it looks.
Thank you,
Omkar
- Attachments
-
- with 20cm width.JPG (37.01 KiB) Viewed 11418 times
-
- with 18cm width.JPG (26.17 KiB) Viewed 11418 times
-
- fig1.pdf
- (34.28 KiB) Downloaded 302 times
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
adusting figures
I can see the problem. The included pdf pictures have a4 paper size too, that's why they are too big. They already have a margin around the original picture. The clean solution would be saving the pictures without white borders, not in a4 size, just the pictures themself.
If that's not easily possible you can trim the pdf images, for example:
Code: Select all
\begin{figure}[ht]
\centering
\includegraphics[trim = 3cm 8cm 2cm 3cm]{fig1.pdf}
\caption{Process Flow Chart}
\end{figure}
Re: adusting figures
Thank you for the advice.
How do I save only pictures? I am not sure. At the same time let me try your code with trimming.
by the way, there is one more issue. Why do I need to have one picture on the entire page? Can't I have picture as well as text above and below the picture, if space permits?
Thank you,
Omkar
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
adusting figures
I don't use MS Word and I only know former versions of it, nothing about it's pdf capabilities. Perhaps you can change the word document layout the way that you don't have margins left, right, below, above, then save it as pdf. Then you don't have the additional margins when you include them.
Some graphic software should do it better. But in the meantime you may use the trim option of \includegraphics. You just have to find out the right margin sizes. No problem if it's not perfect, the picture will be centered if it fits to the page.
TeX tries to place the figure where it should be typographically best, that may be empty pages. You could force the position for instance by using the H option of the float package, or !htbp options to the figure. One example:
Code: Select all
\documentclass[a4paper,10pt]{book}
\usepackage[vmargin={25mm,25mm},hmargin={25mm,25mm}]{geometry}
\usepackage{graphicx,float}
\begin{document}
text text
text text
\begin{figure}[H]
\centering
\includegraphics[trim = 3cm 8cm 2cm 3cm, height=18cm]{fig1.pdf}
\caption{Process Flow Chart}
\end{figure}
more text
more text
\end{document}
Stefan
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
adusting figures
Best regards
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10