目录的页眉页脚不能显示,怎么回事?

发布于 2022-01-27 15:50:54

各位大佬,我放了关于目录的代码,我采用的是fancypagestyle来定义,其他的页面都可以用这种方式来单独定义一个页面的页眉页脚,为什么目录这一部分就一直不行?哪怕我不用fancypagestyle,直接在目录那块用thispagestyle来设置也不行,都不显示页眉页脚。

\documentclass[UTF8,a4paper,12pt]{ctexart}
\usepackage{fancyhdr}
\usepackage{ctex}
%--目录页眉页脚
\fancypagestyle{mulu}
{
        \fancyhf{}
        \fancyhead[c]{**硕士学位论文\quad 目录} 
        \fancyfoot[c]{\thepage}
        \renewcommand{\headrulewidth}{1.5pt}
        \renewcommand{\footrulewidth}{1.5pt}
    }
%-目录页眉页脚
\begin{document}
%-----目录部分
\newpage
\thispagestyle{mulu}%--调用上面定义的\fancypagestyle{mulu}
\renewcommand\contentsname{\textbf{目\quad录}}
    \addcontentsline{toc}{section}{目录}
    \begin{center}
    \tableofcontents%增加章节目录...
\end{center}
\end{document} 

查看更多

关注者
0
被浏览
2.2k
1 个回答
雾月
雾月 2022-01-27
这家伙很懒,什么也没写!
  1. \fancypagestyle 只是定义样式,需要使用 \pagestyle 应用样式,\thispagestyle 只是在当前页面应用样式;
  2. 你可能根本就没编译成功,这行代码
\renewcommand\contentsname{\textbf{目\quad录}}

xeCJKluatex-ja 下一般是无法编译的,应该写成

\renewcommand\contentsname{\textbf{目\quad 录}}

空格是必不可少的。
这是因为在 xeCJKluatex-ja 下,中文字符的类别码被设置为了 letter。

另外,使用了 ctexart 文档类就不必再使用 \usepackage{ctex} 了,UTF8 在 2.5 版(2020 年 5 月起)成为默认选项,一般也不必显示指定。

\documentclass[a4paper,12pt]{ctexart}
\usepackage{fancyhdr}
\usepackage{zhlipsum}
%--目录页眉页脚
\fancypagestyle{mulu}
  {
    \fancyhf{}
    \fancyhead[c]{**硕士学位论文\quad 目录} 
    \fancyfoot[c]{\thepage}
    \renewcommand{\headrulewidth}{1.5pt}
    \renewcommand{\footrulewidth}{1.5pt}
  }
%-目录页眉页脚
\begin{document}

%-----目录部分
\clearpage
\pagestyle{mulu}%--调用上面定义的\fancypagestyle{mulu}
\renewcommand\contentsname{\textbf{目\quad 录}}
    \addcontentsline{toc}{section}{目录}
    \begin{center}
    \tableofcontents%增加章节目录...
\end{center}

\clearpage
\pagestyle{headings}

\section{sec 1}
\zhlipsum[1-3]
\section{sec 2}
\zhlipsum[4-7]
\end{document} 

image.png

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览