When I enter the following:

text width in cm: \printinunitsof{cm}\prntlen{\textwidth}

text height in cm: \printinunitsof{cm}\prntlen{\textheight}

I see output:

text width in cm: 15.11078cm
text height in cm: 21.58693cm

However, when I create an image exactly 15cm by 21cm, and insert it into my document, it is far too large, by about the amount of the margin sizes.

I was under the impression that textwidth was supposed to be only the text box, already accounting for margins. Why is the output I see too large?

I'm looking to include some pre-sized images in my document but can't divide the page in any reasonable way without knowing how large it is. Any hints on what is going on with the output above, or how I might do this better?

EDIT, updated to include MWE

\usepackage{graphicx} % Required for inserting images


text width in cm: \printinunitsof{cm}\prntlen{\textwidth}

text height in cm: \printinunitsof{cm}\prntlen{\textheight}

line width in cm: \printinunitsof{cm}\prntlen{\linewidth}

column width in cm: \printinunitsof{cm}\prntlen{\columnwidth}





Now, run this, you'll see this output:

text width in cm: 13.70499cm
text height in cm: 19.27483cm
line width in cm: 13.70499cm
column width in cm: 13.70499cm
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut...

Go to your favorite image program, and make a colored rectangular image corresponding to what this output says the text size is, that is 13.7cm x 19.2cm.

Uncomment the insert image above,


When you do you, and rerun it, you will see that the image extends well into the footer area. The output of \textwidth and and \textheight just isn't corresponding to the text box---these commands don't seem to account for margins, headers, footers---but I was under the impression this is exactly what the text box ought to correspond to---the printable part of the page, after you deduct all the rest.

  • Please provide a minimum working example (MWE) of the code that's giving you problems.
    – Mico
    Commented Sep 21, 2011 at 18:11
  • Yeah, OK, it looks like it's one of the packages I'm using that is giving me a different value for \textwidth Not sure which is the culprit... Commented Sep 21, 2011 at 18:31
  • Really wish I could find this, actually. Apparently one of the packages I have in my preamble is causing the value these commands output to be too large. Fancyhdr and geometry look most likely, but unsure. Commented Sep 21, 2011 at 18:42
  • 2
    we've discovered that even if no dimensions are reset, the geometry package does have an effect on the settings in the ams document classes. we're telling our authors never to use it in documents submitted to ams for publication since it wreaks havoc with what we prepare for pdf-to-plate reproduction. Commented Sep 21, 2011 at 18:50
  • 1
    @barbarabeeton The last releases of geometry provide a pass option, that will prevent its default to be applied to the document. This is useful for exploiting its \newgeometry feature. But since AMS classes use a very different method for setting the page shape parameters, I agree that your advice is good.
    – egreg
    Commented Sep 21, 2011 at 21:36

2 Answers 2


Create a complete example which shows that it doesn't work. Here is an example which shows that it is possible:





The second page of my test document:

enter image description here

  • Hmmm, so, are you saying the solution is to specify height, in addition to width in the \includegraphics statement? Or to not surround it in an mbox? Because including an image the exact size of the output of \textwidth and \textheight still is not working, and if those are actually dimensions of the text box area, it really seems like like they should work. Commented Sep 23, 2011 at 9:23
  • 1
    You have to specify both, if you want to keep the aspect ration then use \includegraphics[width=\textwidth,height=\textheight,aspectratio]{tiger}
    – user2478
    Commented Sep 23, 2011 at 9:29
  • 1
    I agree that that keeps the aspect ratio, but it doesn't address my question in that when I create an external image corresponding to the output of the \textwidth and \textheight commands, it still doesn't fit---it's too big. I know that I can resize as you suggest within LaTeX, but my concern is why including an image of exactly these dimensions behaves differently than when they are specified internally, as you suggest. Thanks! Commented Sep 24, 2011 at 13:03

Since it appears that it's one of the packages you're loading that's giving you trouble, try modifying your document's preamble along the following lines (I'm assuming just by way of example that your paper dimension is "A4", but it could be anything else too, obviously):

--- load your other packages here ---

By passing the option "a4paper" to the geometry package explicitly, any untoward redefinitions of variables such as \paperwidth will be undone.

If you know that your paper size is, say, exactly 15.1m wide and 21.6cm high, you should of course load the geometry package as follows:


or, more readably, as


You must log in to answer this question.

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