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

xpinyin automatically applied to header when spanning multiple pages #669

Open
hungtzuchang opened this issue Jul 24, 2023 · 1 comment
Open

Comments

@hungtzuchang
Copy link

When pinyinscope environment spans multiple pages, pinyin is automatically applied to the header of the pages (see pictures below, compiled with MikTeX on Windows). This happens when using non-A4 paper sizes in documentclass setting or using a different font size.
image
MWE:

% !TEX TS-program = xelatex
\documentclass[12pt,b5paper]{ctexbook}
\usepackage{zhlipsum,xpinyin}
\begin{document}
\chapter{亂碼}
\begin{pinyinscope}
\zhlipsum
\end{pinyinscope}
\end{document}

image
MWE:

% !TEX TS-program = xelatex
\documentclass[12pt,a4paper]{ctexbook}
\usepackage{zhlipsum,xpinyin}
\begin{document}
\chapter{亂碼}
\begin{pinyinscope}
\Large \zhlipsum
\end{pinyinscope}
\end{document}
@muzimuzhi
Copy link
Contributor

Class options 12pt,b5paper make both page header and footer affected, while b4paper only makes page footer affected.

I guess the cause is similar to https://tex.stackexchange.com/q/498857, in which if the change of catcode table in main body spans multiple pages, then because the page header and footer are only typeset when a page is ship out, the current catcode table when they are typeset is inherited from the main body, hence also the modified one.

In current issue, what's inherited from main body is the state of \enablepinyin that pinyinscope environment turns on locally. Wrapping page header and footer in \disablepinyin ... \enablepinyin is a workaround (actually only \disablepinyin is enough because header and footer are all saved in a box first and boxes have an implicit level of grouping), for example using fancyhdr package.

Header Footer
before image image
after
(with fancyhdr)
image image
% !TEX TS-program = xelatex
\documentclass[12pt,b5paper]{ctexbook}
\usepackage{zhlipsum,xpinyin}
\usepackage{fancyhdr}

\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyfoot[C]{\disablepinyin\thepage}%
}

\pagestyle{fancy}

% not essentially the same as original "headings" page style
\fancyhf{}
\fancyhead[LE,RO]{\disablepinyin\thepage}
\fancyhead[RE]{\disablepinyin\slshape\leftmark}
\fancyhead[LO]{\disablepinyin\rightmark}
\renewcommand{\headrulewidth}{0pt}

\renewcommand{\thepage}{第 \arabic{page} 页}

\begin{document}
\chapter{亂碼}
\begin{pinyinscope}
\zhlipsum[1-3]
\end{pinyinscope}
\end{document}

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

No branches or pull requests

2 participants