# Identical marks in header with onesided memoir

I'm using memoir for an onesided document, but I wanted to have both the chapter and section numbers and names in the header.

I'm using this to achieve it (from Including both chapter name and name of section in header using memoir)

\pagestyle{ruled}


This works great most of the time, however for the ToC and bibliography, both of which are two pages long, I have the same label twice in the header, which looks terrible.

I would like to only show the \rightmark if it's different from the \leftmark. Or somehow change the labeling of those two things. For example it works OK in introduction, which is an \unnumberedchapter and has no \section. I've tried changing \bibsection to \unnumberedchapter but that didn't help.

Thanks.

I'm beginning to think that for any question, there's always an answer inspired by egreg (On testing two fully expanded character strings for equality):

\documentclass[oneside]{memoir}

\usepackage{pdftexcmds} % https://tex.stackexchange.com/questions/59565/on-testing-two-fully-expanded-character-strings-for-equality
\makeatletter
\newcommand*{\test}[2]{%
\ifnum\pdf@strcmp{#1}{#2}=\z@ \relax \else #2 \fi
}
\makeatother

\pagestyle{ruled}

\usepackage{lipsum}

\newcommand{\makechapter}{
\chapter{foo}
\section{foobar}
\lipsum[1-12]
}

\begin{document}

\tableofcontents

\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter

\end{document}


• I give good inspirations, it seems. ;-) – egreg May 10 '14 at 22:27
• @egreg Good solutions too. And at times good lessons, criticisms ..... :). – user11232 May 11 '14 at 0:07
• Works perfectly, thanks! I tried something like this but didn't properly expand the macros before comparison which didn't work so I gave up on that idea. – lacop May 11 '14 at 11:20
• Proper use of \expandafter has always been a sticking point for me, too. I'll certainly go for this method in the future. – Mike Renfro May 11 '14 at 13:02