\thispagestyle{empty}不能取消页码

发布于 2022-06-23 22:32:42

part使用了

\titleformat{\part}[display]{\Huge\bf}{第\thepart 部分}{1em}{}

进行定制,然后在运行下面的代码时

\begin{document}
\small

\setcounter{page}{1}
\pagenumbering{Roman}
\tableofcontents
\newpage

\setcounter{page}{1}
\pagenumbering{arabic}

\part{测试测试测试}
\thispagestyle{empty}

\chapter{测试测试测试}
\thispagestyle{empty}

\end{document}

part所在那一页的页码没有被取消,chapter所在那一页的页码成功取消,请问怎么取消part所在那一页的页码?

查看更多

关注者
0
被浏览
993
雾月
雾月 2022-06-24
这家伙很懒,什么也没写!

\part 的结构为:

\clearpage (\cleardoublepage)
...
\thispagestyle{<pagestyle>}
...
\newpage
...

由于使用了 \clearpage\newpage,使用 \thispagestyle 无法修改 part 页的 pagestyle。
\chapter 则没有尾部的 \newpage,thispagestyle` 可以生效。

如果使用 titlesec 宏包,它提供了 \assignpagestyle 来修改页面样式。如:

\assignpagestyle{\part}{empty}
\assignpagestyle{\chapter}{empty}

将修改 \part\chapter 的 pagestyle 为 empty。此命令应在 \titleformat{<command>}... 后使用。它可以在任意位置使用,将影响其后的 pagestyle。

当使用 ctex 文档类时,可使用 \ctexset{part/pagestyle=..., chapter/pagestyle=...} 直接设置 pagestyle。但当加载 titlesec 后无效。

对于本例,若要全局修改,只需在导言区使用:

%\usepackage{titlesec}
\titleformat{\part}[display]{\Huge\bf}{第\thepart 部分}{1em}{}
\assignpagestyle{\part}{empty}

若只修改个别,则

\assignpagestyle{\part}{empty}
\part{...}
\assignpagestyle{\part}{plain} % 改回来,默认为 plain
1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览