1

I'm having an image which I need to display so that it takes up most of a page (the total width of the page to be exact). The picture itself has a larger width than height and is so big in width that it is bigger than the width of the page.

My problems so far have been that I didn't manage to let the image start (left side of the page) exactly at the start of the page and go until the right border of the page (height is no matter there as the height is smaller ofr the picture and it will be vertically centered).

Even with width=\papwerwidth the pic didnt start at one border and go to the other one (also used \noindent). So question is what can I do to fullfill my target there?

\documentclass[11pt,a4paper,BCOR10mm,DIV11,toc=listof,parskip=full]{scrbook}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}            
\usepackage{multicol}  

\begin{document}
\newpage
\includegraphics{xyz.jpg}
\end{document}

Edit: [width=\paperwidth] added tot the includegraphics scales thee image but part of it is truncated I guess thanks to the image starting not at the left border.

11
  • 1st. Question: Why would you do that? 2nd. question: Have you considered, that there is a margin width, which is the source of the horizontal offset?
    – user31729
    Jul 22 '14 at 19:10
  • 3rd issue: Please post a MWE instead of fragments
    – user31729
    Jul 22 '14 at 19:12
  • \noindent is the command to keep text/content at the left margin of a page, but it does not shift it even more to the left. You probably need an awkward \hspace{-\evensidemargin} or something like that.
    – user31729
    Jul 22 '14 at 19:17
  • 1
    @ChristianHupfer as used in an answer to the OP's previous question a minute or two ago:-) Jul 22 '14 at 19:20
  • 1
    @DavidCarlisle: I am confused! Is there a similar question? I had no idea
    – user31729
    Jul 22 '14 at 19:22
1

Here is a solution, the requires the ifoddside package. The idea is to put the insertion point at the exact center of the physical with an invisible rule, then insert the picture scaled to paper width ant put in a box of zero width:

     \documentclass[a4paper]{book}

    \usepackage[utf8]{inputenc}
    \usepackage[nomarginpar]{geometry}
    \usepackage{graphicx}
    \usepackage{ifoddpage}

    \newlength{\relevantmargin}
    \newcommand\insertpaperwidth[1]{%
    \checkoddpage\setlength{\relevantmargin}{\ifoddpageoroneside\oddsidemargin%
    \else\evensidemargin\fi}
    \par\noindent\hspace*{\dimexpr 0.5\paperwidth-1in -\hoffset -\relevantmargin\relax}%
    \makebox[0pt]{\includegraphics[width = \paperwidth]{#1}}}%

    \usepackage{lipsum}

    \begin{document}

     \lipsum[1-4]
     \vspace{2ex}

    \insertpaperwidth{Piero_di_Cosimo_1}

    \lipsum[5]\vspace{2ex}

    \insertpaperwidth{Piero_di_Cosimo_1}

    \end{document} 

enter image description here

2
  • You don't need the rule, but just \noindent\hspace*{-\dimexpr 1in+\hoffset+\relevantmargin}\makebox[0pt][l]{...}
    – egreg
    Jul 22 '14 at 22:52
  • Perfectly right. It's there because I first checked with my viewer and a rule of width 1pt that it was really the physical centre of the page. I'll change the code at once.
    – Bernard
    Jul 22 '14 at 22:56

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