# How to avoid text overflowing below bottom margin?

My document contains a title page followed by some text. In order to create my title page, I have to change the page margins on the title page using \newgeometry, and after the title page I return to the usual default margins using \restoregeometry. It includes graphics, uses Tikz, and uses a new environment called changemargin whose code is placed at the beginning of the code before \begin{document}.

MWE:

\documentclass[10pt, a4paper, titlepage, draft]{article}
% USING DRAFT BECAUSE WE DO NOT HAVE THE PDFs TO BE INCLUDED
\usepackage{geometry}
\usepackage{tikz}
\usepackage{graphicx}

\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
}%
\item[]}
{\end{list}}

\begin{document}

\begin{titlepage}

\newgeometry{left=6.75cm, right=1.25cm, top=1.25cm, bottom=1.25cm}

\mbox{}\hfill
\begin{minipage}[c]{8cm}
\flushright \textbf{University of ...}
\end{minipage}%
\begin{minipage}[c]{2.5cm}
\flushright \includegraphics[width=2.50cm]{logo.pdf}
\end{minipage}%

\begin{tikzpicture}[overlay, remember picture]

\useasboundingbox [fill=blue!20] ($(current page.south west) + (1, 1)$) rectangle ($(current page.north west) + (6.75, -1)$) ;
\draw [line width=0.01mm, blue] ($(current page.north west) + (1, -1)$) rectangle ($(current page.south east) + (-1, 1)$) ;
\draw ($(current page.north west) + (9.625, -4.00)$) -- ($(current page.north east) + (-1.25, -4.00)$) ;
\draw ($(current page.south west) + (9.625, 4.00)$) -- ($(current page.south east) + (-1.25, 4.00)$) ;

\node[anchor=south west, %anchor is upper left corner of the graphic
xshift=1.125cm, %shifting around
yshift=1.125cm]
at (current page.south west) %left upper corner of the page
{\includegraphics[width=5.25cm]{logo2.pdf}};

\end{tikzpicture}

\begin{changemargin}{0cm}{-0.25cm}

\centering

\vspace*{\baselineskip}
\vspace*{\baselineskip}

\rule{127mm}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
\rule{127mm}{0.4pt}\\[\baselineskip]
\vspace*{\baselineskip}
{\large \textbf{Title}}\\[\baselineskip]
{ Subtitle}\\[0.2\baselineskip]
\rule{127mm}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
\rule{127mm}{1.6pt}\\[\baselineskip]
\vspace*{\baselineskip}

\end{changemargin}

\mbox{} \vfill \hfill
\begin{minipage}[c]{8cm}
\flushright \textbf{Faculty of Science}
\end{minipage}%
\begin{minipage}[c]{2.5cm}
\flushright \includegraphics[width=2.50cm]{logo3.pdf}
\end{minipage}%

\restoregeometry

\end{titlepage}

\newpage

article text

\end{document}


However, the text on the first page overflows into the bottom margin of the document. This does not happen for all the other pages, only the first one.

What have I done wrong?

(I know my question is similar to this one:

Margin overflow when setting the geometry \AtBeginDocument

but the answer given there doesn't solve my problem.)

• What kind of material goes inside titlepage (images, only text)? Can you please add it (you can use some dummy text) to your example code so that we can reproduce the problem? – Gonzalo Medina Nov 28 '12 at 17:13
• Perhaps you could use \enlargethispage{amount} in the title page instead of changing geometry? – JLDiaz Nov 28 '12 at 17:17
• I have combined your three code snippets into a single one, changed the class option from final to draft (because we do not have the pdfs to be included) and added \usetikzlibrary{calc}. Now we have got a minimal working example (MWE) (well, not so minimal, but it can be copied, pasted, and compiled). – Stephen Nov 28 '12 at 17:48
• Adding either \geometry{showframe} or \usepackage{showframe} after \usepackage{geometry} one gets frames around text/header/margin/footer. Where does the text flow into the bottom margin? Another thought: What about placing \restoregeometry after \end{titlepage} \newpage? – Stephen Nov 28 '12 at 17:58
• I believe the problem is that \newgeometry will affect the following page, so it needs to be moved to before \begin{titlepage}. And you will probably want to move \restoregeometry to be after \end{ttilepage}, before \newpage. – Peter Grill Nov 28 '12 at 18:00

\newgeometry affects the following page, so moving it to be before \begin{titlepage} will ensure that it effects the title page.

And since you probably want pages after the title page to have the original geometry, moving \restoregeometry to be after \end{ttilepage}, and before \newpage will make it effective on the first page of the document.

## Code:

\documentclass[10pt, a4paper, titlepage, draft]{article}
% USING DRAFT BECAUSE WE DO NOT HAVE THE PDFs TO BE INCLUDED
\usepackage{geometry}
\usepackage{tikz}
\usepackage{graphicx}

\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
}%
\item[]}
{\end{list}}

\begin{document}
\newgeometry{left=6.75cm, right=1.25cm, top=1.25cm, bottom=1.25cm}
\begin{titlepage}

%\newgeometry{left=6.75cm, right=1.25cm, top=1.25cm, bottom=1.25cm}

\mbox{}\hfill
\begin{minipage}[c]{8cm}
\flushright \textbf{University of ...}
\end{minipage}%
\begin{minipage}[c]{2.5cm}
\flushright \includegraphics[width=2.50cm]{logo.pdf}
\end{minipage}%

\begin{tikzpicture}[overlay, remember picture]

\useasboundingbox [fill=blue!20] ($(current page.south west) + (1, 1)$) rectangle ($(current page.north west) + (6.75, -1)$) ;
\draw [line width=0.01mm, blue] ($(current page.north west) + (1, -1)$) rectangle ($(current page.south east) + (-1, 1)$) ;
\draw ($(current page.north west) + (9.625, -4.00)$) -- ($(current page.north east) + (-1.25, -4.00)$) ;
\draw ($(current page.south west) + (9.625, 4.00)$) -- ($(current page.south east) + (-1.25, 4.00)$) ;

\node[anchor=south west, %anchor is upper left corner of the graphic
xshift=1.125cm, %shifting around
yshift=1.125cm]
at (current page.south west) %left upper corner of the page
{\includegraphics[width=5.25cm]{logo2.pdf}};

\end{tikzpicture}

\begin{changemargin}{0cm}{-0.25cm}

\centering

\vspace*{\baselineskip}
\vspace*{\baselineskip}

\rule{127mm}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
\rule{127mm}{0.4pt}\\[\baselineskip]
\vspace*{\baselineskip}
{\large \textbf{Title}}\\[\baselineskip]
{ Subtitle}\\[0.2\baselineskip]
\rule{127mm}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
\rule{127mm}{1.6pt}\\[\baselineskip]
\vspace*{\baselineskip}

\end{changemargin}

\mbox{} \vfill \hfill
\begin{minipage}[c]{8cm}
\flushright \textbf{Faculty of Science}
\end{minipage}%