竹林第八贤
竹林第八贤
这家伙很懒,什么也没写!

注册于 4年前

回答
2
文章
0
关注者
0

发现一个有趣的问题:您提供的代码可以完美显示这个效果。但是,我希望仅仅在frontmatter部分使用该页眉页脚设置,其他部分设置别的页眉页脚显示方式。所以,以上代码用花括号将frontmatter部分的所有章节都括起来之后,发现目录部分的显示又出现异常,去掉花括号之后就恢复。

{    
        \frontmatter%
    \pagestyle{frontmatter} 
    \pagenumbering{roman}
    \tableofcontents %生成目录
}    

此时页眉中“目录”二字的显示不统一且字符间距在后续页面不起作用,如下图
微信截图_20250214223154.jpg

`documentclass[b5paper,twoside,openany,UTF8]{ctexbook}
usepackage{zhlipsum}
usepackage{zhnumber}
ctexset{

chapter/name = {,},
chapter/number = {\makebox[5\ccwd][s]{第\chinese{chapter}回}},

}
usepackage{fancyhdr}
pagestyle{fancy}
fancyhf{}
fancyhead[CO]{zihao{5}rightmark}
fancyhead[CE]{zihao{5}leftmark}
fancyfoot[RO]{--~thepage~--}
fancyfoot[LE]{--~thepage~--}
renewcommand{headrulewidth}{0.5pt}
renewcommand{chaptermark}[1]{%

\markboth{\makebox[5\ccwd][s]{第\zhnumber{\thechapter}回}}{#1}

}
% 章节首页样式(无页眉和页眉横线,仅保留页码)
% 这是由于在book.cls中,章节首页预定义了样式 thispagestyle{plain}
% 因此此处重定义 plain 样式相当于重定义了 章节首页
fancypagestyle{plain}{%

\fancyhf{}
\fancyfoot[RO]{--~\thepage~--}
\fancyfoot[LE]{--~\thepage~--}
\renewcommand{\headrulewidth}{0pt}

}

usepackage{color,xcolor}

usepackage[%
xetex,
%xetex选项是配合xelatex编译程序的。
pagebackref,
%pagebackref是页码反向索引功能,出现在参考文献后部,用于反馈该条目对应的页码。
pdfstartview=FitH,
%pdfstartview表示打开PDF时,整个页面宽度适合PDF阅读器的窗口宽度(参照胡伟书)。
CJKbookmarks=true,
%CJKbookmarks=true确保PDF书签中的中文标签(如第一章等)显示正常。
bookmarksnumbered=true,
%bookmarksnumbered=true确保PDF书签中的章节编号正常显示
bookmarksopen=true,
%bookmarksopen=true确保打开PDF时,所有的书签都能展开
colorlinks,
%colorlinks链接改用彩色显示,默认为红色边框;
%单独注释掉colorlinks则后续所有的颜色设置失效。
linkcolor=purple,
%linkcolor指定页码和序号等链接的颜色为black黑色
pdfborder=001,
%pdfborder为超链接彩色框设置,单独注释掉此项或000表示不使用链接框。
citecolor=blue,
%citecolor=blue设置参考文献的颜色显示为蓝色
urlcolor=blue
%urlcolor=blue设置超链接文本为蓝色显示
]{hyperref}

begin{document}

\tableofcontents
\chapter{这是一个标题名1}\zhlipsum[1-6]
\addtocounter{chapter}{9}
\chapter{这是一个标题名2}\zhlipsum[1-6]
\addtocounter{chapter}{9}
\chapter{这是一个标题名3}\zhlipsum[1-6]

end{document}`

发布
问题