将\fancyhead[CO]{\zihao{5}\rightmark}替换为\fancyhead[CO]{\zihao{5}\makebox[6\ccwd][s]{\rightmark}}。
另外你似乎多删除了hyperref宏包的调用。或许可以试试这个:
\documentclass[b5paper,twoside,openany,UTF8]{ctexbook}
\usepackage{fancyhdr}
\usepackage{hyperref}%
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CO]{\zihao{5}\rightmark}
\fancyhead[CE]{\zihao{5}\leftmark}
\fancyfoot[RO,LE]{--~\thepage~--}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\chaptermark}[1]{%
\markboth{\texorpdfstring{\makebox[5\ccwd][s]{第\zhnumber{\thechapter}回}}{第\zhnumber{\thechapter}回}}{#1}
}
\fancypagestyle{plain}{%
\fancyhf{} % 清空页眉页脚
% 偶数页左下角、奇数页右下角显示页码
\fancyfoot[RO,LE]{--~\thepage~--}
\renewcommand{\headrulewidth}{0pt} % 去掉页眉横线
}
\fancypagestyle{frontmatter}{ %frontmatter部分的页眉页脚定制
\pagestyle{plain}
\fancyhf{}
\fancyhead[CO]{\zihao{5}\makebox[6\ccwd][s]{\rightmark}}
\fancyhead[CE]{\zihao{5}\makebox[6\ccwd][s]{这是一本书}}
\renewcommand{\headrulewidth}{0.5pt} % 确保页眉横线宽度为0.5pt
\fancyfoot[LE,RO]{--~\thepage~--} %奇数页右下角、偶数页左下角显示页码
}
\begin{document}
\frontmatter%
\pagestyle{frontmatter}
\pagenumbering{roman}
\tableofcontents %生成目录
\mainmatter% 我认为作为一本完整的书
% \frontmatter \mainmatter \backmatter总是要用好的
\pagestyle{fancy}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\chapter{title} \chapter{title} \chapter{title} \chapter{title} \chapter{title}
\end{document}
BTW,如果追求代码更简洁的话,也许可以把\fancypagestyle缩短,让他继承自plain样式:
\fancypagestyle{frontmatter}[plain]{%frontmatter部分的页眉页脚定制
\fancyhead[CO]{\zihao{5}\makebox[6\ccwd][s]{\rightmark}}
\fancyhead[CE]{\zihao{5}\makebox[6\ccwd][s]{这是一本书}}
\renewcommand{\headrulewidth}{0.5pt} % 确保页眉横线宽度为0.5pt
}

















问 排版(多页)目录时,如何设置目录部分的页眉上,“目录”两字的间距(例如4ccwd分散对齐)?