1

For the drafts of my document, I am trying to add a date and time to each page and I decided to use the headers/footers for this. I want the timestamp to be on pages that normally have \pagestyle{empty}, so I added the headers like so:

\documentclass[]{memoir}

\setbinding{0in}
\setlrmarginsandblock{1in}{1in}{*}
\setulmarginsandblock{1in}{1in}{*}
\checkandfixthelayout

\usepackage[en-US]{datetime2}
\usepackage{xcolor}
\usepackage{lipsum}

\newcommand{\draftdate}{\color{gray}\sffamily\small\DTMsetstyle{default}\DTMNow}

\makeevenhead{empty}{\draftdate}{}{}
\makeoddhead{empty}{}{}{\draftdate}

\makeevenhead{plain}{\draftdate}{}{}
\makeoddhead{plain}{}{}{\draftdate}

\begin{document}
\pagestyle{empty}

\noindent Title Page Stuff

\clearpage

\noindent Copyright Page Stuff

\clearpage

\pagestyle{plain}
\lipsum
\end{document}

This results in this clearly wrong header on the first page:

Output of the broken MWE showing the incorrect header placement

The "Copyright Page" also using the empty style is correct, as is the following page using the plain style.

Replacing empty with a new page style foo fixes the problem:

\documentclass[]{memoir}

\setbinding{0in}
\setlrmarginsandblock{1in}{1in}{*}
\setulmarginsandblock{1in}{1in}{*}
\checkandfixthelayout

\usepackage[en-US]{datetime2}
\usepackage{xcolor}
\usepackage{lipsum}

\newcommand{\draftdate}{\color{gray}\sffamily\small\DTMsetstyle{default}\DTMNow}

\makepagestyle{foo}
\makeevenhead{foo}{\draftdate}{}{}
\makeoddhead{foo}{}{}{\draftdate}

\makeevenhead{plain}{\draftdate}{}{}
\makeoddhead{plain}{}{}{\draftdate}

\begin{document}
\pagestyle{foo}

\noindent Title Page Stuff

\clearpage

\noindent Copyright Page Stuff

\clearpage

\pagestyle{plain}
\lipsum
\end{document}

This however, is not a full solution, since I want later empty pages created with \cleardoublepage or inserted between chapters to also have the timestamp.

Interestingly, using a header like \makeoddhead{empty}{}{any text}{\draftdate} works correctly.

What is happening here?

3
  • Seems you encountered a bug with empty... and were understandably confused. This is also why you could make it work with a different style (which isn't buggy).
    – whatisit
    Dec 15, 2018 at 2:43
  • 1
    The memoir empty style are best left alone as it is intentionally missing features that other styles have. Either use \makepagestyle{myempty}\copypagestyle{empty}{myempty} or use \makeheadfootstrut{empty}{\strut}{\strut}, the former is the preferred method.
    – daleif
    Dec 15, 2018 at 4:19
  • Thanks, @daleif! This is the solution I will use. Dec 17, 2018 at 2:11

2 Answers 2

1

In memoir the empty style have a slightly special setup. All pagestyle, except empty gets some struts added for consistency. The empty style does not, otherwise you cannot create a doc where the text block is almost the same size as paper size (at least not without memoir warning about it).

The missing struts in the empty style can lead to unpredictable behaviour as you have already seen.

It is rather rare users mess with the empty style, but if you want to, this is the proper method: (a) First create a new empty page style, with a name different from empty:

\makepagestyle{myempty}

This is now an empty page style with struts.

Next overwrite the existing empty style:

\copypagestyle{empty}{myempty}  

Then add your changes to empty.


Personally, I would not use the header/footers to add draft information. I'd use a package that can place stuff at an absolution position on all pages. Even though it an old package, my go to is often eso-pic.

Or you can combine the page style and eso-pic (or similar packages) to only have this information on the start of chapters (adding it to the chapter style. I use this in a book to add last changed information to each chapter (separate files) from my subversion archive.

1

Here's a fix. (While this answer provides a workaround and observations of what works/doesn't work, @daleif says that you should really be creating a new style, such as myempty, rather than using empty).

Replace:

\makeoddhead{empty}{}{}{\draftdate}

with:

\makeoddhead{empty}{}{~}{\draftdate}

That's it!

Now, lets look at the behavior. It seems to stem from the right-side section of the header. This behavior appears to affect both \makeevenhead{empty}{}{}{} and \makeoddhead{empty}{}{}{}.

Using \makeoddhead{empty}{\draftdate}{}{} (no problem): memomir empty style, left header

Using \makeoddhead{empty}{}{\draftdate}{} (no problem): memomir empty style, center header

Using \makeoddhead{empty}{}{}{\draftdate} (WHAT??): memomir empty style, right header

Using \makeoddhead{empty}{\draftdate}{test}{} (no problem): memomir empty style, left and center header

Using \makeoddhead{empty}{\draftdate}{}{test} (WHAT??): memomir empty style, left and right header

Using \makeoddhead{empty}{}{\draftdate}{test} (no problem): memomir empty style, center and right header

Sooooo, as you can see, there are two headers that behave in different ways for the right header within the empty page styles in memoir:

  • the right-only header
  • the left and right header

Therefore, if you want to use only the right header or the right header with the left header, you can trick it. Bypass the issue by putting a space into the center header slot!

7
  • It is not a bug, it is specifically designed that way. If you want to overwrite the empty style, you first need to make it into a proper page style. For example by making a myempty style and then aliasing the empty style to it.
    – daleif
    Dec 15, 2018 at 3:49
  • 1
    I'm not sure I understand why it's designed this way. The right-side header works as expected in all but two situations. I couldn't find anything in the memoir manual about a special situation with empty, but since I seem to have missed it please point me there. As for creating a new style, I am not disagreeing - I was responding to the specific question in the OP.
    – whatisit
    Dec 15, 2018 at 4:00
  • In general the empty style should be left alone. There are various things not added to empty under that assumption that it should be empty.
    – daleif
    Dec 15, 2018 at 4:03
  • If you want to mess with a common empty style, you need to do \makepagestyle{myempty}\copypagestyle{empty}{myempty} first. Otherwise the style is not adjustable and messing wit it can lead to unpredictable stuff.
    – daleif
    Dec 15, 2018 at 4:12
  • You can also use \makeheadfootstrut{empty}{\strut}{\strut}, but as I said empty is special don't mess with it directly.
    – daleif
    Dec 15, 2018 at 4:17

You must log in to answer this question.

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