# Bad interaction between titlesec/titleps and packages that use \markboth internally

The following MWE demonstrates a bad interaction between endfloat and titleps. The second page has the word FIGURES in all caps in both the header and the footer, contrary to the page style specification.

\documentclass[12pt]{article}
\usepackage[heads,nolists]{endfloat}
\usepackage[pagestyles]{titlesec}
\newpagestyle{main}{
\sethead{}{}{\thepage}
\setfoot{}{}{}
}
\begin{document}
\pagestyle{main}
\section{Foo}
\section*{Bar}
\begin{figure}
Blurf
\end{figure}
\end{document}


biblatex is also affected: in this case REFERENCES appears in both the footer and the header.

\begin{filecontents*}{\jobname.bib}
@book{Saussure1995,
Title = {Cours de Linguistique Générale},
Publisher = {Payot},
Year = {1995},
Author = {Ferdinand de Saussure},
}
\end{filecontents*}
\documentclass{article}
\usepackage{kantlipsum}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{titleps}
\newpagestyle{main}{
\setfoot{My footer}{}{\thepage}
}
\pagestyle{main}
\begin{document}
\cite{Saussure1995}
\kant[1-2]
\printbibliography
\end{document}


I have traced this to endfloat and biblatex internally using the \mark commands. Specifically, the problem goes away if I redefine \markboth to do nothing (still consuming two arguments). I don't feel particularly safe doing that, though. At the least I'd like to know whether anything else needs the same treatment, and what might break.

The titleps documentation warns that "using \markboth can lead to unpredictable results", but that's a disappointing cop-out when it's a documented interface that packages think they can use.

Suggestions?

• @cfr I think the issue is really to do with titleps not titlesec, since I've only encountered it as I've gradually switched from using fancyhdr to titleps. And I use titlesec in every document I write. – Alan Munn Feb 24 '16 at 23:10
• That said, I don't think Biblatex is blameless here. Why doesn't it leave \section or \chapter or whatever to set the marks? Presumably because it is unnumbered, but hard-coding the marks based on the current class doesn't seem a good solution. – cfr Feb 24 '16 at 23:22
• @cfr Yes, I agree. My current solution is to redefine \bibheading but that's a pain to do all the time. – Alan Munn Feb 24 '16 at 23:27
• We had Bibliography and headers with titleps and biblatex where the answer was to what you are doing right now. titleps for fancyhdr users says "you must forget about \leftmark, \rightmark, \markboth and \markright, as well as redefining \sectionmark and the like." So it seems that the package really isn't compatible with that. Setting the commands. – moewe Feb 25 '16 at 7:46
• @moewe As you may guess from the last sentence of the question, I feel that this is a bug in titleps, and I'd be happiest with an answer that patched titleps such that the documented \mark commands were again compatible with what other packages expect them to do. (Alan's bounty is of course up to him.) – zwol Feb 26 '16 at 2:54

## 2 Answers

Add the following lines to the preamble.

\makeatletter
\let\ttl@titlemarks\relax
\makeatother


Then the two examples will work. This also helped in Customizing titleps' header in index to include current index entry.

Not an answer but too long for a comment.

If and how \markboth commands are handled is one part of the question. But in the example the pagestyle is apart from the page number empty and so shouldn't show the content of marking commands. This is clearly a bug and should be reported to the author of titleps. A simple example to demonstrate the problem is:

\documentclass[12pt]{article}
\usepackage{titleps}
\newpagestyle{main}{
\sethead{}{}{}
\setfoot{}{}{}
}

\begin{document}
\pagestyle{main}
\mark{abc}
blub
\end{document}


It prints "bc" in the header and the footer.

• Interesting that the first "a" is swallowed. Do you think it would be a bad idea to disable \mark and friends at the end of loading titleps (maybe from within the package)? – moewe Mar 2 '16 at 10:13
• titleps does a "secondoftwo" that's why the first part of the mark is lost (and why in the original question the \rightmark is shown). I have no idea what would be the best solution. It would need much time to understand why titleps does what it does. One should really better contact the author. – Ulrike Fischer Mar 2 '16 at 12:15
• @UlrikeFischer Thanks Ulrike, I've sent a bug report to Javier. – Alan Munn Mar 2 '16 at 16:59
• @UlrikeFischer This doesn't work even without titleps, as one could expect if a TeX primitive is used instead of LaTeX \mark... stuff. LaTeX internally uses a couple of values inside marks (left and right), and you are passing, as far as LaTeX is concerned, three -- a, b and c. Therefore, you'll get bc (or ac, depending on the page) with standard LaTeX, too. – Javier Bezos Mar 3 '16 at 15:44
• @JavierBezos The problem is not that one get a faulty or senseless output, but that one get an output at all. The pagestyle is defined as empty. So why do a part of the mark content show up? (The problem can be shown with \markboth too, but for debugging I think the primitive command is better). – Ulrike Fischer Mar 3 '16 at 17:11