2023年7月11日发(作者:)
在LATEX中设置页眉页脚以及页码⾸先设置页码:在正⽂中调⽤页码命令pagenumbering{数字形式}。其中数字形式可取值如下:arabic, 阿拉伯数字roman, ⼩写罗马数字Roman,⼤写罗马数字alpha, ⼩写拉丁字母Alpha, ⼤写拉丁字母在latex中⽤⾃定义页眉页脚, ⼀般都要使⽤宏包fancy. 关键是琢磨⼀下下⾯的例⼦, 在看看相应的说明,⼀般就可以得到你想要的结果了. 下⾯的内容主要来⾃CTEX – 在线⽂档, 例⼦部分已经修改过来了, 可以直接编译.在⽤ LaTeX 排版⽂章、书籍时,缺省定义了四种页眉页脚的格式:empty 没有页眉和页脚plain 没有页眉,页脚中部放置页码。headings 没有页脚,页眉包含章节的标题和页码。myheadings 没有页脚,页眉页码和使⽤者所定义的信息。article 缺省使⽤ plain 格式,⽽ book 则使⽤headings 格式。 也可⽤ pagestyle命令在你的⽂档中设定所⽤的格式,例如在⽂档中使⽤pagestyle{empty} 则使得此后的页⾯没有页眉和页脚。⼀般情况下,这四种格式基本可满⾜排版的要求。但在某些情况下,特别是 使⽤者想定义⾃⼰的页眉和页脚格式时,就会遇到很多限制和⿇烦。这时,使⽤ fancyhdr 宏包可以很容易地达到⽬的。利⽤ fancyhdr 宏包提供的命令,可以⽅便的作到:⾃定义页眉和页脚。为页眉和页脚加上装饰性的横线。页眉和页脚的宽度可以超过正⽂⽂本的宽度。多⾏的页眉和页脚。奇偶页使⽤不同格式的页眉和页脚。每章的⾸页使⽤不同格式的页眉和页脚。浮动对象页使⽤不同格式的页眉和页脚。控制页眉和页脚的字体,包括字形,字族,⼤⼩写等。简单的例⼦:documentclass{article}usepackage{fancyhdr}pagestyle{fancy}lhead{}chead{}rhead{bfseries The performance of new graduates}lfoot{From: K. Grant}cfoot{To: Dean A. Smith}rfoot{thepage}renewcommand{headrulewidth}{0.4pt}renewcommand{footrulewidth}{0.4pt}%……begin{document}……test!end{document}上⾯例⼦中,thepage 给出了当前页的页码,⽽ bfseries 则使 LaTeX使⽤粗体字排版页眉。如果想在⽂档中改⽤其它形式,⽐如在第⼀页不要页眉和页脚,则可在 begin{document} 和maketitle 后使⽤命令thispagestyle{empty}缺省情况下,maketitle 命令会⾃动设置其所在页的格式为 plain 。因此,如果你想在该页使⽤ fancy 格式的话,应该在maketile 后⾯使⽤命令thispagestyle{fancy}。下⾯是⼀个双⾯页版式下的例⼦:documentclass{book}usepackage{fancyhdr}fancyhead{} % clear all fieldsfancyhead[RO,LE]{bfseries The performance of new graduates}fancyfoot[LE,RO]{thepage}fancyfoot[LO,CE]{From: K. Grant}fancyfoot[LO,CE]{From: K. Grant}fancyfoot[CO,RE]{To: Dean A. Smith}renewcommand{headrulewidth}{0.4pt}renewcommand{footrulewidth}{0.4pt}begin{document}……test!end{document}这⾥⽅括号中字母代表的意义为:E 偶数页O 奇数页L 页眉或页脚的左边部分C 页眉或页脚的中间部分R 页眉或页脚的右边部分H 页眉F 页脚在配合 CJK 排版中⽂⽂档时,要把带有中⽂的页眉和页脚的定义⽤ begin{CJK}{…}{…} 和 end{CJK}括起来。最简单的办法是将其放到begin{document} 和begin{CJK}{…}{…} 之后。如:documentclass{book}usepackage{CJK}usepackage{fancyhdr}%……begin{document}begin{CJK}{GBK}{song}pagestyle{fancy}fancyhead{} % clear all fieldsfancyhead[RO,LE]{CJKfamily{hei} bfseries LaTeX{} 排版系统}fancyhead[LO,RE]{CJKfamily{hei>} bfseriesleftmark}fancyfoot[LE,RO]{thepage}fancyfoot[LO,RE]{CJKfamily{kai} 公元⼆零零零年七⽉}renewcommand{headrulewidth}{0.4pt}renewcommand{footrulewidth}{0.4pt}%……test!end{CJK}end{document}有关 fancyhdr 更详细的使⽤说明可参考它所带的⽤户⼿册(英⽂版,PDF 格式).下⾯是另外⼀种设置⽅法样例:单⾯样例:documentclass{article}usepackage{lastpage}%获得总页数usepackage{fancyhdr}pagestyle{fancy}lhead{}chead{}rhead{}lfoot{}cfoot{}rfoot{thepage of pageref{LastPage}}%当前页 of 总页数renewcommand{headrulewidth}{0.4pt}%改为0pt即可去掉页眉下⾯的横线renewcommand{footrulewidth}{0.4pt}%改为0pt即可去掉页脚上⾯的横线begin{document}This short code shows how to use fancy package in the case ofoneside {document}双⾯样例:documentclass{book}usepackage{lastpage}%获得总页数usepackage{fancyhdr}pagestyle{fancy}%以下命令中L--左侧 R--右侧 C--中间 O--奇数页 E--偶数页fancyhead[LO,RE]{head}%奇数页左侧,偶数页右侧显⽰页眉fancyfoot[CO,RE]{}%奇数页中间,偶数页右侧页脚为空fancyfoot[LO,CE]{}%奇数页左侧,偶数页中间页脚为空fancyfoot[RO,LE]{thepage ofpageref{LastPage}}%奇数页右侧,偶数页左侧显⽰ 当前页 of 总页数renewcommand{headrulewidth}{0.4pt}%改为0pt即可去掉页眉下⾯的横线renewcommand{footrulewidth}{0.4pt}%改为0pt即可去掉页脚上⾯的横线begin{document}This short code shows how to use fancy package in the caseoftwoside {document}
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689046157a199665.html
评论列表(0条)