Graphics, Figures & TablesResize an image to full page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
anta40
Posts: 38
Joined: Thu Sep 11, 2008 2:36 pm

Resize an image to full page

Post by anta40 »

How to stretch an image so it fits in a page?

Here's my attempt:

Code: Select all

\documentclass[twocolumn, 11pt]{article}
\usepackage{fancyhdr}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{graphicx}

\renewcommand{\headrulewidth}{0.1pt}
\fancyhf{} 
\fancyhead[L]{\small ICACSIS 2009} 
\fancyhead[C]{} 
\fancyhead[R]{\small ISBN:xxxxx} 
\renewcommand{\headrulewidth}{0.1pt} 
\fancyfoot[C]{\thepage} 
\renewcommand{\footrulewidth}{0.1pt} 
\pagestyle{fancy}

\begin{document}

\begin{titlepage}
\includegraphics[width=\paperwidth,height=\paperheight]{designcover.jpg}
\end{titlepage}

\newpage
\pagestyle{fancy}
\lipsum[1-4]

\newpage
\lipsum[5-7]

\newpage
\lipsum[8-11]

\end{document}
The image is too big so some of the parts are not visible.
Beside, there's an extra empty page before the image.

Recommended reading 2024:

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

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

fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Resize an image to full page

Post by fatra2 »

Hi there,

You are confusing the compiler with the command:

Code: Select all

\includegraphics[width=\paperwidth,height=\paperheight]{designcover.jpg}
You are telling to include the figure, at paperwidht and paperheight. LaTeX compiler will always try to keep the proportion of your figure, therefore confusing it.

If you want your image to span over the full page, you need to choose either the "textwidth" or "textheight" command. Choose wisely, so your image does not overfill your page.

By the way, I would leave the command "paperwidth" out, since you probably want to have a bit of a buffer zone, so that the printout is correct.

Cheers
User avatar
anta40
Posts: 38
Joined: Thu Sep 11, 2008 2:36 pm

Resize an image to full page

Post by anta40 »

OK. I changed it into this:

Code: Select all

\documentclass[a4paper, 11pt]{article}
\usepackage{fancyhdr}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{pdfpages}

\renewcommand{\headrulewidth}{0.1pt}
\fancyhf{} 
\fancyhead[L]{\small ICACSIS 2009} 
\fancyhead[C]{} 
\fancyhead[R]{\small ISBN:xxxxx} 
\renewcommand{\headrulewidth}{0.1pt} 
\fancyfoot[C]{\thepage} 
\renewcommand{\footrulewidth}{0.1pt} 
\pagestyle{fancy}

\begin{document}

\begin{titlepage}
\includegraphics[height=\paperheight]{designcover.jpg}
\end{titlepage}

\end{document}
The image is still not stretched properly, and there is still an empty page before the cover.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Resize an image to full page

Post by localghost »

fatra2 wrote:[...] You are telling to include the figure, at paperwidht and paperheight. LaTeX compiler will always try to keep the proportion of your figure, therefore confusing it. [...]
That is simply wrong. Graphics files can be included in arbitrary sizes and aspect ratios. The whole thing becomes interesting when another option is added.

Code: Select all

\includegraphics[width=0.5\textwidth,height=0.5\textheight,keepaspectratio]{designcover.jpg}
This way none of the given lengths will be exceeded and the aspect ratio of the included image is kept.
anta40 wrote:How to stretch an image so it fits in a page? [...]
The answer has been given in another topic [1]. It's just about using a package.

[1] View topic: How to reset margin?


Best regards
Thorsten
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Resize an image to full page

Post by fatra2 »

Hi there,
localghost wrote:That is simply wrong. Graphics files can be included in arbitrary sizes and aspect ratios.

I believe that it will work without a problem. But why would you want to change the ratio of your graphic files, except in exceptional cases (or where you want to be funky). Otherwise, you create or have graphic files that look "good" and want to include them into a text document. There is absolutely no reason to change the ratio of the figure.

Therefore, I believe to include a graphic file, your better of to choose one of the option to keep the ratio of your file.

Cheers
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Resize an image to full page

Post by gmedina »

Hi,
fatra2 wrote:...There is absolutely no reason to change the ratio of the figure...
Right off the top of my head, I can conceive at least one situation in which changing the ratio will prove to be helpful.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Resize an image to full page

Post by fatra2 »

Hi there,
gmedina wrote:Right off the top of my head, I can conceive at least one situation in which changing the ratio will prove to be helpful.
I never said that it can never happen. I simply said that in normal (which is almost all of them) cases, there is no need for changing the ratio of a figure file. You create a figure of some type. You want to include this figure in your text, you don't necessarily want your men to have heads 20 feet long by 1/2 foot wide. This is the reason why I still believe that the choice of option should be made to fit either the textheight or the textwidth.

Of course, you can give me example where it is favourable to change the ratio, and to play with both options. But fact is that for most people writing in LaTeX is already an experience on its own. They are not seeking to experiment with the LaTeX code.

Like the first post said: the image overfills the page, leaving some parts of out, and having empty page before/after the image. We are not talking about ratio experimenting, but about including a figure to fit in the file, so it can be printed or sent by e-mail to a buddy.

Cheers
Post Reply