latex中页眉设置问题!

latex中页眉设置问题!,第1张

\pagestyle{fancy}                    % 设置页眉

\lhead{page \thepage\ of \pageref{LastPage}}

\chead{页眉中间\\换行(两行中文)}

\rhead{\small\leftmark}

%===============

%双线页眉的设置

\makeatletter %双线页眉

\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi%

\hrule\@height 1.0pt \@width\headwidth\vskip1pt%上面线为1pt粗

\hrule\@height 0.5pt\@width\headwidth  %下面0.5pt粗

\vskip-2\headrulewidth\vskip-1pt}      %两条线的距离1pt

  \vspace{6mm}}     %双线与下面正文之间的垂直间距

\makeatother

%===============

这样是不可以的,最好不要修改 plain 的风格。

你有使用 ctexbook 为文档类吗?在 ctexbook 中有相关的设置,具体来说:

1. 文档类为 ctexbook :

\documentclass{ctexbook}

2. 在导言区设置:

\ctexset {chapter = {pagestyle = fancy}}

推荐使用 ctexbook 的方式实现,它自带很多汉化,非常方便,但是如果你不想改文档类的话,也可以使用下面的方式,在导言区加入:

\makeatletter

\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi

                   \thispagestyle{fancy}% original style: plain

                   \global\@topnum\z@

                   \@afterindentfalse

                   \secdef\@chapter\@schapter}

\makeatother

还有第三种方法,把 plain 设置为 fancy (不一定生效,我没验证)

\makeatletter

  \let\ps@plain\ps@fancy

\makeatother

如果上面的方法无效,还有一个变种,前提是你不需要 empty 风格

\makeatletter

  \let\ps@plain\ps@empty

\makeatother

\fancypagestyle{plain}{%

    \fancyhf{} %

    \fancyhead[LO,RE]{...} %

    \fancyhead[RO,LE]{...} %

    \fancyfoot[C]{...} %

    \renewcommand{\headrulewidth}{0.4pt}  %

    \renewcommand{\footrulewidth}{0.4pt}  %

}

如果你是在写数学建模的模板的话,建议参考一下 TeXLive 自带的 mcmthesis

另外,可以到 LaTeX 科技排版工作室 提问,那里回答更加专业,有代码块

以下答案基于正文使用 fancy 格式的页眉页脚。

\usepackage{fancyhdr} % 引入 fancy 页眉页脚

\usepackage{afterpage}  % \afterpage 命令

\usepackage{tocloft} % 定制目录样式

% 以下这些都是正文页眉页脚的设计,根据实际情况进行修改

\fancyhf{}

\fancyhead[CO]{\thesection} % 分了奇偶页

\fancyhead[CE]{数学建模}

\fancyfoot[RO,LE]{\thepage}

\pagestyle{fancy} %

% 从这里,是摘要和目录页的页眉页脚

\fancypagestyle{plain} % 定义一个名为 plain 的页眉页脚样式

{%

\fancyhead{} %

\fancyfoot[RO,LE]{123456} % 只显示号码,RO LE 根据情况进行修改

\renewcommand{\headrulewidth}{0pt}  % 页眉线粗细

\renewcommand{\footrulewidth}{0pt}  % 页脚线粗细

}

之后在摘要和目录页的地方使用:

\tocloftpagestyle{plain}

\tableofcontents

\thispagestyle{plain}

\afterpage{\thispagestyle{plain}} % 防止多页目录时后面格式不正确

正文之前使用 \setcounter{page}{0} 重新计数

大概就是这么多,具体情况需要你修改,我当初调的时候纠结了很久,总是有问题,如果不行的话你可以看一下我的模板文件 usstthesis.cls,或者继续提问。我的邮箱是 [email protected]


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11374856.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存