1

To optically center the dedication in my thesis, I have to use newgeometry for that page. On the following page the page number is now missing and fancyhdr gives the following warning:

Package Fancyhdr Warning: \fancyfoot's `E' option without twoside option is useless on input line **.

I have created an MWE which shows the problem in as few lines as possible. If you comment out the newgeometry block including the restoregeometry command, the error message disappears and the page number is displayed. It does not help to call thispagestyle and/or pagestyle again after the restoregeometry command.


MWE

\documentclass[twoside]{article}
\usepackage[utf8]{inputenc}

\usepackage{%
    geometry,%
    fancyhdr,%
    parskip,%
    xparse,%
}


\geometry{%
    paper = a4paper,%
    top = 3cm,%
    bottom = 3.5cm,%
    inner = 3.5cm,%
    outer = 2.5cm,%
    nomarginpar,%
    showframe = true%
}


\fancypagestyle{noheader}{%
    \fancyhf{}                  % Clean fields
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0.4pt}
    \fancyfoot[LE, RO]{\thepage}%
}


\NewDocumentEnvironment{dedication}{}{%
    \newpage%
    \newgeometry{%
        top = 0cm,%
        bottom = 3.5cm,%
        inner = 3.5cm,%
        outer = 2.5cm,%
        nomarginpar,%
    }
    \vspace*{\fill}
    \itshape%
    \centering%
}{%
    \vspace*{\fill}%
    \restoregeometry%
    \newpage%
}

\begin{document}
\thispagestyle{noheader}%
\pagestyle{noheader}%

This is only the first page. On the next page, the dedication will be displayed.

\begin{dedication}
I'm a touching dedication
\end{dedication}

I'm the third page. Note that I do not have a page number, even though the first and the second page have one.

\end{document}

Edit

These are the log outputs after applying egregs answer.

] [2]) (./dedication.tex [3

] [4]
*geometry* verbose mode - [ newgeometry ] result:
* driver: xetex
* paper: a4paper
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes: 
* h-part:(L,W,R)=(99.58464pt, 426.79135pt, 71.13188pt)
* v-part:(T,H,B)=(0.0pt, 745.4622pt, 99.58464pt)
* \paperwidth=597.50787pt
* \paperheight=845.04684pt
* \textwidth=426.79135pt
* \textheight=745.4622pt
* \oddsidemargin=27.31465pt
* \evensidemargin=27.31465pt
* \topmargin=-109.26999pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=0.0pt
* \marginparsep=0.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)



Package Fancyhdr Warning: \fancyfoot's `E' option without twoside option is useless on input line 5.
1

You should apply \restoregeometry after the environment has ended.

I also fixed the code by removing the unnecessary % bits and adding them where necessary. Also \clearpage is better than \newpage in this context. Remove the \thispagestyle{empty} setting if you so prefer.

\documentclass[twoside]{article}
\usepackage[utf8]{inputenc}

\usepackage{
    geometry,
    fancyhdr,
    parskip,
    xparse,
}


\geometry{
    paper = a4paper,
    top = 3cm,
    bottom = 3.5cm,
    inner = 3.5cm,
    outer = 2.5cm,
    nomarginpar,
%    showframe = true
}


\fancypagestyle{noheader}{%
    \fancyhf{}% Clean fields
    \renewcommand{\headrulewidth}{0pt}%
    \renewcommand{\footrulewidth}{0.4pt}%
    \fancyfoot[LE, RO]{\thepage}%
}


\NewDocumentEnvironment{dedication}{}{%
    \clearpage
    \newgeometry{
        top = 0cm,
        bottom = 3.5cm,
        inner = 3.5cm,
        outer = 2.5cm,
        nomarginpar,
    }
    \thispagestyle{empty}
    \vspace*{\fill}
    \itshape
    \centering
}{%
    \par\vspace*{\fill}
    \clearpage
    \aftergroup\restoregeometry
}

\begin{document}
\pagestyle{noheader}

This is only the first page. On the next page, the dedication will be displayed.

\begin{dedication}
I'm a touching dedication
\end{dedication}

I'm the third page. Note that I do not have a page number, even though the 
first and the second page have one.

\end{document}

On the other hand, I see no real reason for \newgeometry, just to move the dedication a bit upper.

enter image description here

| improve this answer | |
  • Interesting. This resolves the issue with the missing page number but the warning remains. It refers to the line with \end{dedication}. I added the logs. Newgeometry seems to rest the twoside option to false: \@twosidefalse – Sam Oct 5 at 10:47
  • Apparently you have to add the twoside option to the \newgeometry{} command to completely fix the issue. Thanks for the \aftergroup\restoregeometry tip egreg! +1 – Sam Oct 5 at 10:57
  • @Sam I get no warning about two-side or one-side. – egreg Oct 5 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.