You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
7.1 KiB
195 lines
7.1 KiB
%# -*- coding: utf-8-unix -*-
|
|
|
|
%============================================================================
|
|
% 基本库
|
|
\usepackage{longtable}
|
|
\usepackage{multirow}
|
|
\usepackage{array}
|
|
\usepackage{caption}
|
|
\usepackage{lscape}
|
|
\usepackage{fancyhdr}
|
|
\usepackage{newtxtext}
|
|
\usepackage{amsmath,mathtools,amsthm,amsfonts,amssymb,bm}
|
|
\usepackage{titlesec}
|
|
\usepackage[perpage]{footmisc}
|
|
\usepackage[colorlinks,bookmarksnumbered,urlcolor=blue,
|
|
linkcolor=purple,citecolor=red,plainpages=false]{hyperref}
|
|
\usepackage[centering,a4paper,body={16cm,22cm}]{geometry}
|
|
|
|
%============================================================================
|
|
% 配制全局字体
|
|
% \setmonofont{inconsolata} % 使用 inconsolata 等宽字体
|
|
|
|
% % 使用方正系列字体
|
|
% \setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01}
|
|
% \setCJKfamilyfont{zhsong}{FZShuSong-Z01}
|
|
% \setCJKfamilyfont{zhhei}{FZHei-B01}
|
|
% \setCJKfamilyfont{zhkai}{FZKai-Z03}
|
|
% \setCJKfamilyfont{zhfs}{FZFangSong-Z02}
|
|
% \setCJKfamilyfont{zhli}{FZLiShu-S01}
|
|
% \renewcommand*{\songti}{\CJKfamily{zhsong}} % 宋体
|
|
% \renewcommand*{\heiti}{\CJKfamily{zhhei}} % 黑体
|
|
% \renewcommand*{\kaishu}{\CJKfamily{zhkai}} % 楷体
|
|
% \renewcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
|
|
% \renewcommand*{\lishu}{\CJKfamily{zhli}} % 隶书
|
|
|
|
% \setCJKsansfont{FZHei-B01} % 中文无衬线字体
|
|
% \setCJKmonofont{FZHei-B01} % 中文等宽字体
|
|
|
|
%============================================================================
|
|
% 配制列表环境
|
|
\usepackage{enumitem}
|
|
\setlist{nosep} % 紧凑间距
|
|
\setlist*{leftmargin=*} % 列表和段落头对齐
|
|
\setlist[1]{labelindent=\parindent} % Only the level 1
|
|
%============================================================================
|
|
% 绘图支持
|
|
\usepackage{tikz}
|
|
\definecolor{c1}{RGB}{116, 52, 129} %清华紫
|
|
\definecolor{c2}{RGB}{130, 80, 140}
|
|
\definecolor{c3}{RGB}{230, 180, 240}
|
|
%============================================================================
|
|
% 定制代码框
|
|
\usepackage[breakable,minted]{tcolorbox}
|
|
\newtcblisting{code}[1][]{
|
|
center,
|
|
width=0.95\linewidth,
|
|
listing only,
|
|
breakable=true,
|
|
minted language=#1,
|
|
extras={frame empty},
|
|
fontupper=\linespread{1.3}\small,
|
|
% minted style=colorful,
|
|
minted options={ %自动移除前置空白、制表为4字符、mathhe和||内的不处理
|
|
fontfamily=tt,
|
|
% breaksymbol=,
|
|
autogobble,
|
|
tabsize=4,
|
|
startinline,
|
|
breaklines,
|
|
mathescape
|
|
}
|
|
}
|
|
%============================================================================
|
|
% 设置 PDF 文件信息
|
|
\hypersetup{
|
|
pdfauthor = {计算机网络教案社区},
|
|
pdftitle = {实验指导书},
|
|
pdfkeywords = {计算机网络}}
|
|
|
|
%============================================================================
|
|
% 文档风格
|
|
\ctexset{today=small}
|
|
\ctexset{contentsname=目~~~~录}
|
|
\setcounter{secnumdepth}{4} % 章节编号深度 (part 对应 -1)
|
|
\setcounter{tocdepth}{1} % 目录深度 (part 对应 -1)
|
|
%============================================================================
|
|
% 每节单独起一页
|
|
\newcommand{\sectionbreak}{\clearpage}
|
|
%============================================================================
|
|
% 居中章节标题
|
|
\newenvironment{pre}{
|
|
\titleformat{\chapter}[display]{\centering}{}{-3mm}{\Huge\heiti}
|
|
\titlespacing{\chapter}{0pt}{0pt}{2\baselineskip}
|
|
\chapter{前~~~~言}{}
|
|
}{}
|
|
%============================================================================
|
|
% chapter级样式设置
|
|
\ctexset{chapter/name = {第,单元}}
|
|
\titleformat{\chapter}[display]{\flushleft}{
|
|
\begin{tikzpicture}
|
|
\node[anchor=south west] (chap) at (0,1.3){
|
|
\Large\heiti {\chaptername}};
|
|
\path[left color=c1,right color=c3]
|
|
(0,-0.3)rectangle(\textwidth,-0.5);
|
|
\end{tikzpicture}
|
|
}{-30mm}{\Huge\heiti}
|
|
\titlespacing{\chapter}{0pt}{0pt}{2\baselineskip}
|
|
%============================================================================
|
|
% section级样式设置
|
|
\ctexset{section/break = \Needspace{\textheight}}
|
|
\ctexset{section={
|
|
name={实验},
|
|
format={\Large\heiti\centering},
|
|
afterskip={1.0ex \@plus .2ex},
|
|
}
|
|
}
|
|
%============================================================================
|
|
% subection级样式设置
|
|
\ctexset{subsection={
|
|
format={\bfseries\heiti\normalsize},
|
|
indent={0\ccwd},
|
|
afterskip={1.0ex \@plus .2ex},
|
|
number={\chinese{subsection}~.}
|
|
}
|
|
}
|
|
%============================================================================
|
|
% subsubection级样式设置
|
|
\ctexset{subsubsection={
|
|
format={\bfseries\bfseries\normalsize},
|
|
indent={0\ccwd},
|
|
afterskip={1.0ex \@plus .2ex},
|
|
number={\arabic{subsection}.\arabic{subsubsection}}
|
|
}
|
|
}
|
|
%============================================================================
|
|
% paragraph级样式设置
|
|
\ctexset{paragraph={
|
|
format={\normalfont\normalsize},
|
|
indent={0\ccwd},
|
|
number={\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
|
|
}
|
|
}
|
|
%============================================================================
|
|
% 设置页眉与页脚样式
|
|
\def\markboxwidth{0.75\textwidth}
|
|
\pagestyle{fancy}
|
|
\fancyhf{}
|
|
\renewcommand{\chaptername}{第\zhnumber{\thechapter}单元}
|
|
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ #1}{}}
|
|
% 在奇数页的右上角显示页码,偶数页的左上角显示页码
|
|
\fancyhead[LE,RO]{\sffamily\normalsize\thepage}
|
|
\fancyhead[LO]{\nouppercase{\small\kaishu\rightmark}} % 在奇数页的左侧显示小节名
|
|
\fancyhead[RE]{\nouppercase{\small\kaishu\leftmark}} % 在偶数页的右侧显示章名
|
|
\renewcommand{\headrulewidth}{0.5pt}
|
|
\addtolength{\headheight}{2.5pt}
|
|
\renewcommand{\footrulewidth}{0pt}
|
|
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}
|
|
%============================================================================
|
|
% 设置图片的标题样式
|
|
\DeclareCaptionFont{heiti}{\heiti}
|
|
\captionsetup{format=plain,labelformat=simple,
|
|
labelsep=space,justification=centering,
|
|
font={small,heiti}}
|
|
\captionsetup[sub]{font=footnotesize}
|
|
%============================================================================
|
|
% 设置图、表的号
|
|
\numberwithin{figure}{section}
|
|
\numberwithin{table}{section}
|
|
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}--\arabic{figure}}
|
|
\renewcommand{\thetable}{\arabic{chapter}.\arabic{section}--\arabic{table}}
|
|
%============================================================================
|
|
% 设置目录格式
|
|
\makeatletter
|
|
\renewcommand\tableofcontents{%
|
|
\cleardoublepage
|
|
\pdfbookmark[0]{\contentsname}{toc}
|
|
\chapter*{\centerline{\Huge\heiti\contentsname}}
|
|
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
|
|
\@starttoc{toc}%
|
|
}
|
|
\addtocontents{toc}{\let\string\CTEX@spaceChar\relax}
|
|
\makeatother
|
|
%============================================================================
|
|
% 行距缩放
|
|
\linespread{1.5}
|
|
\renewcommand{\arraystretch}{1}
|
|
%============================================================================
|
|
% 调整附录格式
|
|
\let\stdappendix\appendix
|
|
\renewcommand{\appendix}{
|
|
\stdappendix
|
|
\renewcommand{\thefigure}{\Alph{chapter}--\arabic{figure}}
|
|
\renewcommand{\thetable}{\Alph{chapter}--\arabic{table}}
|
|
\renewcommand{\chaptername}{附录\Alph{chapter}}
|
|
} |