2

I'm trying to plot a diagram with matplotlib and embed it in latex. I want the diagram to have the full textwidth so I printed the textwidth in points to my document with \the\textwidth. The value I've got is 418.25555pt. However when I convert this value to inches with google for instance I get: 5.80910486111. This, however, is based on the assumption that one inch equals 72 pt. This is different from the information given here: https://en.wikibooks.org/wiki/LaTeX/Lengths

It says 1 inch equals 72.27 pt. I wrote a helper function in python to convert points to inches:

import scipy.constants as sc

def figsize(scale, textwidthInPt):
    textwidthInInch = textwidthInPt * sc.pt / sc.inch  #1
    figWidthInInch = textwidthInInch * scale
    figHeightInInch = figWidthInInch / sc.golden_ratio
    return [figWidthInInch, figHeightInInch]

The line marked with #1 shows the conversion to inch. The constants from scipy are also based on the 1 in = 72 pt equality.

All my plots are slightly to wide and cause an overfull hbox warning.

Why is LaTeX different in this case?

  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE). that illustrates your problem with the plots. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. – Bobyandbob Apr 27 '17 at 13:22
  • LaTeX has two different "point" units: big points bp, and traditional printer's points pt, defined as 72.27 pt = 72 bp = 1in. – Thruston Apr 27 '17 at 13:31
  • From my own experience, you should use tight_layout() on your figures in matplotlib for the inclusion in LaTeX (just a tip). – Skillmon Apr 27 '17 at 13:33
  • See https://tex.stackexchange.com/questions/200934/why-does-a-tex-point-differ-from-a-desktop-publishing-point – Torbjørn T. Apr 27 '17 at 15:19

0 Answers0