[Tex/LaTex] Where is the left-hand margin

calculationslengthsmargins

I'm working on the TikZ-from-TeX-SX package, specifically developing the code for putting equation numbering at places within a tikzpicture environment. To do this, I need to know where the text starts and stops horizontally on the page. From looking at a couple of diagrams, it seems that the left-hand margin is at: \hoffset + 1in + \oddsidemargin (but that \oddsidemargin worries me somewhat!) and to get the right-hand margin I add \textwidth.

So the question: how do I reliably figure out where my left and right margins are (as measured from, say, the left-hand edge of the page)?

If it matters, then I'd rather go for where TeX thinks they are than where they actually are. Namely, if there's some grouping in which the user has changed a load of lengths that fool TeX temporarily, but where that fooling is over before TeX actually puts anything on the page, then I'll join TeX in its dream-world.

Also, I guess that knowing which page I'm on will be important. In which case, I'm allowed to have two TeX runs to figure it out since I already need two TeX runs for some other stuff in the package.

(Note: This question is absolutely nothing to do with TikZ)

Best Answer

\hoffset + 1in + \oddsidemargin + \leftskip and for right margin, add \textwidth - \rightskip.

For display material, there is also \displayindent and \displaywidth.

I should also mention the layout package.

Related Question