Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Some figures in my LaTeX document I am generating with Python. Normally I manually check how wide my picture can be with \showthe\columnwidth and adjust the image width accordingly. (This whole is important for not resizing text labels)

Is there a way that I can write this to a file, so I can do this magically? The \columnwidth is always the same through my document, so it only has to be written once. It would be especially nice if the file is not rewritten when the value hasn't changed (good for my Makefile).

share|improve this question

1 Answer 1

up vote 6 down vote accepted

This seems to do what you want.

\newdimen\tempcolwidth \tempcolwidth0pt

I should point out that if your file is called foo.tex, then this will produce a file called foo.width which contains the line \tempcolwidth =...pt where the ... is the actual width of the column. If after reading in the file, \columnwidth and \tempcolwidth agree, then the file is not written. Otherwise, the file is opened and the value of the column width written out.

share|improve this answer
Works great! Thanks! –  Peter Smit Dec 16 '10 at 10:44
@Peter: One thing to keep in mind is that TeX uses printer's points which are 72.27pt to 1 inch. Postscript and many other desktop software use 72pt to 1 inch. (TeX supports this latter unit, but calls it a big point. That is 72.27pt = 72bp = 1in.) –  TH. Dec 16 '10 at 11:06
Thanks for the hint! I knew it actually (and was already using that measure) but it is probably very useful for anyone browsing by this question. –  Peter Smit Dec 16 '10 at 11:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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