# Getting layout parameters from the geometry package

The geometry package provides a simple way to set layout parameters. For example,

\usepackage[margin=1in]{geometry}


will give me a document with 1 inch margins on each side. In particular, it computes the LaTeX parameters like \textwidth, \oddsidemargin, \textheight, and \topmargin, among others. Is it possible to retrieve the 'friendlier' values like left, right, top, and bottom?

Of course, one can compute the values using something like \dimexpr \topmargin + \headheight + \headsep + 1in \relax. There's also the further complication that the includehead and includefoot options influence the setting of the parameters.

-

The values are stored in pt in commands like \Gm@lmargin, \Gm@tmargin etc. If you are interested in the unit you actually used in the options you could also patch \Gm@defbylen which is (as far as I can see) used by most options and then set the values with \geometry:

\documentclass[12pt]{article}
\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\makeatletter
\def\Gm@defbylen#1#2{%
\expandafter\edef\csname myGm#1\endcsname{#2}%new
\begingroup\setlength\@tempdima{#2}%
\expandafter\xdef\csname Gm@#1\endcsname{\the\@tempdima}\endgroup}%

\geometry{margin=1in}

\begin{document}

\makeatletter\Gm@lmargin \myGmlmargin

\end{document}

-