# LyX: set width of image to 100% of page width

When I insert an image into LyX and set it to 100% page width, its left side is not at the farthest most edge of the left page. Instead it starts where the text margin is, and since it's too large to display, it cuts off on the right. Is there a way to set a different margin for figures than that of the text?

-

## migrated from stackoverflow.comFeb 7 '12 at 20:08

This question came from our site for professional and enthusiast programmers.

Not sure about lyx but if you can go into the code then you can use the adjustwidth environment from the changepage package –  cmhughes Feb 7 '12 at 21:05

The horizontal image shift is due to the paragraph indent if you don't place the image inside a figure environment. To avoid this without inserting a figure environment, insert an ERT (or Ctrl+L) just before the image that contains \noindent. This removes the paragraph indent so that the image will fit within the text block.

-
the margin is still there. did you mean \nomargin? I tried that but it didn't work either. –  waspinator Feb 10 '12 at 19:50
@waspinator: It sounds like the original problem deals with the image being pushed out into the right margin. This is typically caused when the image is set to the text block width \textwidth but with a paragraph indent. Hence the suggestion to use \noindent, which removes the paragraph indent. Are you actually setting the image to the text block width, or the page width? –  Werner Feb 10 '12 at 19:54
I set the image to page width since it's large. Basically I wanted to apply a different margin to the image than the text. Thanks. –  waspinator Feb 14 '12 at 22:14
@waspinator: Well, if you want to modify the text block margins on the fly, than can also be done using the changepage package. You could update your original question with some more detail on specifically what you're after. You could even provide a screen shot, even if its produce in something else (like MS Word). It really helps in assessing what your best options are. –  Werner Feb 14 '12 at 22:22

To make your graphics span the full paper widht, you need a negative \hskip to compensate for the left margin. Hence, add something like this in an ERT box directly before your graphics:

\hskip\dimexpr-\hoffset-1in-\oddsidemargin-\leftskip\relax


This assumes, however, that the float will be placed on an odd page. Depending on the document class and layout options, the page margins on odd and even pages may differ. To take this into accout requires a somewhat bigger effort. Add the following to your preamble (Document->Settings->LaTeX Preamble):

\usepackage{changepage}
\strictpagecheck

\newlength{\totalleftmargin}
\newcommand{\calctotalleftmargin}{%
\setlength{\totalleftmargin}{\dimexpr+\hoffset+1in+\leftskip}%
\checkoddpage%

\calctotalleftmargin