4

Possible Duplicate:
Why isn't \textwidth the width of the text?

After some gruelling work, I reduced my problem to this MWE:

\documentclass{article}

\usepackage{rotating}

\begin{document}
\includegraphics[width=\textwidth]{Rolemaster.pdf}
\end{document}

The PDF included by this snippet is actually a potrace of a bitmap, and according to TeX of ~470pt width:

<Rolemaster.pdf, id=1, 469.755pt x 91.34125pt>

That's why am using the width=\textwidth parameter to includegraphics, to scale the included PDF down to fit. However, I am getting this warning:

Overfull \hbox (15.0pt too wide) in paragraph at lines 6--7

Why does this happen, and what would be the correct parameter to width to result in max-width fit without a warning?

I did some trial & error, with (for me) surprising results. Going from the above warning ("15.0pt too wide") I tried:

\includegraphics[width=\textwidth - 15pt]{Rolemaster.pdf}

Getting:

Overfull \hbox (65.00009pt too wide) in paragraph at lines 6--7

So obviously there's something non-trivial going on behind the scenes, screwing with my numbers. Using fixed numbers, I figured that

\includegraphics[width=330pt]{Rolemaster.pdf}

does what I want, but quite obviously this isn't acceptable since I am not in a mind of peppering my document with "magic numbers" like that. There has to be some constant (or sum of constants) that would result in the proper max width. But I have no idea which one that would be...?

DevSolar
  • 7,857
  • 3
    There's the normal indentation: put \noindent before \includegraphics – egreg Sep 19 '12 at 15:09
  • @egreg: Turn that into an answer and you get the checkmark of honor. I probably wouldn't have thought about indent, ever... – DevSolar Sep 19 '12 at 15:13
  • @egreg: Any idea how reducing the width of the PDF by the excessive 15pt makes it another 65pt too wide? – DevSolar Sep 19 '12 at 15:20
  • @StephanLehmke: Agreed. – DevSolar Sep 19 '12 at 15:22
  • 1
    @DevSolar You need the calc package for that kind of calculation. Without it, it just typesets -15pt in front of your graphic. – Qrrbrbirlbel Sep 19 '12 at 15:23
  • @DevSolar If you look at the PDF you'll see that - 15pt is typeset. You can't do arithmetic in that way; width=\dimexpr\textwidth-15pt\relax would be correct syntactically, but resulting in wrong output, as the picture would be indented. – egreg Sep 19 '12 at 15:26
  • Another advice: most of the time, it is better to use \linewidth than \textwidth. – Paul Gaborit Sep 19 '12 at 15:48
  • @PaulGaborit: Any hint as for when the two might not actually be the same? (Nevermind... found it.) – DevSolar Oct 05 '12 at 13:02

0 Answers0