Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing oneside check in \f@nch@initialise #5

Closed
zepinglee opened this issue Jan 29, 2021 · 2 comments
Closed

Missing oneside check in \f@nch@initialise #5

zepinglee opened this issue Jan 29, 2021 · 2 comments

Comments

@zepinglee
Copy link

zepinglee commented Jan 29, 2021

fancyhdr version: 2021/01/04 v4.0

The code in \f@nch@initialise assumes that the document is in twoside mode. This causes a oneside document fails to produce the correct header.

fancyhdr/fancyhdr.dtx

Lines 4168 to 4187 in 06e1305

\def\f@nch@initialise{%
% \end{macrocode}
%
% \begin{macro}{\chaptermark}
% \begin{macro}{\sectionmark}
% \begin{macro}{\subsectionmark}
% Standard definitions for \cs{chaptermark}, \cs{sectionmark} and \cs{subsectionmark}.
%
% \begin{macrocode}
\f@nch@ifundefined{chapter}%
{\def\sectionmark##1{\markboth{\MakeUppercase{\ifnum \c@secnumdepth>\z@
\thesection\hskip 1em\relax
\fi ##1}}{}}%
\def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
\thesubsection\hskip 1em\relax \fi ##1}}}%
{\def\chaptermark##1{\markboth {\MakeUppercase{\ifnum
\c@secnumdepth>\m@ne \@chapapp\ \thechapter. \ \fi ##1}}{}}%
\def\sectionmark##1{\markright{\MakeUppercase{\ifnum \c@secnumdepth >\z@
\thesection. \ \fi ##1}}}%
}%

\documentclass[oneside]{book}
\usepackage{fancyhdr}
\begin{document}
\chapter{Foo}
\section{Bar}
\clearpage
\null\clearpage
\null\clearpage
\end{document}

The headers of pages 2 and 3 are 1.1. BAR2, which is inconsistent with that if \usepackage{fancyhdr} is commented out.

Sorry that I created an incomplete issue firstly.

@pietvo
Copy link
Owner

pietvo commented Jan 29, 2021

Thanks for your report.
You are right, the fancyhdr default is not the same as the LaTeX default. It wasn't the intention. In the documentation it is described for the twosided case, but the onesided case is actually the same, except that only the 'odd page' layout is used.

Your document is missing a \pagestyle{fancy} command, therefore the header you get is not the fancyhdr default but some half-baked version of it.

To get the same layout as the default LaTeX layout but with a line under the header, use (only available on fancyhdr version 4):

\usepackage[headings]{fancyhdr}
\pagestyle{headings}

I could make a change to implement a different default for onesided documents (which would give the same layout as the two lines above), but that would break some existing documents. I tried it on my system, and several of my test files would give a different output. I think this is too risky, so I will not implement it. I will update the documentation to describe the situation more fully.

@zepinglee
Copy link
Author

Thanks for your response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants