[Tex/LaTex] \pagestyle{ruled} adds superfluous text in glossary

glossariesheader-footerincompatibilitymemoir

I'm writing my thesis using the memoir package, using \pagestyle{ruled}, and have created glossaries for a glossary and an acronym list. The resulting pdf, contains the superfluous text "Glossary" and "Acronyms" right below the chapter headings of the same name.

I use latexmk to build the pdf, using a custom .latexmkrc:

add_cus_dep('glo', 'gls', 0, 'makeglossaries');
sub makeglossaries {
    system("makeglossaries '$_[0]'");
}

Here is my minimal example:

\documentclass[a4paper]{memoir}
\usepackage[acronym,toc]{glossaries}
\makeglossaries
\pagestyle{ruled}
\newglossaryentry{UML}{name={UML},description={definition}}
\newacronym{XML}{XML}{Extensible Markup Language}
\begin{document}
\chapter{Intro}
text \gls{XML}
\gls{UML}
\printglossaries
\end{document}

Removing the \pagestyle{ruled} line removes the extra text.
How do I get rid of the extra text, while still using a ruled pagestyle?

Best Answer

Issue \pagestyle{ruled} before loading the glossaries package. (I've tested my solution with a glossary with about 30 entries, and its page style is indeed ruled.)

Partial explanation: Both memoir and glossaries define the \glossarymark macro. glossaries adds some compatibility code in case memoir is used, and so it seems the sensible thing to choose a page style first and then let glossaries do its work.

\documentclass[a4paper]{memoir}
\pagestyle{ruled}
\usepackage[acronym,toc]{glossaries}
\makeglossaries
\newglossaryentry{UML}{name={UML},description={definition}}
\newacronym{XML}{XML}{Extensible Markup Language}
\begin{document}
\chapter{Intro}
text \gls{XML}
\gls{UML}
\printglossaries
\end{document}
Related Question