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.

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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

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.