清理格式,基础文档类调整为ctexbook

merge-requests/11/head
Xphi 4 years ago
parent 4b89a51914
commit 7067b86081

@ -1,30 +1,47 @@
%# -*- coding: utf-8-unix -*- %# -*- coding: utf-8-unix -*-
\usepackage{hyperref} %============================================================
% 基本库
\usepackage{longtable} \usepackage{longtable}
\usepackage{url}
\usepackage{array}
\usepackage{multirow} \usepackage{multirow}
\usepackage{array}
\usepackage{caption}
\usepackage{lscape} \usepackage{lscape}
\usepackage{fancyhdr}
\usepackage{amsmath,mathtools,amsthm,amsfonts,amssymb,bm}
\usepackage[colorlinks, urlcolor=blue, linkcolor=purple, citecolor=red]{hyperref}
\usepackage[centering,a4paper,body={16cm,22cm}]{geometry}
%============================================================
% 配制列表环境
\usepackage{enumitem}
\setlist{nosep} % 紧凑间距
\setlist*{leftmargin=*} % 列表和段落头对齐
\setlist[1]{labelindent=\parindent} % Only the level 1
%============================================================
% 每节单独起一页
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
%============================================================
% 绘图支持
\usepackage{tikz} \usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows} % \usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{shapes,decorations} % \usetikzlibrary{shapes,decorations}
\usetikzlibrary{intersections,decorations.text} % \usetikzlibrary{intersections,decorations.text}
\definecolor{c1}{RGB}{116, 52, 129} \definecolor{c1}{RGB}{116, 52, 129} %清华紫
\definecolor{c2}{RGB}{130, 80, 140} \definecolor{c2}{RGB}{130, 80, 140}
\definecolor{c3}{RGB}{230, 180, 240}
\tcbuselibrary{minted} %============================================================
% 定制代码框
\usepackage[breakable,minted]{tcolorbox}
\newtcblisting{code}[1][]{ \newtcblisting{code}[1][]{
center, center,
width=0.95\linewidth, width=0.95\linewidth,
listing only, listing only,
breakable=true, breakable=true,
minted language=#1, minted language=#1,
% frame empty,
extras={frame empty}, extras={frame empty},
% minted style=colorful,
fontupper=\small, fontupper=\small,
% minted style=colorful,
minted options={ %自动移除前置空白、制表为4字符、mathhe和||内的不处理 minted options={ %自动移除前置空白、制表为4字符、mathhe和||内的不处理
breaksymbol=, breaksymbol=,
autogobble, autogobble,
@ -34,10 +51,120 @@
mathescape mathescape
} }
} }
%============================================================
% 设置 PDF 文件信息
\hypersetup{
pdfauthor = {计算机网络教案社区},
pdftitle = {实验指导书},
pdfkeywords = {计算机网络}}
\newcommand{\cndash}{\rule{0.0em}{0pt}\rule[0.35em]{1.4em}{0.05em}\rule{0.2em}{0pt}} %============================================================
\newcommand{\ch}{\titleformat{\chapter}[display]{\centering}{}{-3mm}{\Huge\bfseries} % 文档风格
\titlespacing{\chapter}{0pt}{0pt}{2\baselineskip}}%用来将需要的章节标题居中 \ctexset{today=small}
\ctexset{contentsname=目~~~~录}
\setcounter{secnumdepth}{4} % 章节编号深度 (part 对应 -1)
\setcounter{tocdepth}{1} % 目录深度 (part 对应 -1)
%============================================================
% 居中章节标题
\newenvironment{pre}{ \newenvironment{pre}{
\ch\chapter{前~~~~言}{}}{} \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
%======================================================================
% 行距缩放
\renewcommand{\baselinestretch}{1.5}%======================================================================
% 调整附录格式
\newcommand{\appendixes}{
\appendix
\renewcommand{\thefigure}{\Alph{chapter}--\arabic{figure}}
\renewcommand{\thetable}{\Alph{chapter}--\arabic{table}}
\renewcommand{\chaptername}{附录\Alph{chapter}}
}

@ -1,51 +1,33 @@
%# -*- coding: utf-8-unix -*- %# -*- coding: utf-8-unix -*-
\documentclass[cn]{elegantbook} \documentclass[zihao=-4]{ctexbook}
\input{config} \input{config}
\begin{document} \begin{document}
\pagestyle{empty}
\input{../data/cover} % 载入封面 \pagestyle{empty} % 前导页无页眉页脚
%============================================================
%========================================================================= % 封面
% 版本声明 \input{../data/cover}
\clearpage %============================================================
\begin{center} % 版权页
\Large{Version 1.0$\alpha$} \\ \vspace{2em} \input{../data/copyright}
\Large{发布日期: {\number\year\number\month\number\day}}
% \\ \vspace{1em} \frontmatter % 从前言开始用罗马数字作为页码
\end{center} %============================================================
% \vfill
% \vspace{30em}
% \begin{tabular*}{\textwidth}{ccc}
% \includegraphics{figure/by-nc.eps}
% & \begin{minipage}[b]{0.6\textwidth}
% \small\sffamily
% 本作品采用知识共享 署名-非商业性使用 4.0 国际许可协议进行许可。\\
% 访问~\href{http://creativecommons.org/licenses/by-nc/4.0/}{此链接}~查看该许可协议。
% \end{minipage}
% \end{tabular*}
%=========================================================================
% 前言 % 前言
\thispagestyle{empty}
\frontmatter % 对前言和概览用罗马数字作为页码
\pagestyle{empty}
\input{../data/preface} \input{../data/preface}
%============================================================
%=========================================================================
% 目录 % 目录
\cleardoublepage \cleardoublepage
\pagestyle{empty}
\tableofcontents \tableofcontents
\mainmatter % 对正文用阿拉伯数字作为页码
%====================================================================== \mainmatter % 从正文开始用阿拉伯数字作为页码
\pagestyle{fancy} % 正文有页眉页脚
\setcounter{page}{1} % 正文页码从1开始
%============================================================
% 正文内容 % 正文内容
% \pagestyle{fancy}
\setcounter{page}{1}
% “网络抓包与协议分析” % “网络抓包与协议分析”
\graphicspath{{../figure/chapters/wireshark/}} \graphicspath{{../figure/chapters/wireshark/}}
@ -61,7 +43,6 @@
\input{../data/ch_socket/sec_web} \input{../data/ch_socket/sec_web}
\input{../data/ch_socket/sec_smtp} \input{../data/ch_socket/sec_smtp}
% “组网基础” % “组网基础”
\graphicspath{{../figure/chapters/ensp/}} \graphicspath{{../figure/chapters/ensp/}}
\input{../data/ch_ensp/preface} \input{../data/ch_ensp/preface}
@ -83,22 +64,9 @@
\input{../data/ch_sdn-openbox/sec_topo} \input{../data/ch_sdn-openbox/sec_topo}
\input{../data/ch_sdn-openbox/sec_ns} \input{../data/ch_sdn-openbox/sec_ns}
%============================================================
% % %========================================================================= % 附录
% % % 附录 \appendixes
% % \appendix
% % \titleformat{\chapter}[display]{\flushleft}{
% % \begin{tikzpicture}
% % \node[anchor=south west] (chap) at (0,1.3){
% % \Large\heiti {附录\Alph{chapter}}};
% % \path [left color=c1,right color=c3] (0,-0.3) rectangle (\textwidth,-0.5);
% % \path(0,-0.2);
% % \end{tikzpicture}
% % }{-30mm}{\Huge\heiti}
% % \titlespacing{\chapter}{0pt}{0pt}{2\baselineskip}
% % \renewcommand{\thefigure}{\Alph{chapter}--\arabic{figure}}
% % \renewcommand{\thetable}{\Alph{chapter}--\arabic{table}}
% % \renewcommand{\chaptername}{附录\Alph{chapter}}
% 速查手册 % 速查手册
\graphicspath{{../figure/appendixes/cheat_sheet/}} \graphicspath{{../figure/appendixes/cheat_sheet/}}
@ -116,11 +84,4 @@
\graphicspath{{../figure/appendixes/fast/}} \graphicspath{{../figure/appendixes/fast/}}
\input{../data/appendix/fast} \input{../data/appendix/fast}
\backmatter
%======================================================================
% 参考文献
% \printbibliography[heading=bibintoc]
% \makeatletter
% \makeatother
\end{document} \end{document}

@ -0,0 +1,20 @@
%=========================================================================
% 版本声明
\clearpage
\begin{center}
\Large{Version 1.0$\alpha$} \\ \vspace{2em}
\Large{发布日期: \today}%{\number\year\number\month\number\day}}
% \\ \vspace{1em}
\end{center}
% \vfill
% \vspace{30em}
% \begin{tabular*}{\textwidth}{ccc}
% \includegraphics{figure/by-nc.eps}
% & \begin{minipage}[b]{0.6\textwidth}
% \small\sffamily
% 本作品采用知识共享 署名-非商业性使用 4.0 国际许可协议进行许可。\\
% 访问~\href{http://creativecommons.org/licenses/by-nc/4.0/}{此链接}~查看该许可协议。
% \end{minipage}
% \end{tabular*}
Loading…
Cancel
Save