# How do I prevent duplicate Glossaries section title when redefining page styles in Memoir class?

The solution provided to question How to modify Memoir class' headers/footers without redefining everything involves a) redefining the Memoir headings and b) redefining page styles. The latter seems to cause a new problem to appear: I now have two "Glossary" sectional titles when using Glossaries. Here is the MWE:

\documentclass{memoir}

\usepackage{lipsum}

%-----------------------------
\copypagestyle{headingsnobook}{headings}

\makeevenhead{headings}%
{\slshape\leftmark}{}{\thepage}
\makeoddhead{headings}{\rightmark}{}{\thepage}
\makeevenfoot{headings}{}{}{}
\makeoddfoot{headings}{}{}{}

\copypagestyle{plainnotice}{plain}
\makeevenfoot{plainnotice}{}{}{\thepage}
\makeoddfoot{plainnotice}{}{}{\thepage}
\aliaspagestyle{chapter}{plainnotice}

\makeevenhead{headingsnobook}{\leftmark}{}{\thepage}
%-----------------------------

\usepackage{glossaries}
\makeglossaries
\newglossaryentry{test}{%
name={test},
description={A test}}

\begin{document}

% Backmatter
\backmatter
\pagestyle{headingsnobook}

\glsaddall
\printglossaries

\end{document}


Commenting-out the code between the dotted lines as well as \pagestyle{headingsnobook} makes the duplicate title disappear, but I need this code to eventually add Book XX and Part XX to mainmatter headings, but not to backmatter headings, such as in glossaries or indexes. Can the "headingsnobook" page style be defined so as to avoid this?

-
add comment

## 1 Answer

The observed duplicate title is due to an incompatibility between memoir and glossaries described in \pagestyle{ruled} adds superfluous text in glossary. In that question, the solution was to issue the \pagestyle command before loading glossaries. This, however, doesn't help in the question at hand because you apparently need to switch from another page style to \pagestyle{headingsnobook} in the document body (at the start of the backmatter). Solution: After doing the switch, issue some compatibility code copied from glossaries.sty.

\documentclass{memoir}

\usepackage{lipsum}

%-----------------------------
\copypagestyle{headingsnobook}{headings}

\makeevenhead{headings}%
{\slshape\leftmark}{}{\thepage}
\makeoddhead{headings}{\rightmark}{}{\thepage}
\makeevenfoot{headings}{}{}{}
\makeoddfoot{headings}{}{}{}

\copypagestyle{plainnotice}{plain}
\makeevenfoot{plainnotice}{}{}{\thepage}
\makeoddfoot{plainnotice}{}{}{\thepage}
\aliaspagestyle{chapter}{plainnotice}

\makeevenhead{headingsnobook}{\leftmark}{}{\thepage}
%-----------------------------

\usepackage{glossaries}
\makeglossaries
\newglossaryentry{test}{%
name={test},
description={A test}}

\begin{document}

\pagestyle{headings}

\chapter{foo}

Some stuff unrelated to the glossary.

% Backmatter
\backmatter
\pagestyle{headingsnobook}
\renewcommand{\glossarymark}[1]{%
\markboth{\memUChead{#1}}{\memUChead{#1}}%
}

\glsaddall
\printglossaries

\end{document}


-
Unbelievably, this works. You are awesome, lockstep! Thank you. –  Olivier Drolet Apr 10 '12 at 0:03
add comment