3

I'm trying to insert a graphic and stretch it to textwidth and textheight. I get a overfull box and an empty page befor the graphic. But it works when I only strech in horizontal reps vertical direction. Why I can't stretch in both directions?

This works as I want

\documentclass[]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\pagestyle{empty}

\begin{document}
    \includegraphics[height=\textheight]{example-image-a}
\end{document}

But this yields an overfull vbox and an empty page

\documentclass[]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\pagestyle{empty}

\begin{document}
    \includegraphics[height=\textheight, width=\textwidth]{example-image-a}
\end{document}

The only difference is the width=\textwidth.

4
  • Anyway specifying both will distort your image.
    – Bernard
    Commented Apr 6, 2016 at 15:00
  • It's a small distortion and it's necessary because the graphics will be printed in a large, given format and exhibited. It's not possible to change the inserted graphics so I have to stretch them. Anyway I wonder, why it doesn't work with includegraphics. Commented Apr 6, 2016 at 15:03
  • Fix: \includegraphics[height=.9999\textheight,width=\textwidth]{example-image-a}. Sounds like a roundoff issue. Note that an extra 9, that is .99999, breaks it again. Commented Apr 6, 2016 at 15:05
  • To avoid overfull hbox I also need width=.9999\textwidth. I also think, it's a roundoff issue because the log says 0.16693pt to high. Commented Apr 6, 2016 at 15:19

1 Answer 1

2

The issue appears to be one of roundoff. Changing

\includegraphics[height=\textheight, width=\textwidth]{example-image-a}

to

\includegraphics[height=.9999\textheight, width=\textwidth]{example-image-a}

fixes the problem, whereas an extra 9,

\includegraphics[height=.99999\textheight, width=\textwidth]{example-image-a}

breaks it again. Such roundoff issues should not be too surprising, if one considers that constraining both the height and width is not a pure scale, but will require several constrained length multiplications in order to determine the final aspect and dimensional scale.

This MWE demonstrates the issue:

\documentclass[]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\pagestyle{empty}
\newsavebox\tmpbox

\begin{document}
\the\textheight{} actual textheight

\savebox\tmpbox{\includegraphics[height=.9999\textheight,width=\textwidth]{example-image-a}}
\the\ht\tmpbox{} .9999 is below

\savebox\tmpbox{\includegraphics[height=.99999\textheight,width=\textwidth]{example-image-a}}
\the\ht\tmpbox{} .99999 is above

\savebox\tmpbox{\includegraphics[height=\textheight,width=\textwidth]{example-image-a}}
\the\ht\tmpbox{} scaled to textheight is above
\end{document}

enter image description here

4
  • cf latex-project.org/cgi-bin/ltxbugs2html?pr=graphics/4451
    – user4686
    Commented Apr 6, 2016 at 15:22
  • @jfbu Thanks for the pointer to what I knew had to be a known issue. Commented Apr 6, 2016 at 15:23
  • 1
    I encountered it there tex.stackexchange.com/questions/291839/… see the comments below my answer
    – user4686
    Commented Apr 6, 2016 at 15:24
  • 1
    It should be noted, however, that the rounding error is below the usual \hfuzz/\vfuzz threshold, even in a case like this, in which relatively large dimensions are involved. So, the only issue is the first empty page, due to the well-known problem of the initial \write-1{} before the first \topskip glue. In other words, what I am trying to say is that this is a rather exceptional example.
    – GuM
    Commented Apr 6, 2016 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .