9

I want to alter the geometry of only one page in my Latex document. So I define my geometry as a4paper and then use \newgeometry. However when I enter the \restoregeometry it doesn't restore it. What am I doing wrong? This is the basic code and I am compiling in XeLaTeX ( I can't change the compiling method because it is essential for me to wright in an other language, namely greek):

\documentclass[12pt,a4paper]{article}

\usepackage{xltxtra}
\usepackage{xgreek}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}

\setsansfont{Arial}
\setmonofont{Courier New}
\setmainfont[Mapping=tex-text]{Times New Roman}


\begin{document}

\newgeometry{top=3.1cm}
\tableofcontents
\restoregeometry

\newpage

\end{document}

sorry if my question is somewhat stupid, but I haven been using Latex for a very short time and serching through the web didn't help.

1
  • 1
    \restoregeometry{top=...} only has an effect on the next page after its invocation. Since the document produced by your MWE is only one-page long, \restoregeometry has no effect here. Try to add some contents below \restoregeomtry, like \section{foo}\lipsum[1]\section{bar}\lipsum[2] (you'll need to load the lipsum package). You'll see that the geometry gets restored on the second page.
    – jub0bs
    Jan 18, 2014 at 13:55

1 Answer 1

6

It does restore. But you haven't given the margin values earlier (hence default are chosen). Consider the following code:

\documentclass[12pt,a4paper]{article}

\usepackage{xltxtra}
\usepackage{xgreek}
\usepackage[a4paper,margin=1in,showframe]{geometry}
\setsansfont{Arial}
\setmonofont{Courier New}
\setmainfont[Mapping=tex-text]{Times New Roman}


\begin{document}

\newgeometry{top=5.1cm}  %% I increased for demo
\tableofcontents
\restoregeometry

\clearpage %% old habits die hard ;-)
\newpage %% just to show a second page

Some text

\end{document}

enter image description here

BTW don't load packages two times (e.g. graphicx).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .