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.

Using the following minimal working example

\documentclass[12pt,a4paper]{article}

\usepackage[showframe]{geometry}
\geometry{hmargin={3.5cm,2.5cm}}

\AtBeginDocument{\geometry{vmargin={12cm,5cm}}}

\usepackage{lipsum}

\begin{document}
\lipsum[1-10]
\end{document}

Text on the first page overflows the lower margin. Other pages are fine, as illustrated by the figures below:

  • first page margin (overflown)

First page lower margin overflown

  • other pages (as expected)

Other pages are behaving correctly

I need to use commands in MWE for a complicated sequence (creating a complex template as a document class, calculating some lenghts involved in the template, then putting appropriate margins on the text block to fit into the template), so redefining MWE as an answer is probably not desirable.

share|improve this question
    
Your title doesn't seem very clear to me. How would you like "Margin overflow when setting the geometry AtBeginDocument"? –  Hendrik Vogt Mar 9 '11 at 15:04
    
You are right. And fancyhdr is not necessary either, so I will remove it from the question. –  ipavlic Mar 9 '11 at 15:10

1 Answer 1

up vote 7 down vote accepted

You cannot use \geometry for a setting inside the text body. Use \newgeometry instead. However, fancyhdr should always be loaded after geometry.

\documentclass[12pt,a4paper]{article}

\usepackage[showframe]{geometry}
\geometry{hmargin={3.5cm,2.5cm}}

\AtBeginDocument{\newgeometry{vmargin={12cm,5cm}}}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}

\usepackage{lipsum}

\begin{document}
\lipsum[1-10]
\end{document}
share|improve this answer

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.