目录
字体设置布局设置页眉页脚设置行距的设置其他字体设置
字体设置需要用到宏包fontspec
,需要在导言区添加如下指令:
\usepackage{fontspec}
中英文字体都可以分为如下3种:
正文字体族无衬线字体族打字机字体族
设置中英文正文字体的命令如下(另外两种后面需要用到时再来补上):
%设置英文正文字体\setmainfont{Times New Roman}%设置中文正文字体\setCJKmainfont{SimSun}
注意:设置中文字体前,必须在导言区加入:
\usepackage[slantfont, boldfont]{xeCJK}
上面方括号中的参数开启中文下的斜体与粗体,即使命令\textit{}
和\textbf{}
对中文也有效。
在指定正文字体时,还可以设置其颜色,如下:
%设置英文正文字体为红色\setmainfont[Color={ff0000}]{Times New Roman}%设置中文正文字体为绿色\setCJKmainfont[Color={00ff00}]{SimSun}
布局设置
geometry
包可以用来设置页面的布局,如页边距等,导入geometry
包:
\usepackage{geometry}
设置页边距(上下左右边距)
\geometry{left=25mm,right=20mm,top=25mm,bottom=25mm}
页眉页脚设置
使用fancyhdr
包来进行页眉页脚的设置:
\usepackage{fancyhdr} %导入包\pagestyle{fancy} %指定pagestyle%clears the header and footer,%otherwise the elements of the %default "plain" page style will appear.\fancyhf{}
可以设置页眉页脚各自左中右共6个位置的内容
\lhead{}\chead{}\rhead{}\cfoot{\thepage}\rfoot{}\lfoot{}
关于页码的显示:
\thepage
若要用到总页数,则需要导入包lastpage
:
\usepackage{lastpage}
此时可以设置页码为如x/x
的格式:
\cfoot{\thepage / \pageref{LastPage}}
若要设置页眉页脚线宽,使用如下命令:
\renewcommand{\headrulewidth}{0.1mm}\renewcommand{\footrulewidth}{0.1mm}% 设为0时,不显示相应的线
注意:
命令\geometry{}
必须放在\pagestyle{fancy}
之前首页\maketitle
后需要加上\thispagestyle{fancy}
行距的设置
需要用到包setspace
:
\usepackage{setspace}
设置为20磅行间距:
\setlength{\baselineskip}{20pt}
上面这行命令必须放在
\begin{document}
之后才能生效
其他
不显示日期\date{}
标题斜体\title{\textit{ 你的标题 }}
添加邮箱信息(在作者姓名正下方),纯文本形式:\author{D. Trump \\ trump@}
效果如下:
添加邮箱信息(在作者姓名正下方),超链接形式:
\author{D. Trump \\ \href{mailto:trump@}{trump@} }
此时,邮箱内容为一个超链接,可以点击直接跳转发信。不过这一功能需要另外一个包的支持:
\usepackage{hyperref}
超链接默认是有颜色的,去掉颜色,可使用下面的一行命令:
\hypersetup{hidelinks}
多个作者情况
\author{author1 \and author2}
多个作者且填写各自邮箱时
\author{D. Trump \\ \href{mailto:trump@}{trump@} \andBiden \\ \href{mailto:biden@}{biden@}}
效果如下: