I'm using fancyhdr and everything works well, except one chapter in which I need a longtable in the first page: this causes the header to display the name of the previous chapter. This happens in Overleaf with pdfTex This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex 2025.6.16) (but not locally in VSCode with pdfTex This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.10.12) (preloaded format=pdflatex 2023.12.16)) Unfortunately I need this to work in Overleaf too, for unrelated reasons, and Overleaf doesn't let me decide the compiler version.
This is a MWE:
\documentclass[twoside]{report} \usepackage{blindtext} \usepackage{longtable} % table on more pages \usepackage{fancyhdr} % fancy headers \usepackage{soul} \usepackage[bf]{titlesec} \linespread{2.0} \pagestyle{fancy} \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\so{#1}}}{}} % make header uppercase \fancyhf{} %clears all header and footer fields \fancyhead[LE,RO]{\bfseries\rm\thepage} \fancyhead[LO]{\bfseries\footnotesize\rightmark} \fancyhead[RE]{\bfseries\footnotesize\leftmark} % redefine plain style for pagestyle \fancypagestyle{plain}{% \fancyhead{} % get rid of headers \renewcommand{\headrulewidth}{0pt} % and the line } % redefine headings style for pagestyle \fancypagestyle{headings}{% \fancyhead{} % get rid of headers \fancyhead[LE,RO]{\bfseries\rm\thepage} \fancyhead[LO]{\bfseries\rm\rightmark} \fancyhead[RE]{\bfseries\rm\leftmark} } \begin{document} \chapter{Previous Chapter} \blindtext[6] \chapter{This Chapter} Few rows\\ Few rows\\ {\setlength\tabcolsep{8pt} \footnotesize \begin{longtable}{ c | c ||l} \hline 0 & 1 & A~ \\ 0 & 2 & B~ \\ 0 & 3 & C~ \\ \hline 0 & 1 & A~ \\ 0 & 2 & B~ \\ 0 & 3 & C~ \\ \hline 0 & 1 & A~ \\ 0 & 2 & B~ \\ 0 & 3 & C~ \\ \hline 0 & 1 & A~ \\ 0 & 2 & B~ \\ 0 & 3 & C~ \\ \hline 0 & 1 & A~ \\ 0 & 2 & B~ \\ 0 & 3 & C~ \\ \hline \end{longtable}} \normalsize \blindtext[6] \end{document} 


\listfilesand then show which package versions you have in the version that works, and which in the version that does not work.fancyhdr,soulandtitlesec, if you use\pagestyle{headings}. Then there is still "Chapter 1. PREVIOUS CHAPTER" on page 6 and 8, which are the second and fourth page of Chapter 2. It does not happen with TeX Live 2024. So maybe an issue of the changed mark handling in LaTeX 2025-06-01.