Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Feb 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

2 Answers 2

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.

share|improve this answer
    
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%
  \addtolength{\totalleftmargin}{\ifoddpage\oddsidemargin\else\evensidemargin\fi}%
}

The ERT box directly before your graphics does then become:

\calctotalleftmargin
\hskip-\totalleftmargin\relax
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.