I'm attempting to use dictionary-style ranges for page headers using titlesec, but I'm running into a problem when trying to collapse them if there's only a single range on a given page.
The documentation suggests this is possible, but is also stunningly vague:
"Of course, this example should be fine tuned to collapse the ranges if there is a single section in a page, but it gives a hint of how to get stunning headers."
Given the following code below, I'd like the header on the second page to say "3" rather than "3-3". Why doesn't ifstrequal work?
\documentclass[]{book}
\usepackage{lipsum}
\usepackage[pagestyles]{titlesec}
\usepackage{etoolbox}
\renewcommand{\thesection}{\arabic{section}}
\newpagestyle{pagestyle}{
\sethead[\ifstrequal{\toptitlemarks\thesection}{\bottitlemarks\thesection}{\toptitlemarks\thesection}{\toptitlemarks\thesection---\bottitlemarks\thesection}]
[]
[]
{}
{}
{\ifstrequal{\toptitlemarks\thesection}{\bottitlemarks\thesection}{\toptitlemarks\thesection}{\toptitlemarks\thesection---\bottitlemarks\thesection}}
}
\pagestyle{pagestyle}
\begin{document}
\section{}
\lipsum[1-2]
\section{}
\lipsum[1]
\section{}
\lipsum[1-6]
\section{}
\lipsum[1-2]
\end{document}