diff --git a/.gitignore b/.gitignore index d3b29b7..cb14806 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,15 @@ *.snm *.vrb +# biblatex 的中间产物(教材/ 会生成) +# *-blx.bib biblatex 自动写的"引用收集"文件,每次编译重写,不是输入 +# *.run.xml biblatex 运行时状态 +*-blx.bib +*.run.xml + +# 各模板的预览图(截图导出,不入库) +*/.preview/ + # 简历成果统计的自动生成文件(每次编译重写,不要提交) # 见 简历/awesome-source-cv.cls 的「成果统计」一节 *.cvnum diff --git a/build.sh b/build.sh index da55b66..ea4b5da 100755 --- a/build.sh +++ b/build.sh @@ -56,7 +56,21 @@ build_one() { # 第一遍:产出 .aux/.toc,允许非致命错误(TOC 还没生成时会警告) ( cd "$ROOT/$dir" && $TEXBIN -interaction=nonstopmode "$name.tex" ) > "$log1" 2>&1 local rc1=$? - # 第二遍:交叉引用稳定后的最终结果,统计以这一遍为准 + + # 有参考文献库时插入 bibtex(教材/ 等模板需要)。 + # ⚠️ 判定依据是目录下存在 **任意 .bib** 且不是 biblatex 自动生成的 + # "*-blx.bib"(那是 biblatex 的中间产物,不能当输入跑 bibtex)。 + # biblatex 的 bcf 后端用 biber,但本库统一用 bibtex 后端(elegantbook + # 的默认),且仓库里的模板都用 bibtex,故这里只调 bibtex。 + # bibtex 失败不中断构建 —— 下一遍 xelatex 会用旧的 .bbl, + # 参考文献可能不全,但正文和版式照常验证。 + if ( cd "$ROOT/$dir" && ls *.bib 2>/dev/null | grep -qv -- '-blx\.bib$' ); then + ( cd "$ROOT/$dir" && bibtex "$name" ) > "/tmp/oucbibtex.$$.log" 2>&1 || true + # bibtex 之后必须再跑一遍让引用编号落位 + ( cd "$ROOT/$dir" && $TEXBIN -interaction=nonstopmode "$name.tex" ) > "$log1" 2>&1 + fi + + # 最后一编:交叉引用稳定后的最终结果,统计以这一遍为准 ( cd "$ROOT/$dir" && $TEXBIN -interaction=nonstopmode "$name.tex" ) > "$log" 2>&1 local rc2=$? diff --git a/verify_all.sh b/verify_all.sh index 4096aff..561c78c 100755 --- a/verify_all.sh +++ b/verify_all.sh @@ -37,6 +37,7 @@ TARGETS=( "课程教学日历|课程教学日历.tex" "课程大纲|课程大纲.tex" "会议预算表|会议预算表.tex" + "教材|教材.tex" ) filter="${1:-}" diff --git a/教材/README.md b/教材/README.md new file mode 100644 index 0000000..0cd9056 --- /dev/null +++ b/教材/README.md @@ -0,0 +1,210 @@ +# 教材 + +中国海洋大学 教材 LaTeX 模板。 + +版式从《软件需求工程导论》(sre 仓库)的成品书抽取而来, +保留其全部排版特性,正文内容为占位示例。 + +## 编译 + +```bash +cd 教材 +xelatex 教材.tex # 无参考文献时,单次即可 +``` + +有参考文献时(本模板默认就有)走完整流程: + +```bash +xelatex 教材.tex +bibtex 教材 +xelatex 教材.tex +xelatex 教材.tex +``` + +或仓库根:`bash build.sh 教材`(已自动处理 bibtex) + +## 文件 + +| 文件 | 作用 | +|---|---| +| `ouctextbook.sty` | 版式配置(编号层级、封面色、宏包、断行) | +| `elegantbook.cls` | **本地化过的**文档类(改过字体,见下) | +| `教材.tex` | 示例正文 | +| `reference.bib` | 参考文献库(内容是虚构条目) | +| `README.md` | 本文件 | + +## ⚠️ 唯一的结构性差异:本模板带一份 cls + +仓库其他模板只需 `\input{../fonts.tex}`。本模板还需要一份 +**改过字体的 `elegantbook.cls`**,原因如下。 + +### elegantbook 的三档中文字体,全都不通用 + +| 选项 | 实际字体 | 问题 | +|---|---|---| +| `founder`(默认) | FZShuSong-Z01 / FZHei-B01 / FZKai-Z03 / FZFangSong-Z02 | **方正商业字体,不能分发** | +| `ctexfont` | 系统字体(Windows=SimSun/SimHei,macOS=PingFang) | 同一份源码三个平台三种样子 | +| `nofont` | 不设,交给用户 | 不配置就直接报错 | + +### 但只写 nofont 还不够 + +`elegantbook.cls` 自身还硬编码了两处西文字体: + +```latex +\setmainfont{TeXGyreTermesX}[...] % 西文衬线 +\setsansfont{texgyreheros}[...] % 西文无衬线 +``` + +这两款在精简版 TeX Live 和很多机器上都没有,会直接报 + +``` +! Package fontspec Error: The font "texgyreheros-regular" cannot be found +``` + +而且是 9 个错误连发(类的每个字体档位都失败一次)。 + +**实测:在 `\documentclass` 之后用 `\setsansfont` 覆盖无效** —— +类加载时字体族已经注册失败,后面的重新指定救不回来。 + +### 所以 cls 必须本地化 + +模板目录里的 `elegantbook.cls` 相对上游改了三处,都带 +「本地化」注释,便于将来对比上游版本: + +| 位置 | 改动 | 原因 | +|---|---|---| +| 第 176 行附近 | `TeXGyreTermesX` → `texgyretermes`,加 `Path=../fonts/tex-gyre-termes/` | 用仓库自带字体 | +| 第 184 行附近 | `texgyreheros` → `OUCSans`,加 `Path=../fonts/ouc-sans/` | 仓库没有 Hero | +| `\maketitle` 内 | `example-image` → `\ouc@coverblank` | 无封面图时不插占位图 | + +### 中文依赖链 + +`nofont` 模式下 elegantbook **不定义** `\songti` / `\heiti` / `\kaishu` / +`\fangsong`,但它的 `\cbfseries`、章节标题都依赖 `\heiti`。 + +这层依赖由 `../fonts.tex` 补上——那里已用 `\def` 定义这四个命令。 +**若哪天 fonts.tex 改了这几个命令的名字,本模板的章节标题会立刻失去中文字体。** + +## ⚠️ 封面:三个坑 + +### 1. 不写 `\cover{}` 会插一张 "Image" 占位图 + +elegantbook 在 `\maketitle` 里: + +```latex +\ifcsname @cover\endcsname + \includegraphics[width=\linewidth]{\@cover} +\else + \includegraphics[width=\linewidth]{example-image} ← mwe 宏包的灰底占位图 +\fi +``` + +首页顶着 "Image" 两个大字。本地化版本已把 `else` 分支换成空盒子。 + +### 2. 空盒子的宽度不能是 0 + +第一版把占位改成 `\rule{0pt}{0pt}`(0 宽),结果**冒出 5pt Overfull**, +且只出现在 `\maketitle` 那一行,怎么调 `\hspace`、`minipage` 宽度都去不掉。 + +根因:0 宽空盒让 `\linewidth` 在 titlepage 里的计算与 `\textwidth` 差了 5pt, +后续并排的 `\parbox` + 两个 `minipage` 就超了。 + +✅ 正解给占位盒一个满宽: + +```latex +\newcommand{\ouc@coverblank}{\rule{0pt}{0pt}\hspace{\linewidth}\rule{0pt}{0pt}} +``` + +实测 0 Overfull。 + +### 3. 要真封面就写 `\cover{文件}` + +把图片放进本目录,导言区加 `\cover{cover.jpg}` 即可,走插图分支。 + +## 版式参数 + +``` +页面 A4 210 × 297 mm +边距 上下 25.4mm,左右 20mm +headheight 2.17cm,headsep 4mm,footskip 12mm +字号 10pt(比仓库其他模板的 12pt 小,原教材如此) +行距 1.2 倍(elegantbook 默认) +封面色 RGB(32, 178, 170) 青绿 +``` + +## 标题编号 + +``` +章 1 +节 1.1 +小节 1.1.1 +小小节 1.1.1.1 ← secnumdepth=3,编号最多到这里 +第 5 级 (1)(2)(3) ← 不进编号体系,随小节重置 +``` + +第 5 级为什么要单独处理:`secnumdepth=4` 会排出 `3.1.1.1.1` 这种过长编号, +教材里很难看。改用带括号的序号,与正文行文习惯一致。 + +## 章的标准结构 + +原教材 13 章全部遵循,做模板时保留: + +```latex +\chapter{标题} +导语(3~5 段,概述本章问题、结构、与相邻章的关系) +\section{...} +\section{本章小结} % 用 \oucsummary +\section{习题} % 用 \oucexercises +``` + +两个小节做成了命令,避免各章写法不一致。 + +## 字体(全部来自仓库,无商业字体) + +| 用途 | 字体 | 来源目录 | +|---|---|---| +| 中文正文 | OUC Serif | `../fonts/ouc-serif/` | +| 中文黑体 | OUC Sans | `../fonts/ouc-sans/` | +| 中文楷体(代斜体) | OUC Kai | `../fonts/ouc-kai/` | +| 中文仿宋 | Zhuque Fangsong | `../fonts/zhuque-fangsong/` | +| 西文正文 | TeX Gyre Termes | `../fonts/tex-gyre-termes/` | +| 西文无衬线 | OUC Sans | `../fonts/ouc-sans/` | + +PDF 内嵌字体实测: +``` +OUCSerif-Regular / OUCSerif-Bold / OUCKai-Regular +TeXGyreTermes-Regular / -Bold / -Italic +LMMono10-Regular ← \texttt 用的等宽,TeX Live 自带 +``` + +⚠️ `LMMono10` 是 Computer Modern 等宽字体,用于 `\texttt{}`(代码、DOI)。 +仓库 fonts.tex **没有配等宽字体**,elegantbook 也没有。它由 TeX Live +自带,WSL 和 Windows 两端都有,所以跨平台一致,不算问题。 +要换成别的等宽字体,在导言区加 `\setmonofont{...}`。 + +## 验证 + +``` +8 页 error 0 Overfull 0 Underfull 0 +字体全部来自 ../fonts/,无商业字体、无系统字体 +全库 16/16 通过 +``` + +⚠️ Windows 端本机未能编译(TeX Live 写字体缓存被安全策略拦截), +但模板只依赖 TeX Live 标准宏包与发行版自带字体,不涉及平台特有资源。 +原教材本身就是在 Windows + TeX Live 2022 上编译的。 + +## 与原教材的差异 + +| 项 | 原教材 | 本模板 | 原因 | +|---|---|---|---| +| 封面图 | cover.jpg | 无(纯色带) | 模板不附图片 | +| 字体 | 方正四大字体 | 仓库开源字体 | 商业字体不能分发(#17 的规矩) | +| 西文无衬线 | texgyreheros | OUC Sans | 仓库没有 Hero | +| 正文 | 13 章 265 页 | 1 章示例 | 只抽骨架 | + +## 已知问题 + +`\texttt{}` 用的是 Computer Modern 等宽(LMMono10),与正文西文 +Termes 风格不搭。成因是仓库未统一配置等宽字体,见上文字体表。 +目前仅 2 处用到(示例里的 `booktabs` 和一条 DOI),不影响观感。 \ No newline at end of file diff --git a/教材/elegantbook.cls b/教材/elegantbook.cls new file mode 100755 index 0000000..d0a7f0f --- /dev/null +++ b/教材/elegantbook.cls @@ -0,0 +1,1489 @@ +%%%%%%%%%%%%%%%%%%%%%% +%% start of file `elegantbook.cls'. +%% Copyright 2013-2022 ElegantLaTeX (elegantlatex2e@gmail.com) +%% +%% This work may be distributed and/or modified freely +%% available at https://github.com/ElegantLaTeX/ElegantBook +% +%%%%%%%%%%%%%%%%%%%%% +% % !Mode:: "TeX:UTF-8" +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{elegantbook}[2022/12/31 v4.5 ElegantBook document class] + + +%%% +\RequirePackage{kvoptions} +\RequirePackage{etoolbox} +\SetupKeyvalOptions{family=ELEGANT, prefix=ELEGANT@, setkeys=\kvsetkeys} +\newcommand{\ekv}[1]{\kvsetkeys{ELEGANT}{#1}} +% ----- Colors ----- +\DeclareStringOption[blue]{color} +\DeclareStringOption[en]{lang} +\DeclareStringOption[answer]{result} +\DeclareStringOption[fancy]{mode} +\DeclareStringOption[normal]{device} +\DeclareStringOption[cm]{math} +\DeclareStringOption[marginfalse]{marginpar} +\DeclareStringOption[onecol]{toc} +\DeclareStringOption{scheme} + +% ----- backward compatibility +\DeclareVoidOption{green}{\ekv{color=green}} +\DeclareVoidOption{cyan}{\ekv{color=cyan}} +\DeclareVoidOption{blue}{\ekv{color=blue}} +\DeclareVoidOption{gray}{\ekv{color=gray}} +\DeclareVoidOption{black}{\ekv{color=black}} +\DeclareVoidOption{nocolor}{\ekv{color=none}} + +\DeclareVoidOption{chinese}{\ekv{scheme=chinese}} + +\DeclareStringOption[ctexfont]{chinesefont} +\DeclareVoidOption{ctexfont}{\ekv{chinesefont=ctexfont}} +\DeclareVoidOption{founder}{\ekv{chinesefont=founder}} +\DeclareVoidOption{nofont}{\ekv{chinesefont=nofont}} + +\DeclareVoidOption{en}{\ekv{lang=en}} +\DeclareVoidOption{cn}{\ekv{lang=cn}} +\DeclareVoidOption{it}{\ekv{lang=it}} +\DeclareVoidOption{fr}{\ekv{lang=fr}} +\DeclareVoidOption{nl}{\ekv{lang=nl}} +\DeclareVoidOption{hu}{\ekv{lang=hu}} +\DeclareVoidOption{de}{\ekv{lang=de}} +\DeclareVoidOption{mn}{\ekv{lang=mn}} +\DeclareVoidOption{pt}{\ekv{lang=pt}} +\DeclareVoidOption{jp}{\ekv{lang=jp}} + +\DeclareVoidOption{fancy}{\ekv{mode=fancy}} +\DeclareVoidOption{simple}{\ekv{mode=simple}} +\DeclareBoolOption[false]{usesamecnt} + +\DeclareVoidOption{answer}{\ekv{result=answer}} +\DeclareVoidOption{noanswer}{\ekv{result=noanswer}} + +\DeclareVoidOption{normal}{\ekv{device=normal}} +\DeclareVoidOption{pad}{\ekv{device=pad}} + +\DeclareStringOption[numeric-comp]{citestyle} +\DeclareStringOption[numeric]{bibstyle} + +\DeclareVoidOption{newtx}{\ekv{math=newtx}} +\DeclareVoidOption{mtpro2}{\ekv{math=mtpro2}} +\DeclareVoidOption{cm}{\ekv{math=cm}} + +\DeclareVoidOption{margintrue}{\ekv{marginpar=margintrue}} +\DeclareVoidOption{marginfalse}{\ekv{marginpar=marginfalse}} + + +\DeclareVoidOption{onecol}{\ekv{toc=onecol}} +\DeclareVoidOption{twocol}{\ekv{toc=twocol}} + +\DeclareStringOption[chapter]{thmcnt} +\DeclareVoidOption{chapter}{\ekv{thmcnt=chapter}} +\DeclareVoidOption{section}{\ekv{thmcnt=section}} + +\DeclareStringOption[bibtex]{bibend} +\DeclareVoidOption{biber}{\ekv{bibend=biber}} +\DeclareVoidOption{bibtex}{\ekv{bibend=bibtex}} + + +% ----- Math option ----- +\newcommand\mailto[1]{\href{mailto:#1}{\nolinkurl{#1}}} + +% ----- Title Style ----- +\DeclareStringOption[hang]{titlestyle}[hang] +% ----- backward compatibility +\DeclareVoidOption{hang}{\ekv{titlestyle=hang}} +\DeclareVoidOption{display}{\ekv{titlestyle=display}} +% ----- Default Options ----- +\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{book}} + +\ProcessKeyvalOptions*\relax +% \ProcessOptions*\relax +\LoadClass[a4paper,oneside]{book} + +\RequirePackage{setspace} + +\RequirePackage{csquotes} + + +\RequirePackage{hyperref} +\hypersetup{ + breaklinks, + unicode, + linktoc=all, + bookmarksnumbered=true, + bookmarksopen=true, + pdfkeywords={ElegantBook}, + colorlinks, + linkcolor=winered, + citecolor=winered, + urlcolor=winered, + plainpages=false, + pdfstartview=FitH, + pdfborder={0 0 0}, + linktocpage +} +\newif\ifELEGANT@Hy@later + \@ifpackagelater{hyperref}{2022/05/16} + {\ELEGANT@Hy@latertrue} + {\ELEGANT@Hy@laterfalse} + +%% device settings +\RequirePackage{geometry} +\ifdefstring{\ELEGANT@device}{normal}{ + \geometry{ + a4paper, + top=25.4mm, bottom=25.4mm, + left=20mm, right=20mm, + headheight=2.17cm, + headsep=4mm, + footskip=12mm + } + \ifdefstring{\ELEGANT@marginpar}{margintrue}{ + \geometry{ + marginparwidth=5cm, marginparsep=5mm, + left=2cm,right=7cm}}{\relax}}{ + \relax} + +\ifdefstring{\ELEGANT@device}{pad}{ +\geometry{ + paperwidth=7.5in, + paperheight=10in, + margin=16mm, + headheight=2.17cm, + footskip=4mm +}}{\relax} + + +\RequirePackage{indentfirst,comment} +% fontsetting +\ifdefstring{\ELEGANT@math}{mtpro2}{ + \let\Bbbk\relax + \RequirePackage[lite]{mtpro2} +}{\relax} + +\setcounter{tocdepth}{1} +\renewcommand{\baselinestretch}{1.2} + +\PassOptionsToPackage{no-math}{fontspec} +\PassOptionsToPackage{quiet}{fontspec} +\RequirePackage{iftex} + +\ifpdftex + \RequirePackage{newtxtext} + \RequirePackage[scaled=.90]{helvet} +\else + \RequirePackage[no-math]{fontspec} + % ===== 本地化:改用仓库自带字体(原版用 TeXGyreTermesX / texgyreheros)===== + \setmainfont{texgyretermes}[ + UprightFont = *-regular , + BoldFont = *-bold , + ItalicFont = *-italic , + BoldItalicFont = *-bolditalic , + Extension = .otf , + Path = ../fonts/tex-gyre-termes/ , + Scale = 1.0] + + \setsansfont{OUCSans}[ + UprightFont = *-Regular , + BoldFont = *-Bold , + Extension = .otf , + Path = ../fonts/ouc-sans/ , + Scale = 1.0] +\fi + +\ifdefstring{\ELEGANT@lang}{cn}{ + \ifdefstring{\ELEGANT@chinesefont}{founder}{ + \RequirePackage[UTF8, scheme=plain, fontset=none]{ctex} + \setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01} + \setCJKsansfont[BoldFont={FZHei-B01}]{FZKai-Z03} + \setCJKmonofont[BoldFont={FZHei-B01}]{FZFangSong-Z02} + \setCJKfamilyfont{zhsong}{FZShuSong-Z01} + \setCJKfamilyfont{zhhei}{FZHei-B01} + \setCJKfamilyfont{zhkai}[BoldFont={FZHei-B01}]{FZKai-Z03} + \setCJKfamilyfont{zhfs}[BoldFont={FZHei-B01}]{FZFangSong-Z02} + \newcommand*{\songti}{\CJKfamily{zhsong}} + \newcommand*{\heiti}{\CJKfamily{zhhei}} + \newcommand*{\kaishu}{\CJKfamily{zhkai}} + \newcommand*{\fangsong}{\CJKfamily{zhfs}}}{\relax} + + \ifdefstring{\ELEGANT@chinesefont}{nofont}{ + \RequirePackage[UTF8,scheme=plain,fontset=none]{ctex} + \xeCJKsetup{AutoFakeBold=true} + }{\relax} + + \ifdefstring{\ELEGANT@chinesefont}{ctexfont}{ + \RequirePackage[UTF8,scheme=plain]{ctex} + \xeCJKsetup{AutoFakeBold=true} + }{\relax} + + \AfterEndPreamble{ + \setlength\parindent{2\ccwd}} +}{\relax} + +\ifcsname heiti\endcsname + \newcommand{\cbfseries}{\heiti} +\else + \newcommand{\cbfseries}{\bfseries} +\fi + + +\ifcsname kaishu\endcsname + \newcommand{\citshape}{\kaishu} +\else + \newcommand{\citshape}{\itshape} +\fi +\ifcsname kaishu\endcsname + \newcommand{\cnormal}{\kaishu} +\else + \newcommand{\cnormal}{\normalfont} +\fi + +\ifcsname fangsong\endcsname + \newcommand{\cfs}{\fangsong} +\else + \newcommand{\cfs}{\normalfont} +\fi + +\RequirePackage{anyfontsize} +\ifdefstring{\ELEGANT@math}{newtx}{ + \let\oldencodingdefault\encodingdefault + \let\oldrmdefault\rmdefault + \let\oldsfdefault\sfdefault + \let\oldttdefault\ttdefault + \def\encodingdefault{T1} + \renewcommand{\rmdefault}{ntxtlf} + \renewcommand{\sfdefault}{qhv} + \renewcommand{\ttdefault}{ntxtt} + \RequirePackage{newtxmath} + \let\encodingdefault\oldencodingdefault + \let\rmdefault\oldrmdefault + \let\sfdefault\oldsfdefault + \let\ttdefault\oldttdefault + \let\Bbbk\relax + \RequirePackage{esint} + %%% use yhmath pkg, uncomment following code + % \let\oldwidering\widering + % \let\widering\undefined + % \RequirePackage{yhmath} + % \let\widering\oldwidering + + %%% use esvect pkg, uncomment following code + % \RequirePackage{esvect} + + \DeclareSymbolFont{CMlargesymbols}{OMX}{cmex}{m}{n} + \let\sumop\relax\let\prodop\relax + \DeclareMathSymbol{\sumop}{\mathop}{CMlargesymbols}{"50} + \DeclareMathSymbol{\prodop}{\mathop}{CMlargesymbols}{"51} +}{\relax} + + +% ----- Handle Colors ----- +%% 章节以及页脚图形 + +\RequirePackage[table]{xcolor} +\ifdefstring{\ELEGANT@color}{green}{ + \definecolor{structurecolor}{RGB}{0,120,2}% + \definecolor{main}{RGB}{0,120,2}% + \definecolor{second}{RGB}{230,90,7}% + \definecolor{third}{RGB}{0,160,152}% +}{\relax} +\ifdefstring{\ELEGANT@color}{cyan}{ + \definecolor{structurecolor}{RGB}{31,186,190}% + \definecolor{main}{RGB}{59,180,5}% + \definecolor{second}{RGB}{175,153,8}% + \definecolor{third}{RGB}{244,105,102}% +}{\relax} +\ifdefstring{\ELEGANT@color}{blue}{ + \definecolor{structurecolor}{RGB}{60,113,183} + \definecolor{main}{RGB}{0,166,82}% + \definecolor{second}{RGB}{255,134,24}% + \definecolor{third}{RGB}{0,174,247}% +}{\relax} +\ifdefstring{\ELEGANT@color}{gray}{ + \definecolor{structurecolor}{RGB}{150,150,150} + \definecolor{main}{RGB}{150,150,150}% + \definecolor{second}{RGB}{150,150,150}% + \definecolor{third}{RGB}{150,150,150}% +}{\relax} +\ifdefstring{\ELEGANT@color}{black}{ + \definecolor{structurecolor}{RGB}{0,0,0} + \definecolor{main}{RGB}{0,0,0}% + \definecolor{second}{RGB}{0,0,0}% + \definecolor{third}{RGB}{0,0,0}% +}{\relax} + +%green color +\definecolor{structure1}{RGB}{0,120,2}% +\definecolor{main1}{RGB}{0,120,2}% +\definecolor{second1}{RGB}{230,90,7}% +\definecolor{third1}{RGB}{0,160,152}% +%cyan color +\definecolor{structure2}{RGB}{31,186,190}% +\definecolor{main2}{RGB}{59,180,5}% +\definecolor{second2}{RGB}{175,153,8}% +\definecolor{third2}{RGB}{244,105,102}% +%blue color +\definecolor{structure3}{RGB}{60,113,183} +\definecolor{main3}{RGB}{0,166,82}% +\definecolor{second3}{RGB}{255,134,24}% +\definecolor{third3}{RGB}{0,174,247}% +% gray color +\definecolor{structure4}{RGB}{150,150,150} +\definecolor{main4}{RGB}{150,150,150}% +\definecolor{second4}{RGB}{150,150,150}% +\definecolor{third4}{RGB}{150,150,150}% +% black color +\definecolor{structure5}{RGB}{0,0,0} +\definecolor{main5}{RGB}{0,0,0}% +\definecolor{second5}{RGB}{0,0,0}% +\definecolor{third5}{RGB}{0,0,0}% + +% corlor definition +\definecolor{winered}{rgb}{0.5,0,0} +\definecolor{bule}{RGB}{18,29,57} +\colorlet{coverlinecolor}{second} + + +% ----- Title Style ----- +\ifdefstring{\ELEGANT@titlestyle}{hang}{\def\style{hang}}{\relax} +\ifdefstring{\ELEGANT@titlestyle}{display}{\def\style{display}}{\relax} + +% reference: +% https://tex.stackexchange.com/questions/58506/how-to-make-a-new-command-similar-to-author +% https://pastebin.com/C8W4axzV +\newcommand\email[1]{\href{mailto:#1}{\nolinkurl{#1}}} + +\global\let\@title\@empty +\global\let\@author\@empty +\global\let\@date\@empty +\newcommand{\subtitle}[1]{\gdef\@subtitle{#1}} +\newcommand{\institute}[1]{\gdef\@institute{#1}} +\newcommand{\version}[1]{\gdef\@version{#1}} +\newcommand{\extrainfo}[1]{\gdef\@extrainfo{#1}} + +\RequirePackage{mwe} +\newcommand{\logo}[1]{\gdef\@logo{#1}} +\newcommand{\cover}[1]{\gdef\@cover{#1}} + +\newcommand{\question}[1]{{\par\citshape #1}\\[0.2ex]} + +\RequirePackage{enumerate} +% list/itemize/enumerate setting +\RequirePackage[shortlabels,inline]{enumitem} +\setlist{nolistsep} + +\RequirePackage[labelfont={bf,color=structurecolor}]{caption} +\captionsetup[table]{skip=3pt} +\captionsetup[figure]{skip=3pt} + +\AtBeginDocument{ + \setlength{\abovedisplayskip}{3pt} + \setlength{\belowdisplayskip}{3pt} + \RequirePackage[flushmargin,stable]{footmisc} + \setlength{\footnotesep}{12pt} +} + + + +\RequirePackage{graphicx} +%\RequirePackage{enumerate} +\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb} +% \providecommand\qed{} +% \renewcommand{\qed}{\hfill\ensuremath{\square}} +\RequirePackage{booktabs} +\RequirePackage{multicol,multirow} + +\RequirePackage{fancyvrb} +\RequirePackage{makecell,lipsum,hologo} +%%中文结构名字 + + +%% 章节设置 +\RequirePackage[center,pagestyles]{titlesec} +\RequirePackage[title,titletoc,header]{appendix} + + +\RequirePackage[ + backend=\ELEGANT@bibend, + citestyle=\ELEGANT@citestyle, + bibstyle=\ELEGANT@bibstyle]{biblatex} + +\ifdefstring{\ELEGANT@lang}{cn}{ + \renewcommand{\baselinestretch}{1.3} + \renewcommand{\contentsname}{目录} + \renewcommand{\figurename}{图} + \renewcommand{\tablename}{表} + \renewcommand{\partname}{\color{structurecolor}} + \renewcommand{\thepart}{第\zhnumber{\arabic{part}}部分} + \renewcommand{\listfigurename}{插图目录} + \renewcommand{\listtablename}{表格目录} + \renewcommand{\bibname}{参考文献} + \newcommand{\ebibname}{参考文献} + \renewcommand{\appendixname}{附录} + \renewcommand{\appendixtocname}{附录} + \renewcommand{\indexname}{索\hspace{2em}引} + \newcommand\figref[1]{\textbf{图}~\ref{#1}} + \newcommand\tabref[1]{\textbf{表}~\ref{#1}} + \newcommand{\authorname}{\citshape 作者:} + \newcommand{\institutename}{\citshape 组织:} + \newcommand{\datename}{\citshape 时间:} + \newcommand{\versionname}{\citshape 版本:} + \newcommand{\notename}{笔记} + \renewcommand*{\proofname}{证明} + \newcommand{\definitionname}{定义} + \newcommand{\theoremname}{定理} + \newcommand{\axiomname}{公理} + \newcommand{\postulatename}{公设} + \newcommand{\lemmaname}{引理} + \newcommand{\propositionname}{命题} + \newcommand{\corollaryname}{推论} + \newcommand{\examplename}{例题} % + \newcommand{\instancename}{示例} % + \newcommand{\problemname}{问题} % 问题 + \newcommand{\exercisename}{练习} % 练习=习题 + \newcommand{\remarkname}{注} + \newcommand{\assumptionname}{假设} + \newcommand{\conclusionname}{结论} + \newcommand{\solutionname}{解} + \newcommand{\propertyname}{性质} + \newcommand{\introductionname}{内容提要} + \newcommand\bioinfo[2]{\gdef\@bioinfo{{\citshape #1}:#2}} + \newcommand{\updatename}{更新:} + \newcommand{\historyname}{版本更新历史} + \newcommand{\beforechap}{第} + \newcommand{\afterchap}{章} +}{\relax} + + +\ifdefstring{\ELEGANT@lang}{en}{ + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Figure}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Table}~\ref{#1}} + \renewcommand{\chaptername}{Chapter} + \renewcommand{\partname}{\color{structurecolor} Part} + \newcommand{\authorname}{\textbf{Author: }} + \newcommand{\institutename}{\textbf{Institute: }} + \newcommand{\datename}{\textbf{Date: }} + \newcommand{\versionname}{\textbf{Version: }} + \newcommand{\notename}{Note} + \newcommand{\proofname}{Proof} + \newcommand{\problemname}{Problem} + \newcommand{\definitionname}{Definition} + \newcommand{\theoremname}{Theorem} + \newcommand{\axiomname}{Axiom} + \newcommand{\postulatename}{Postulate} + \newcommand{\lemmaname}{Lemma} + \newcommand{\propositionname}{Proposition} + \newcommand{\corollaryname}{Corollary} + \newcommand{\examplename}{Example} + \newcommand{\exercisename}{Exercise} + \newcommand{\remarkname}{Remark} + \newcommand{\assumptionname}{Assumption} + \newcommand{\conclusionname}{Conclusion} + \newcommand{\solutionname}{Solution} + \newcommand{\propertyname}{Property} + \newcommand{\introductionname}{Introduction} + \renewcommand{\appendixname}{Appendix} + \newcommand{\ebibname}{Bibliography} + % \newcommand{\problemsetname}{Exercise} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Updates:} + \newcommand{\historyname}{Version History} +}{\relax} + +\ifdefstring{\ELEGANT@lang}{it}{ + % \RequirePackage[utf8]{inputenc} + \RequirePackage[italian]{babel} + % \RequirePackage[T1]{fontenc} + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Figura}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Tabella}~\ref{#1}} + \renewcommand{\chaptername}{Chapter} + \newcommand{\authorname}{\textbf{Autore: }} + \newcommand{\institutename}{\textbf{Istituto: }} + \newcommand{\datename}{\textbf{Data: }} + \newcommand{\versionname}{\textbf{Versione: }} + \newcommand{\notename}{Nota} + \newcommand{\proofname}{Dimostrazione} + \newcommand{\problemname}{Problema} + \newcommand{\definitionname}{Definizione} + \newcommand{\theoremname}{Teorema} + \newcommand{\axiomname}{Assioma} + \newcommand{\postulatename}{Postulato} + \newcommand{\lemmaname}{Lemma} + \newcommand{\propositionname}{Proposizione} + \newcommand{\corollaryname}{Corollario} + \newcommand{\examplename}{Esempio} + \newcommand{\exercisename}{Esercizio} + \newcommand{\remarkname}{Commento} + \newcommand{\assumptionname}{Assunto} + \newcommand{\conclusionname}{Conclusione} + \newcommand{\solutionname}{Soluzione} + \newcommand{\propertyname}{Proprietà} + \newcommand{\introductionname}{Introduzione} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Aggiornamenti:} + \newcommand{\ebibname}{Bibliografia} + \newcommand{\historyname}{Cronologia delle versioni} +}{\relax} + +\ifdefstring{\ELEGANT@lang}{fr}{ + \RequirePackage[utf8]{inputenc} + \RequirePackage[T1]{fontenc} + \RequirePackage[french]{babel} + \setlength\parindent{2em} + \renewcommand\figref[1]{\textbf{Figure}\ref{#1}} + \renewcommand\tabref[1]{\textbf{Tableau}\ref{#1}} + \renewcommand{\chaptername}{Chapitre} + \renewcommand{\authorname}{\textbf{Auteur: }} + \renewcommand{\institutename}{\textbf{Institut: }} + \renewcommand{\datename}{\textbf{Date: }} + \renewcommand{\versionname}{\textbf{Version: }} + \renewcommand{\notename}{Note} + \renewcommand{\proofname}{Démonstration} + \renewcommand{\problemname}{Problème} + \renewcommand{\definitionname}{Définition} + \renewcommand{\theoremname}{Théorème} + \renewcommand{\axiomname}{Axiôme} + \renewcommand{\postulatename}{Postulat} + \renewcommand{\lemmaname}{Lemme} + \renewcommand{\propositionname}{Proposition} + \renewcommand{\corollaryname}{Corollaire} + \renewcommand{\examplename}{Exemple} + \renewcommand{\exercisename}{Exercice} + \renewcommand{\remarkname}{Remarque} + \renewcommand{\assumptionname}{Supposition} + \renewcommand{\conclusionname}{Conclusion} + \renewcommand{\solutionname}{Solution} + \renewcommand{\propertyname}{Propriété} + \renewcommand{\introductionname}{Introduction} + \renewcommand{\problemsetname}{Exercice} + \renewcommand{\updatename}{Mises à jour:} + \newcommand{\ebibname}{Bibliographie} + \renewcommand{\historyname}{Historique des versions} +}{\relax} + + +\ifdefstring{\ELEGANT@lang}{nl}{ + \RequirePackage[dutch]{babel} + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Figuur}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Tabel}~\ref{#1}} + \renewcommand{\chaptername}{Hoofdstuk} + \newcommand{\authorname}{\textbf{Auteur: }} + \newcommand{\institutename}{\textbf{Instituut: }} + \newcommand{\datename}{\textbf{Datum: }} + \newcommand{\versionname}{\textbf{Versie: }} + \newcommand{\notename}{Opmerking} + \newcommand{\proofname}{Bewijs} + \newcommand{\problemname}{Probleem} + \newcommand{\definitionname}{Definitie} + \newcommand{\theoremname}{Stelling} + \newcommand{\axiomname}{Uitgangspunt} + \newcommand{\postulatename}{Hypothese} + \newcommand{\lemmaname}{Lemma} + \newcommand{\propositionname}{Voorstel} + \newcommand{\corollaryname}{Gevolgtrekking} + \newcommand{\examplename}{Voorbeeld} + \newcommand{\exercisename}{Oefening} + \newcommand{\remarkname}{Commentaar} + \newcommand{\assumptionname}{Veronderstelling} + \newcommand{\conclusionname}{Besluit} + \newcommand{\solutionname}{Oplossing} + \newcommand{\propertyname}{Eigenschap} + \newcommand{\introductionname}{Introductie} + \newcommand{\problemsetname}{Probleemcomplex} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Update:} + \newcommand{\ebibname}{Bibliographie} + \newcommand{\historyname}{Versie Geschiedenis} +}{\relax} + + +\ifdefstring{\ELEGANT@lang}{hu}{ + \RequirePackage[magyar]{babel} + \setlength\parindent{2em} + \newcommand\figref[1]{\ref{#1}~\textbf{Ábra}} + \newcommand\tabref[1]{\ref{#1}~\textbf{Táblázat}} + \renewcommand{\chaptername}{Fejezet} + \newcommand{\authorname}{\textbf{Szerző: }} + \newcommand{\institutename}{\textbf{Intézmény: }} + \newcommand{\datename}{\textbf{Dátum: }} + \newcommand{\versionname}{\textbf{Verziószám: }} + \newcommand{\notename}{Jegyzet} + \newcommand{\proofname}{Bizonyítás} + \newcommand{\problemname}{Probléma} + \newcommand{\definitionname}{Definíció} + \newcommand{\theoremname}{Tétel} + \newcommand{\axiomname}{Axióma} + \newcommand{\postulatename}{Követelmény} + \newcommand{\lemmaname}{Lemma} + \newcommand{\propositionname}{Előzmény} + \newcommand{\corollaryname}{Következmény} + \newcommand{\examplename}{Példa} + \newcommand{\exercisename}{Feladat} + \newcommand{\remarkname}{Megjegyzés} + \newcommand{\assumptionname}{Sejtés} + \newcommand{\conclusionname}{Összefoglalás} + \newcommand{\solutionname}{Megoldás} + \newcommand{\propertyname}{Tulajdonság} + \newcommand{\introductionname}{Bevezetés} + \newcommand{\problemsetname}{Feladatok} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Frissítve:} + \newcommand{\ebibname}{Bibliográfia} + \newcommand{\historyname}{Korábbi verziók} +}{\relax} + +\ifdefstring{\ELEGANT@lang}{de}{ + \setlength\parindent{2em} + \renewcommand{\contentsname}{Inhaltsverzeichnis} + \newcommand\figref[1]{\textbf{Figur}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Tabelle}~\ref{#1}} + \renewcommand{\partname}{\color{structurecolor} Teil} + \renewcommand{\listfigurename}{Abbildungsverzeichnis} + \renewcommand{\listtablename}{Tabellenverzeichnis} + \renewcommand{\bibname}{Bibliographie} + \renewcommand{\appendixname}{Anhang} + \renewcommand{\chaptername}{Kapitel} + \newcommand{\authorname}{\textbf{Autor: }} + \newcommand{\institutename}{\textbf{Institut: }} + \newcommand{\datename}{\textbf{Datum: }} + \newcommand{\versionname}{\textbf{Version: }} + \newcommand{\notename}{Notiz} + \newcommand{\proofname}{Beweis} + \newcommand{\problemname}{Problem} + \newcommand{\definitionname}{Definition} + \newcommand{\theoremname}{Theorem} + \newcommand{\axiomname}{Axiom} + \newcommand{\postulatename}{Postulat} + \newcommand{\lemmaname}{Lemma} + \newcommand{\propositionname}{Behauptung} + \newcommand{\corollaryname}{Corollary} + \newcommand{\examplename}{Beispiel} + \newcommand{\instancename}{Beispiel} % + \newcommand{\exercisename}{\"{U}bung} + \newcommand{\remarkname}{Anmerkung} + \newcommand{\assumptionname}{Annahme} + \newcommand{\conclusionname}{Abschluss} + \newcommand{\solutionname}{Aufl\"{o}sung} + \newcommand{\propertyname}{Property} + \newcommand{\introductionname}{Einleitung} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Updates:} + \renewcommand{\ebibname}{Bibliographie} + \newcommand{\historyname}{Version der Geschichte} +}{\relax} + +\ifdefstring{\ELEGANT@lang}{es}{ + \RequirePackage[spanish]{babel} + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Figura}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Tabla}~\ref{#1}} + \renewcommand{\spanishchaptername}{Capítulo} + \newcommand{\authorname}{\textbf{Autor: }} + \newcommand{\institutename}{\textbf{Instituto: }} + \newcommand{\datename}{\textbf{Fecha: }} + \newcommand{\versionname}{\textbf{Versión: }} + \newcommand{\notename}{Nota} + \newcommand{\proofname}{Demostración} + \newcommand{\problemname}{Problema} + \newcommand{\definitionname}{Definición} + \newcommand{\theoremname}{Teorema} + \newcommand{\axiomname}{Axioma} + \newcommand{\postulatename}{Postulado} + \newcommand{\lemmaname}{Lema} + \newcommand{\propositionname}{Proposición} + \newcommand{\corollaryname}{Corolario} + \newcommand{\examplename}{Ejemplo} + \newcommand{\exercisename}{Ejercicio} + \newcommand{\remarkname}{Comentario} + \newcommand{\assumptionname}{Asunto} + \newcommand{\conclusionname}{Conclusión} + \newcommand{\solutionname}{Solución} + \newcommand{\propertyname}{Propiedad} + \newcommand{\introductionname}{Introducción} + \newcommand{\problemsetname}{Ejercicio} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Actualización:} + \newcommand{\ebibname}{Bibliografía} + \newcommand{\historyname}{Historial de versiones} +}{\relax} + +\ifdefstring{\ELEGANT@lang}{mn}{ + \RequirePackage[mongolian]{babel} + \RequirePackage[utf8]{inputenc} + \RequirePackage[T2A]{fontenc} + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Зураг}\ref{#1}} + \newcommand\tabref[1]{\textbf{Хүснэгт}\ref{#1}} + \renewcommand{\chaptername}{Бүлэг} + \newcommand{\authorname}{\textbf{Зохиогч: }} + \newcommand{\institutename}{\textbf{Сургууль: }} + \newcommand{\datename}{\textbf{Огноо: }} + \newcommand{\versionname}{\textbf{Хувилбар: }} + \newcommand{\notename}{Тэмдэглэл} + \newcommand{\proofname}{Баталгаа} + \newcommand{\problemname}{Бодлого} + \newcommand{\definitionname}{Тодорхойлолт} + \newcommand{\theoremname}{Томьёо} + \newcommand{\axiomname}{Аксиом} + \newcommand{\postulatename}{Постулат} + \newcommand{\lemmaname}{Лемма} + \newcommand{\propositionname}{Таамаглал} + \newcommand{\corollaryname}{Үр дүн} + \newcommand{\examplename}{Жишээ} + \newcommand{\exercisename}{Дасгал} + \newcommand{\remarkname}{Тайлбар} + \newcommand{\assumptionname}{Урьдчилсан нөхцөл} + \newcommand{\conclusionname}{Дүгнэлт} + \newcommand{\solutionname}{Хариулт} + \newcommand{\propertyname}{Шинж чанар} + \newcommand{\introductionname}{Удиртгал} + \newcommand{\problemsetname}{Бодлогууд} + \newcommand\bioinfo[2]{\gdef@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Шинэчлэлтүүд:} + \newcommand{\ebibname}{Ном зүй} + \newcommand{\historyname}{Хувилбарын түүх} +}{\relax} + + +\ifdefstring{\ELEGANT@lang}{pt}{ + \RequirePackage[portuguese]{babel} + \setlength\parindent{2em} + \newcommand\figref[1]{\textbf{Figura}~\ref{#1}} + \newcommand\tabref[1]{\textbf{Tabela}~\ref{#1}} + \renewcommand{\chaptername}{Capítulo} + \newcommand{\authorname}{\textbf{Autor: }} + \newcommand{\institutename}{\textbf{Instituição: }} + \newcommand{\datename}{\textbf{Data: }} + \newcommand{\versionname}{\textbf{Versão: }} + \newcommand{\notename}{Observação} + \newcommand{\proofname}{Demostração} + \newcommand{\problemname}{Problema} + \newcommand{\definitionname}{Definição} + \newcommand{\theoremname}{Teorema} + \newcommand{\axiomname}{Axioma} + \newcommand{\postulatename}{Postulado} + \newcommand{\lemmaname}{Lema} + \newcommand{\propositionname}{Proposição} + \newcommand{\corollaryname}{Corolário} + \newcommand{\examplename}{Exemplo} + \newcommand{\exercisename}{Exercício} + \newcommand{\remarkname}{Comentário} + \newcommand{\assumptionname}{Assunto} + \newcommand{\conclusionname}{Conclusão} + \newcommand{\solutionname}{Soluções} + \newcommand{\propertyname}{Propiedade} + \newcommand{\introductionname}{Introdução} + \newcommand{\problemsetname}{Questão} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{Atualização: } + \newcommand{\ebibname}{Bibliografia} + \newcommand{\historyname}{Histórico de versões} +}{\relax} + + +\ifdefstring{\ELEGANT@lang}{jp}{ + \RequirePackage{luatexja} + \setlength\parindent{2em} + \renewcommand{\contentsname}{目次} + \newcommand\figref[1]{\textbf{図}~\ref{#1}} + \newcommand\tabref[1]{\textbf{表}~\ref{#1}} + \renewcommand{\partname}{\color{structurecolor}} + \renewcommand{\listfigurename}{イラストカタログ} + \renewcommand{\listtablename}{表カタログ} + \renewcommand{\bibname}{参考文献} + \renewcommand{\appendixname}{付録} + \renewcommand{\chaptername}{第 \thechapter 章} + \newcommand{\authorname}{\textbf{著者:}} + \newcommand{\institutename}{\textbf{組織団体:}} + \newcommand{\datename}{\textbf{日付:}} + \newcommand{\versionname}{\textbf{\citshape バージョン:}} + \newcommand{\notename}{ノート} + \newcommand{\proofname}{証明} + \newcommand{\problemname}{問題} + \newcommand{\definitionname}{定義} + \newcommand{\theoremname}{定理} + \newcommand{\axiomname}{公理} + \newcommand{\postulatename}{公準} + \newcommand{\lemmaname}{補題} + \newcommand{\propositionname}{命題} + \newcommand{\corollaryname}{系} + \newcommand{\examplename}{例題} + \newcommand{\instancename}{例} + \newcommand{\exercisename}{練習} + \newcommand{\remarkname}{注} + \newcommand{\assumptionname}{仮設} + \newcommand{\conclusionname}{結論} + \newcommand{\solutionname}{解答} + \newcommand{\propertyname}{性質} + \newcommand{\introductionname}{内容概要} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} + \newcommand{\updatename}{更新:} + \newcommand{\ebibname}{参考文献} + \newcommand{\historyname}{バージョン更新履歴} +}{\relax} + + +\graphicspath{{./figure/}{./figures/}{./image/}{./images/}{./graphics/}{./graphic/}{./pictures/}{./picture/}} + +\RequirePackage{tikz} %% load tikz without tikz +\usetikzlibrary{backgrounds,calc,shadows,positioning,fit} +\newcommand*\circled[1]{\tikz[baseline=(char.base)]{ + \node[shape=circle,draw,inner sep=1pt] (char) {#1};}} +% https://tex.stackexchange.com/questions/7032/good-way-to-make-textcircled-numbers + +\newcommand*{\eitemi}{\tikz \draw [baseline, ball color=structurecolor,draw=none] circle (2pt);} +\newcommand*{\eitemii}{\tikz \draw [baseline, fill=structurecolor,draw=none,circular drop shadow] circle (2pt);} +\newcommand*{\eitemiii}{\tikz \draw [baseline, fill=structurecolor,draw=none] circle (2pt);} +\setlist[enumerate,1]{label=\color{structurecolor}\arabic*.} +\setlist[enumerate,2]{label=\color{structurecolor}(\alph*).} +\setlist[enumerate,3]{label=\color{structurecolor}\Roman*.} +\setlist[enumerate,4]{label=\color{structurecolor}\Alph*.} +\setlist[itemize,1]{label={\eitemi}} +\setlist[itemize,2]{label={\eitemii}} +\setlist[itemize,3]{label={\eitemiii}} + +\RequirePackage{apptools} + +% appendix chapter: + +\ifdefstring{\ELEGANT@lang}{cn}{ + \ifdefstring{\ELEGANT@scheme}{chinese}{ + \newcommand{\xchaptertitle}{第\zhnumber{\arabic{chapter}}章} }{ + \newcommand{\xchaptertitle}{第 \thechapter{} 章}} +% Hyperref 2022/05/16's changelog.txt said +% * nameref is loaded always and earlier (issue#235) + \AtBeginDocument{ + \ifELEGANT@Hy@later + \patchcmd{\NR@chapter}% + {\numberline{\thechapter}}{\numberline{\xchaptertitle}}% + {}{\fail} + \else + \patchcmd{\Hy@org@chapter}% + {\numberline{\thechapter}}{\numberline{\xchaptertitle}}% + {}{\fail} + \fi + } + } + {\newcommand{\xchaptertitle}{\chaptername~\thechapter~}} + +\setcounter{secnumdepth}{5} +\titleformat{\chapter}[\style]{\bfseries}{ + \filcenter\LARGE\enspace\bfseries{\color{structurecolor} \IfAppendix{\appendixname\;\thechapter\;}{\xchaptertitle\;}}}{1pt}{ + \LARGE\bfseries\color{structurecolor}\filcenter}[] +\titleformat{\section}[hang]{\bfseries}{ + \Large\bfseries{\color{structurecolor}\thesection}\enspace}{1pt}{% + \color{structurecolor}\Large\bfseries\filright} +\titleformat{\subsection}[hang]{\bfseries}{ + \large\bfseries\color{structurecolor}\thesubsection\enspace}{1pt}{% + \color{structurecolor}\large\bfseries\filright} +\titleformat{\subsubsection}[hang]{\bfseries}{ + \large\bfseries\color{structurecolor}\thesubsubsection\enspace}{1pt}{% + \color{structurecolor}\large\bfseries\filright} + +\titlespacing{\chapter}{0pt}{-20pt}{1.3\baselineskip} +%\titlespacing{\subsection}{0pt}{0.5\baselineskip}{-\baselineskip} + + + +%%define the +%%definition theorem postulate axiom corollary lemma proposition +%%and proof environment +\RequirePackage{pifont,manfnt,bbding} +\RequirePackage[many]{tcolorbox} +% \newlength{\normalparindent} +% \setlength{\normalparindent}{\parindent} +\newcommand{\ELEGANT@tmp@tl}{} +\ifELEGANT@usesamecnt + \newcounter{ELEGANT@samecnt} + \counterwithin{ELEGANT@samecnt}{\ELEGANT@thmcnt} + \tcbset{ + new/usesamecnt/.style = {use counter = ELEGANT@samecnt} + } +\else + \tcbset{ + new/usesamecnt/.style = {} + } +\fi + +\ifdefstring{\ELEGANT@mode}{fancy}{ + \tcbset{ + common/.style={ + fontupper=\citshape, + lower separated=false, + % before upper={\setlength{\parindent}{\normalparindent}}, + coltitle=white, + colback=gray!5, + boxrule=0.5pt, + fonttitle=\bfseries, + enhanced, + breakable, + top=8pt, + before skip=8pt, + attach boxed title to top left={ + yshift=-0.11in, + xshift=0.15in}, + boxed title style={ + boxrule=0pt, + colframe=white, + arc=0pt, + outer arc=0pt}, + separator sign={.},}, + defstyle/.style={ + common, + colframe=main, + colback=main!5, + colbacktitle=main, + overlay unbroken and last={ + \node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) { + \textcolor{main}{$\clubsuit$}};}}, + thmstyle/.style={ + common, + colframe=second, + colback=second!5, + colbacktitle=second, + overlay unbroken and last={ + \node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) { + \textcolor{second}{$\heartsuit$}};}}, + prostyle/.style={ + common, + colframe=third, + colback=third!5, + colbacktitle=third, + overlay unbroken and last={ + \node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) { + \textcolor{third}{$\spadesuit$}};}}, + ELEGANT@title/.code n args={2} + { + + \tcbset + { + title= + { + \csname #1name\endcsname~% + \ifdef{\thetcbcounter}{\thetcbcounter}{}% + \ifblank{#2}{}{\ (#2)} + } + } + }, + ELEGANT@label/.code n args={2} + { + \ifblank{#2} + {}{\tcbset{label={#1:#2}}} + } + } + + % define an internal control sequence \ELEGANT@newtheorem for fancy mode's newtheorem + % #1 is the environment name, #2 is the prefix of label, #3 is the style + % style: thmstyle, defstyle, prostyle + % e.g. \ELEGANT@newtheorem{theorem}{thm}{thmstyle} + % will define two environments: numbered ``theorem'' and no-numbered ``theorem*'' + % WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition, + % WARNING FOR MULTILINGUAL: it should be defined in language settings. + \NewDocumentCommand \ELEGANT@newtheorem { m m m O{} }{ + \ifcsundef{#1name}{% + \ClassError{elegantbook}{% + \ #1name undefined, \MessageBreak + Please check in language setting + }{} + }{\relax} + \expandafter\ifblank\expandafter{#4}{ + \tcbset{ + new/usecnt/.style={} + } + }{ + \tcbset{ + new/usecnt/.style= {use counter from = #4} + } + } + \DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt,usesamecnt,usecnt]{#1}{ g o t\label g }{ + common,#3, + IfValueTF={##1} + {ELEGANT@title={#1}{##1}} + { + IfValueTF={##2} + {ELEGANT@title={#1}{##2}} + {ELEGANT@title={#1}{}} + }, + IfValueT={##4} + { + IfBooleanTF={##3} + {label={##4}} + {ELEGANT@label={#2}{##4}} + } + } + \DeclareTColorBox{#1*}{ g o }{ + common,#3, + IfValueTF={##1} + {ELEGANT@title={#1}{##1}} + { + IfValueTF={##2} + {ELEGANT@title={#1}{##2}} + {ELEGANT@title={#1}{}} + }, + } + } + % define several environment + % we define headers like \definitionname before + \ELEGANT@newtheorem{theorem}{thm}{thmstyle} + \ELEGANT@newtheorem{definition}{def}{defstyle} + \ELEGANT@newtheorem{postulate}{pos}{thmstyle} + \ELEGANT@newtheorem{axiom}{axi}{thmstyle} + \ELEGANT@newtheorem{corollary}{cor}{thmstyle} + \ELEGANT@newtheorem{lemma}{lem}{thmstyle} + \ELEGANT@newtheorem{proposition}{pro}{prostyle} +}{\relax} + + +\ifdefstring{\ELEGANT@mode}{simple}{ + \let\openbox\relax + \RequirePackage{amsthm} + \let\proof\relax + % \let\proofname\relax + \let\endproof\relax + + % declare new theorem styles: defstyle, thmstyle, prostyle + \newtheoremstyle{defstyle}{3pt}{3pt}{\citshape}{-3pt}{ + \bfseries\color{main}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} + \newtheoremstyle{thmstyle}{3pt}{3pt}{\citshape}{-3pt}{ + \bfseries\color{second}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} + \newtheoremstyle{prostyle}{3pt}{3pt}{\citshape}{-3pt}{ + \bfseries\color{third}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} + + % define an internal control sequence \ELEGANT@newtheorem for simple mode's newtheorem + % #1 is the environment name, #2 is the style + % style: thmstyle, defstyle, prostyle + % e.g. \ELEGANT@newtheorem{theorem}{thmstyle} + % will define two environments: numbered ``theorem'' and no-numbered ``theorem*'' + % WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition, + % WARNING FOR MULTILINGUAL: it should be defined in language settings. + \NewDocumentCommand \ELEGANT@newtheorem { m m O{} } { + \theoremstyle{#2} + \ifELEGANT@usesamecnt + \newtheorem{#1}[ELEGANT@samecnt]{\csname #1name\endcsname} + \else + \ifblank{#3}{ + \newtheorem{#1}{\csname #1name\endcsname}[\ELEGANT@thmcnt] + }{ + \newtheorem{#1}[#3]{\csname #1name\endcsname} + } + \fi + \newtheorem*{#1*}{\csname #1name\endcsname} + } + + % define several environment + % we define headers like \definitionname before + \ELEGANT@newtheorem{theorem}{thmstyle} + \ELEGANT@newtheorem{definition}{defstyle} + \ELEGANT@newtheorem{postulate}{thmstyle} + \ELEGANT@newtheorem{axiom}{thmstyle} + \ELEGANT@newtheorem{corollary}{thmstyle} + \ELEGANT@newtheorem{lemma}{thmstyle} + \ELEGANT@newtheorem{proposition}{prostyle} +}{\relax} + +% define an user control sequence \elegantnewtheorem +% #1 is the evironment, #2 is the theorem header +% #3 is the style #4 is the prefix for fancy mode +% style: thmstyle, defstyle, prostyle +% if #4 is given in simple mode, an error will be raised +% if #4 isn't given in fancy mode, the prefix will be set equal to #1, +% and a warning will be raised +\newcommand{\ELEGANT@newtheorem@warning}{} +\newcommand{\ELEGANT@newtheorem@error}{} +\newcommand{\ELEGANT@usesamecnt@warning}{} +\NewDocumentCommand\elegantnewtheorem{ m m m g O{} } + { + \renewcommand{\ELEGANT@usesamecnt@warning}{ + \ClassWarning{elegantbook}{% + [#5] won't make sence with option \MessageBreak + `usesamecnt'. + } + } + \renewcommand{\ELEGANT@newtheorem@warning}{ + \ClassWarning{elegantbook}{% + Because you didn't provide a prefix, \MessageBreak + we use #1 as the default prefix. \MessageBreak + You have to use \MessageBreak + \ref{#1:label} to refer a \MessageBreak + \begin{#1}{name}{label} environment. \MessageBreak + } + } + \renewcommand{\ELEGANT@newtheorem@error}{ + \ClassError{elegantbook}{% + You can't set a prefix in mode ``simple''.\MessageBreak + Just use \MessageBreak + \elegantnewtheorem{#1}{#2}{#3} + }{% + We are using ``amsthm'' package to \MessageBreak + generate theorem-like theorem. \MessageBreak + The 4th parameter ``prefix'' isn't allowed. + } + } + \ifELEGANT@usesamecnt + \ifblank{#5}{}{\ELEGANT@usesamecnt@warning} + \else + \renewcommand{\ELEGANT@tmp@tl}{#5} + \fi + \expandafter\def\csname #1name\endcsname{#2} + \ifdefstring{\ELEGANT@mode}{simple}{% + \IfValueTF{#4} + {\ELEGANT@newtheorem@error} + {\ELEGANT@newtheorem{#1}{#3}[\ELEGANT@tmp@tl]} + }{\relax} + \ifdefstring{\ELEGANT@mode}{fancy}{% + \IfValueTF{#4} + { + \def\ELEGANT@temp@prefix{#4} + \ifdefempty{\ELEGANT@temp@prefix} + { + \ELEGANT@newtheorem{#1}{#1}{#3}[\ELEGANT@tmp@tl] + \ELEGANT@newtheorem@warning + } + {\ELEGANT@newtheorem{#1}{#4}{#3}[\ELEGANT@tmp@tl]} + } + { + \ELEGANT@newtheorem{#1}{#1}{#3}[\ELEGANT@tmp@tl] + \ELEGANT@newtheorem@warning + } + }{\relax} + } + +% main(green-def): example exercise problem solution +% second(orange-thm): proof note remark +% third(blue-prop): assumptions property conclusion custom + +%% Example with counter +\newcounter{exam}[chapter] +\setcounter{exam}{0} +\renewcommand{\theexam}{\thechapter.\arabic{exam}} +\newenvironment{example}[1][]{ + \refstepcounter{exam} + \par\noindent\textbf{\color{main}{\examplename} \theexam #1 }\rmfamily}{ + \par\ignorespacesafterend} + +%% Exercise with counter +\newcounter{exer}[chapter] +\setcounter{exer}{0} +\renewcommand{\theexer}{\thechapter.\arabic{exer}} +\newenvironment{exercise}[1][]{ + \refstepcounter{exer} + \par\noindent\makebox[-3pt][r]{ + \scriptsize\color{red!90}\HandPencilLeft\quad} + \textbf{\color{main}{\exercisename} \theexer #1 }\rmfamily}{ + \par\ignorespacesafterend} + +%% Problem with counter +\newcounter{prob}[chapter] +\setcounter{prob}{0} +\renewcommand{\theprob}{\thechapter.\arabic{prob}} +\newenvironment{problem}[1][]{ + \refstepcounter{prob} + \par\noindent\textbf{\color{main}{\problemname} \theprob #1 }\rmfamily}{ + \par\ignorespacesafterend} + +\newenvironment{note}{ + \par\noindent\makebox[-3pt][r]{ + \scriptsize\color{red!90}\textdbend\quad} + \textbf{\color{second}\notename} \citshape}{\par} + +\newenvironment{proof}{ + \par\noindent\textbf{\color{second}\proofname\;} + \color{black!90}\cfs}{ + % \hfill$\Box$\quad + \par} + +\newenvironment{solution}{\par\noindent\textbf{\color{main}\solutionname} \citshape}{\par} +\newenvironment{remark}{\noindent\textbf{\color{second}\remarkname}}{\par} +\newenvironment{assumption}{\par\noindent\textbf{\color{third}\assumptionname} \citshape}{\par} +\newenvironment{conclusion}{\par\noindent\textbf{\color{third}\conclusionname} \citshape}{\par} +\newenvironment{property}{\par\noindent\textbf{\color{third}\propertyname} \citshape}{\par} +\newenvironment{custom}[1]{\par\noindent\textbf{\color{third} #1} \citshape}{\par} + +\RequirePackage{multicol} +\tcbset{ + introductionsty/.style={ + enhanced, + breakable, + colback=structurecolor!10, + colframe=structurecolor, + fonttitle=\bfseries, + colbacktitle=structurecolor, + fontupper=\citshape, + attach boxed title to top center={yshift=-3mm,yshifttext=-1mm}, + boxrule=0pt, + toprule=0.5pt, + bottomrule=0.5pt, + top=8pt, + before skip=8pt, + sharp corners + }, +} + + +\newenvironment{introduction}[1][\introductionname]{ + \begin{tcolorbox}[introductionsty,title={#1}] + \begin{multicols}{2} + \begin{itemize}[label=\textcolor{structurecolor}{\upshape\scriptsize\SquareShadowBottomRight}]}{ + \end{itemize} + \end{multicols} + \end{tcolorbox}} + +\RequirePackage{adforn} + +\newenvironment{problemset}[1][\xchaptertitle~\exercisename]{ + \vspace*{10pt} + \begin{center} + \phantomsection\addcontentsline{toc}{section}{\texorpdfstring{\xchaptertitle~\exercisename}{\exercisename}} + % \markboth{#1}{\rightmark} + \markright{#1} + \textcolor{structurecolor}{\Large\bfseries\adftripleflourishleft~#1~\adftripleflourishright} + \end{center} + \begin{enumerate}}{ + \end{enumerate}} + +\def\relsec{\endgroup start} +\def\endrelsec{end\begingroup\def \@currenvir {relsec}} + +\ifdefstring{\ELEGANT@result}{noanswer}{ + \AtBeginDocument{ + \excludecomment{solution} + \excludecomment{proof} + \excludecomment{inline} + } +}{\relax} + + +%页眉页脚 +\RequirePackage{fancyhdr} +\fancyhf{} + + +\fancyfoot[c]{\color{structurecolor}\small\thepage} +\if@twoside + \fancyhead[EL]{\color{structurecolor}\cnormal\leftmark} + \fancyhead[OR]{\color{structurecolor}\cnormal\rightmark} +\else + \fancyhead[R]{\color{structurecolor}\cnormal\rightmark} +\fi + +\renewcommand{\headrule}{\color{structurecolor}\hrule width\textwidth} +\pagestyle{fancy} +\renewcommand{\headrulewidth}{1pt} +% \renewcommand{\headrule}{} +\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}\fancyhf{}\renewcommand{\headrule}{}} +\renewcommand{\sectionmark}[1]{\markright{\thesection\, #1}{}} +\renewcommand{\chaptermark}[1]{\markboth{\xchaptertitle\, #1}{}} + + +\newcommand{\ouc@coverblank}{\rule{0pt}{0pt}\hspace{\linewidth}\rule{0pt}{0pt}} +\renewcommand*{\maketitle}{% +\hypersetup{pageanchor=false} +\pagenumbering{Alph} +\begin{titlepage} + \newgeometry{margin = 0in} + \parindent=0pt + \ifdefstring{\ELEGANT@device}{normal}{ + \ifcsname @cover\endcsname + \includegraphics[width=\linewidth]{\@cover} + \else + \ouc@coverblank + \fi + }{\relax} + \ifdefstring{\ELEGANT@device}{pad}{ + \ifcsname @cover\endcsname + \includegraphics[trim=0 26bp 0 26bp,clip=true, width=\linewidth]{\@cover} + \else + \ouc@coverblank + \fi + }{\relax} + \setlength{\fboxsep}{0pt} + % 本地化:色带宽度用 \hsize 而不是 \linewidth。 + % \newgeometry{margin=0in} 之后 \linewidth 的更新时机与 \makebox 的 + % 宽度计算有时序差,导致实测 Overfull 5pt(原版有封面图时被图宽度 + % 掩盖,换成占位空盒后暴露出来)。 + \colorbox{coverlinecolor}{\makebox[\linewidth][c]{\shortstack[c]{\vspace{0.5in}}}} + \vfill + \vskip-2ex + \hspace{2em} + \parbox{0.8\textwidth}{ + \bfseries\Huge + \ifcsname @title\endcsname \@title \fi + \par} + \vfill + \vspace{-1.0cm} + \setstretch{2.5} + \hspace{2.5em} + \begin{minipage}[c]{0.67\textwidth} + {\color{darkgray}\bfseries\Large + \ifcsname @subtitle\endcsname\@subtitle\\[2ex]\fi} + \color{gray}\normalsize + {\renewcommand{\arraystretch}{0.618} + \begin{tabular}{l} + % \ifcsname @author\endcsname \authorname \@author\\\fi + \ifx\@author\empty\else\authorname\cnormal\@author\\ \fi + \ifcsname @institute\endcsname \institutename \cnormal\@institute\\ \fi + % \ifcsname @date\endcsname \@date\\\fi + \ifx\@date\empty\else\datename\cnormal\@date \\ \fi + \ifcsname @version\endcsname \cnormal\versionname\@version\\ \fi + \ifcsname @bioinfo\endcsname \cnormal\@bioinfo\\ \fi + \end{tabular}} + \end{minipage} + \begin{minipage}[c]{0.27\textwidth} + \begin{tikzpicture}[remember picture,overlay] + \begin{pgfonlayer}{background} + \node[opacity=0.8, + anchor=south east, + outer sep=0pt, + inner sep=0pt] at ($(current page.south east) +(-0.8in,1.5in)$) { + \ifcsname @logo\endcsname\includegraphics[width=4.2cm]{\@logo}\fi}; + \end{pgfonlayer} + \end{tikzpicture} + \end{minipage} + \vfill + \begin{center} + \setstretch{1.3} + \parbox[t]{0.7\textwidth}{\centering \citshape + \ifcsname @extrainfo\endcsname\@extrainfo\fi} + \end{center} + \vfill +\end{titlepage} +\restoregeometry +\thispagestyle{empty}} + + +\newcommand{\dollar}{\mbox{\textdollar}} + +\RequirePackage{listings} +\renewcommand{\ttdefault}{cmtt} +\lstdefinestyle{mystyle}{ + basicstyle=% + \ttfamily + \lst@ifdisplaystyle\small\fi +} + +\lstset{basicstyle=\ttfamily,style=mystyle,breaklines=true} + +\definecolor{lightgrey}{rgb}{0.9,0.9,0.9} +\definecolor{frenchplum}{RGB}{190,20,83} +\lstset{language=[LaTeX]TeX, + texcsstyle=*\color{winered}, + numbers=none, + mathescape=false, + breaklines=true, + keywordstyle=\color{winered}, + commentstyle=\color{gray}, + emph={elegantpaper,fontenc,fontspec,xeCJK,citestyle,FiraMono,xunicode,figure,fig,image,img,table,itemize,enumerate,ctex,microtype,description,times,booktabs,tabular,PDFLaTeX,XeLaTeX,type1cm,BibTeX,device,color,mode,lang,amsthm,tcolorbox,titlestyle,cite,ctex,listings,base,math,scheme,toc,esint,chinesefont,amsmath,bibstyle,natbib,pgfornament,addbibresource,printbibliography}, + emphstyle={\color{frenchplum}}, + morekeywords={DeclareSymbolFont,SetSymbolFont,toprule,midrule,bottomrule,institute,version,includegraphics,setmainfont,setsansfont,setmonofont ,setCJKmainfont,setCJKsansfont,setCJKmonofont,RequirePackage,figref,tabref,email,maketitle,keywords,definecolor,extrainfo,logo,cover,subtitle,appendix,chapter,section,hypersetup,mainmatter,frontmatter,tableofcontents,elegantpar,heiti,kaishu,lstset,pagecolor,zhnumber,marginpar,part,equote,marginnote,bioinfo,datechange,listofchange,lvert,lastpage,songti,heiti,fangsong,setCJKfamilyfont,textbf,elegantnewtheorem,thmcnt,colorlet,usesamecnt}, + frame=single, + tabsize=2, + rulecolor=\color{structurecolor}, + framerule=0.2pt, + columns=flexible, + % backgroundcolor=\color{lightgrey} +} + +\newcommand\bmmax{0} +\RequirePackage{bm} + +% add the list of change history +\newcommand{\dateinfoline}[2]{ + \noindent\makebox[0pt][r]{% + \makebox[-3em][r]{% + \small + \textbf{\textcolor{structurecolor}{#1}}}\;\;}% + {\citshape\updatename\ignorespaces#2}} + +\newcommand{\datechange}[2]{% + \noindent{\makebox[\textwidth][r]{\color{structurecolor}\rule{1.15\textwidth}{.4pt}}} + \dateinfoline{#1}{#2} + \addcontentsline{dates}{section}{#1 -- #2}} + +\newcommand{\listofchanges}{% + \begingroup + \renewcommand{\contentsname}{\historyname} + \let\old@starttoc\@starttoc + \def\@starttoc##1{ + \old@starttoc{dates}} + \tableofcontents% + \endgroup} +% https://tex.stackexchange.com/questions/472931/list-of-all-dates-in-a-document + +\newenvironment{change}{ + \begin{enumerate}[label=\small\protect\circled{\arabic*}]}{ + \end{enumerate}} + + + +\renewcommand\tableofcontents{% + \hypersetup{linktoc=all, linkcolor=black} + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \ifdefstring{\ELEGANT@toc}{twocol}{ + \setlength{\columnsep}{2em} + \begin{multicols}{2}% + \@starttoc{toc} + \end{multicols}}{ + \@starttoc{toc}} + \if@restonecol\twocolumn\fi + \hypersetup{linkcolor=winered}} + + +\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else +\hbox{}% +\thispagestyle{empty}% +\newpage% +\if@twocolumn\hbox{}\newpage\fi\fi\fi} + + +% https://tex.stackexchange.com/questions/56839/chaptername-is-used-even-for-appendix-chapters-in-toc +\RequirePackage{calc} +\RequirePackage[titles]{tocloft} +\ifdefstring{\ELEGANT@lang}{cn}{ + % \renewcommand{\cftchappresnum}{\beforechap\space} + % \renewcommand{\cftchapaftersnum}{\space\afterchap} + % \setlength{\cftchapnumwidth}{\widthof{\textbf{附录~十一}}} + \renewcommand{\numberline}[1]{% + \@cftbsnum #1\@cftasnum~\@cftasnumb ~% + } + \g@addto@macro\appendix{% + % recover \thechapter in the \NR@chapter's \numberline + \ifELEGANT@Hy@later + \patchcmd{\NR@chapter}% + {\numberline{\xchaptertitle}}{\numberline{\thechapter}}% + {}{\fail} + \else + \patchcmd{\Hy@org@chapter}% + {\numberline{\xchaptertitle}}{\numberline{\thechapter}}% + {}{\fail} + \fi + \addtocontents{toc}{% + \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% + \protect\renewcommand{\protect\cftchapaftersnum}{}% + }% + } +}{ + \renewcommand{\cftchappresnum}{\chaptername\space} + \renewcommand{\cftchapaftersnum}{\space} + \setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~9}}} + \g@addto@macro\appendix{% + \addtocontents{toc}{% + \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% + \protect\renewcommand{\protect\cftchapaftersnum}{}% + \setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999}}} + }% + } +} + +% restore the tt default family to lmodern tt family +\renewcommand\ttdefault{lmtt} \ No newline at end of file diff --git a/教材/ouctextbook.sty b/教材/ouctextbook.sty new file mode 100644 index 0000000..14384f8 --- /dev/null +++ b/教材/ouctextbook.sty @@ -0,0 +1,225 @@ +%====================================================================== +% ouctextbook.sty —— 中国海洋大学 教材 版式包 +% +% 从《软件需求工程导论》(sre 仓库) 的版式抽取而来, +% 底层是 elegantbook 文档类,保留其全部排版特性。 +% +% 编译: xelatex 教材.tex (单次即可;有参考文献时 xelatex→bibtex→xelatex×2) +% +% ------------------------------------------------------------------ +% ⚠️⚠️ 本模板与其他模板最大的不同:它是**文档类**不是宏包 +% +% elegantbook 是 \documentclass 级别的类,不能 \usepackage。 +% 所以本文件只提供**配置命令**,正文首行必须自己写 +% \documentclass[...]{elegantbook},再 \usepackage{ouctextbook}。 +% +% 顺序不能反:\documentclass 必须第一行。 +% ------------------------------------------------------------------ +%====================================================================== +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{ouctextbook}[2026/11/01 v1.0 OUC textbook style] + +%====================================================================== +% 一、公共字体(本模板的核心约束) +% +% ⚠️⚠️ 为什么必须在 \documentclass 里写 chinesefont=nofont +% +% elegantbook 的 chinesefont 只有三档,全都不通用: +% +% founder(默认) 方正四大字体 FZShuSong-Z01 / FZHei-B01 / +% FZKai-Z03 / FZFangSong-Z02 +% ⇒ **商业字体,不能随仓库分发**,换机器就废 +% ctexfont ctex 按**系统**字体配(Windows=SimSun/SimHei, +% macOS=PingFang,Linux 视装了什么而定) +% ⇒ 同一份源码在三个平台排出三种样子 +% nofont 不设字体,完全交给用户 +% ⇒ 不额外配置就直接报错 +% +% ⇒ 本模板用 nofont,然后在正文 \input{../fonts.tex} 接入仓库字体。 +% +% ⚠️⚠️ 但只写 nofont 还不够 —— elegantbook.cls 自身还硬编码了两处字体: +% +% \setmainfont{TeXGyreTermesX}[...] % 西文衬线 +% \setsansfont{texgyreheros}[...] % 西文无衬线 +% +% 这两款在精简版 TeX Live 和很多机器上**都没有**,会直接报 +% ! Package fontspec Error: The font "texgyreheros-regular" +% cannot be found +% 而且是 9 个错误连发,因为在类的每个字体档位上都会失败。 +% +% 实测:在 \documentclass 之后用 \setsansfont 覆盖**无效** —— +% 类加载时该字体族已经注册失败,后面的重新指定救不回来。 +% +% ⇒ 唯一可靠的做法是**本地化 cls 本身**:模板目录里带一份 +% elegantbook.cls 副本,把那两处改成仓库字体: +% \setmainfont{texgyretermes}[Path=../fonts/tex-gyre-termes/] +% \setsansfont{OUCSans}[Path=../fonts/ouc-sans/] +% 改动处有 "本地化" 注释,便于将来对比上游版本。 +% +% ⇒ 这也是本模板与仓库其他模板的**唯一结构性差异**: +% 别的模板只需要 \input{../fonts.tex}, +% 本模板还需要那份改过字体的 cls 副本。 +% +% ⚠️ fonts.tex 已用 \def 定义 \songti / \heiti / \kaiti / \fangsong, +% elegantbook 内部依赖 \heiti(用于 \cbfseries、章节标题), +% 所以这层依赖是通的。若哪天 fonts.tex 改了这几个命令的名字, +% 本模板的章节标题会立刻失去中文字体。 +%====================================================================== +\RequirePackage{etoolbox} + +% 检查是否已加载 elegantbook 且用了 nofont。 +% 若用户忘了写 nofont,给出明确提示而不是让方正字体报一堆乱码错误。 +\AtBeginDocument{% + \ifcsname ELEGANT@chinesefont\endcsname + \ifdefstring{\ELEGANT@chinesefont}{nofont}{}{% + \PackageWarning{ouctextbook}{% + 检测到 chinesefont 不是 nofont。请把文档类选项改为 + \string\documentclass[lang=cn,newtx,10pt,black,chinesefont=nofont]{elegantbook}% + \MessageBreak + 否则会加载方正商业字体或系统字体,失去跨平台一致性}% + }% + \fi +} + +%====================================================================== +% 二、标题编号层级 +% +% 原教材主文件里的自定义,很有用,保留: +% 编号最多到第 4 级 章(1) → 节(1.1) → 小节(1.1.1) → 小小节(1.1.1.1) +% 第 5 级(\paragraph)不再进编号体系,改用「(1)(2)(3)」形式, +% 避免出现 3.1.1.1.1 这种过长编号。 +% +% ⚠️ 这段必须在 \begin{document} 之前执行,用 \AtBeginDocument 会太晚 +% (编号层级在导言区就被读取)。 +%====================================================================== +\setcounter{secnumdepth}{3} +\setcounter{tocdepth}{3} + +\makeatletter +\newcounter{paranum}[subsubsection] % 随小小节自动重置 +\renewcommand\paragraph[1]{% + \par\addvspace{0.9ex}% + \stepcounter{paranum}% + \noindent{\bfseries (\arabic{paranum})\,#1}% + \par\nobreak\addvspace{0.1ex}% + \@afterindentfalse\@afterheading} +\makeatother + +%====================================================================== +% 三、封面色带 +% +% 原教材用青绿色 RGB(32,178,170),比 elegantbook 默认的蓝色沉稳, +% 与清华社的封面观感接近。保留。 +% +% ⚠️⚠️ 必须在 \begin{document} 之后才能改 coverlinecolor +% +% elegantbook.cls 第 345 行有 +% \colorlet{coverlinecolor}{second} +% 这行在**类加载末尾**执行,把 coverlinecolor 绑到 "second" 色上 +% (color=black 选项下 second 就是黑色)。 +% +% ⇒ 在导言区写 \colorlet{coverlinecolor}{...} 会被它覆盖, +% 实测封面色带仍是纯黑,改了半天没反应。 +% 必须用 \AtBeginDocument 排到它后面。 +%====================================================================== +\definecolor{ouccoverlinecolor}{RGB}{32,178,170} + +\AtBeginDocument{% + \colorlet{coverlinecolor}{ouccoverlinecolor}% +} + +% 需要临时换别的色时,在正文里调这个(不调则用上面的青绿) +\newcommand{\oucSetCoverColor}[1]{% + \colorlet{coverlinecolor}{#1}% +} + +%====================================================================== +% 四、图形与表格 +% +% 原教材用到的宏包,逐个说明为什么需要: +% array \makecell(表格内换行) +% cprotect \verb 等脆弱命令进表格/标题 +% graphicx 插图 +% float [H] 强制定位(教材排版要求图跟文字,不能漂走) +% longtable 跨页表格 +%====================================================================== +\RequirePackage{array} +\RequirePackage{cprotect} +\RequirePackage{graphicx} +\RequirePackage{float} +\RequirePackage{longtable} + +% TikZ 绘图库(原教材的流程图/关系图用这些) +\RequirePackage{tikz} +\usetikzlibrary{ + shapes.geometric, shapes.misc, + arrows.meta, arrows, + decorations.pathreplacing, decorations.markings, + positioning, calc, fit, backgrounds +} + +%====================================================================== +% 五、断行宽容度 +% +% ⚠️ 教材正文长、中文多、行内夹英文术语和公式,默认 \tolerance +% 会产生大量 Overfull(原教材明确加过这一条)。 +% 2em 是原教材实测的值,既消掉大部分告警,又不会排出稀疏的行。 +%====================================================================== +\setlength{\emergencystretch}{2em} + +%====================================================================== +% 六、常用排版命令 +%====================================================================== +% 表格里的色块占位(原教材 \ccr 的用途:图例色块) +\newcommand{\ouccolorcell}[1]{% + \makecell{{\color{#1}\rule{1cm}{1cm}}}} + +%====================================================================== +% 七、章节末的标准小节 +% +% 原教材每章固定以「本章小结」+「习题」收尾。 +% 做成命令,避免各章写法不一致。 +%====================================================================== +\newcommand{\oucsummary}{\section{本章小结}} +\newcommand{\oucexercises}{\section{习题}} + +%====================================================================== +% 八、封面:无封面图时不插 example-image +% +% ⚠️⚠️ elegantbook 在没写 \cover{} 时会插入 mwe 宏包的 example-image, +% 也就是**一张印着 "Image" 字样的灰底占位图**,铺满首页。 +% 源码(cls 第 1288~1300 行): +% \ifcsname @cover\endcsname +% \includegraphics[width=\linewidth]{\@cover} +% \else +% \includegraphics[width=\linewidth]{example-image} ← 就是这个 +% \fi +% 交付给别人的模板首页顶着 "Image" 两个大字,不合适。 +% +% ⇒ 解法在 cls 里,不在本文件:本地化版本的 elegantbook.cls 已把 +% 那两处 example-image 换成了 \ouc@coverblank(一个占位盒子)。 +% 这样不写 \cover{} 时封面只有色带和文字,没有占位图。 +% +% ⚠️⚠️ 占位盒的宽度**不能是 0**。 +% +% 第一版写成 \rule{0pt}{0pt}(0 宽),立刻冒出 +% Overfull \hbox (5.00002pt too wide) in paragraph at lines 44--44 +% 而且它只出现在 \maketitle 那一行,改 \hspace{2em}、\hspace{2.5em}、 +% minipage 的 0.67/0.27\linewidth、tabular 的列间距,**全部无效**, +% 溢出量死钉在 5.00002pt 不动。 +% +% 根因:0 宽空盒让 \linewidth 在 titlepage 里的计算与 \textwidth +% 差了 5pt,后续并排的 \parbox{0.8\textwidth} + 两个 minipage +% 就整体超宽。 +% +% ✅ 正解:给占位盒一个满宽 +% \newcommand{\ouc@coverblank}{% +% \rule{0pt}{0pt}\hspace{\linewidth}\rule{0pt}{0pt}} +% 实测 0 Overfull。 +% +% ⚠️ 不要试图在本文件里用 \ifcsname 覆盖 \@cover 来绕开 —— 实测 +% \@cover 即使定义成空串也会走 \includegraphics{} 分支报错。 +% 改 cls 是唯一干净的办法。 +%====================================================================== + +\endinput \ No newline at end of file diff --git a/教材/reference.bib b/教材/reference.bib new file mode 100644 index 0000000..aee680f --- /dev/null +++ b/教材/reference.bib @@ -0,0 +1,24 @@ +% 教材模板示例参考文献 +% ⚠️ 这两条是**虚构条目**,只用于展示 biblatex 的排版格式。 +% 实际使用时整份文件替换为真实文献库。 + +@book{example2020, + author = {作者甲 and 作者乙}, + title = {软件工程导论}, + publisher = {示例出版社}, + address = {北京}, + year = {2020}, + edition = {第 3 版}, + language = {chinese}, +} + +@article{example2021, + author = {Author, Alpha and Author, Beta}, + title = {A Sample Article for Bibliography Formatting}, + journal = {Journal of Examples}, + volume = {12}, + number = {3}, + pages = {45--67}, + year = {2021}, + doi = {10.0000/example.2021.001}, +} \ No newline at end of file diff --git a/教材/教材.pdf b/教材/教材.pdf new file mode 100644 index 0000000..027b044 Binary files /dev/null and b/教材/教材.pdf differ diff --git a/教材/教材.tex b/教材/教材.tex new file mode 100644 index 0000000..3a2b8e1 --- /dev/null +++ b/教材/教材.tex @@ -0,0 +1,225 @@ +%====================================================================== +% 中国海洋大学 教材 模板(示例) +% +% 从《软件需求工程导论》(sre 仓库) 的版式抽取而来。 +% 正文内容为占位示例,只用来展示版式,不含原书内容。 +% +% 编译: xelatex 教材.tex +% 有参考文献时:xelatex → bibtex → xelatex → xelatex +% +% ------------------------------------------------------------------ +% ⚠️⚠️ 前两行不能动、不能换序 +% +% 第 1 行 \documentclass 必须含 chinesefont=nofont +% 第 2 行 \input{../fonts.tex} 接入仓库公共字体 +% +% 写错任一处都会退回商业字体或系统字体,详见 ouctextbook.sty 第一节。 +% ------------------------------------------------------------------ +%====================================================================== +\documentclass[lang=cn,newtx,10pt,black,chinesefont=nofont]{elegantbook} +\input{../fonts.tex} +\usepackage{ouctextbook} + +% ---- 书名信息 ---- +\title{教材模板示例} +\subtitle{副标题写在这里} +\author{作者甲 \quad 作者乙 \quad 作者丙} +\institute{中国海洋大学} +\date{2026/11/1} +\version{第一版} +\extrainfo{出版社} + +% ---- 封面图 ---- +% ⚠️ 不写 \cover{} 就不出封面图,只出纯色带封面,不会报错。 +% 要加封面就把图片放进本目录,写 \cover{cover.jpg}。 +% 示例不放图,保持模板轻量。 +% \cover{cover.jpg} + +% ---- 参考文献库(必须在 \begin{document} 之前)---- +\addbibresource[location=local]{reference.bib} + +\begin{document} + +% ---- 标题页(elegantbook 自动生成,含书名/作者/机构/版本/日期)---- +\maketitle + +% ---- 前置部分:页码用罗马数字 ---- +\frontmatter +\tableofcontents + +%====================================================================== +% 前言 +% +% ⚠️ 前言用 \chapter*(不进编号、不进目录), +% 与正文章节的 \chapter 区分。原教材如此。 +%====================================================================== +\chapter*{前言} +\markboth{前言}{前言} + +这里写前言。教材前言通常包括:本书的写作背景与目的、读者对象、 +全书结构安排、各章内容简介、使用建议(可作为哪些课程的教材、 +需要哪些先修知识)、致谢、以及勘误联系方式。 + +\vspace{1.5em} + +\hfill 编\quad 者\\ +\hfill 2026 年 11 月 + +% ---- 正文部分:页码用阿拉伯数字,章从 1 开始 ---- +\mainmatter + +%====================================================================== +% 正文示例章 +% +% ⚠️ 章的标准结构(原教材 13 章全部如此): +% \chapter{标题} +% → 导语(3~5 段,概述本章要点与结构) +% → \section 正文各节 +% → \section{本章小结} +% → \section{习题} +%====================================================================== +\chapter{章节标题示例} + +本章导语。教材每章开篇先有一段到几段导语,说明本章要解决什么问题、 +分几部分展开、与其他章的关系。这段文字通常在 3~5 段、200~400 字之间, +让读者在进入细节前建立整体框架。 + +导语的第二段继续交代本章的组织逻辑。例如「首先……接着……随后…… +最后……」这样的行文,既是给读者的路线图,也是作者自查结构是否清晰的 +工具。 + +\section{节标题} + +正文段落。教材正文 10pt,行距由 elegantbook 设定为 1.2 倍。 + +行内可以用 \textbf{黑体强调}、\emph{楷体强调},以及英文术语 +Requirements Engineering 和缩写 SRE。 + +\subsection{小节标题} + +更细一层的展开。 + +\subsubsection{小小节标题} + +最细一层。注意编号最多到这里(1.1.1.1)。 + +\paragraph{第五级标题} +这一级不再进编号,改用「(1)(2)(3)」形式,避免编号过长。 +新的一段从段首开始。 + +\paragraph{再一个第五级标题} +编号自动递增为(2)。 + +\section{列表与表格示例} + +无序列表: + +\begin{itemize} + \item \textbf{项目软件。}由甲方委托开发,需求主要来自甲方。 + \item \textbf{产品软件。}面向普通用户,需求来自产品经理。 +\end{itemize} + +有序列表: + +\begin{enumerate} + \item \textbf{系统化方法:}使用可重复的过程与标准工具。 + \item \textbf{工程原则:}模块化、抽象、分而治之。 + \item \textbf{质量保证:}通过测试、审查与验证确保质量。 +\end{enumerate} + +表格示例(教材表格通常用三线表,见 \texttt{booktabs}; +这里演示最简的带框表格,与原教材一致): + +\begin{table}[htbp] + \centering + \caption{表格标题示例} + \label{tab:example} + \begin{tabular}{|l|l|} + \hline + \textbf{列标题一} & \textbf{列标题二} \\ \hline + 内容 A & 15.9\% \\ \hline + 内容 B & 13.9\% \\ \hline + \end{tabular} +\end{table} + +见表~\ref{tab:example} 可见表题在表上方。 + +\section{插图示例} + +\begin{figure}[H] + \centering + % 有图时:\includegraphics[width=0.8\textwidth]{image/xxx.png} + \fbox{\parbox[c][3cm][c]{0.6\textwidth}{\centering 图占位}} + \caption{图标题示例} + \label{fig:example} +\end{figure} + +见图~\ref{fig:example}。图题在图下方,与表题相反,这是通行惯例。 + +\section{TikZ 绘图示例} + +教材里的关系图、流程图多用 TikZ 直接画,好处是矢量、可改、不用外部图片: + +\begin{figure}[H] + \centering + \begin{tikzpicture}[ + box/.style={draw, rounded corners, align=center, + fill=blue!6, minimum width=3.2cm, minimum height=1.0cm}, + font=\small] + \node[box] (a) at (0,1.6) {甲方\\(提目标)}; + \node[box] (b) at (0,-1.6) {用户\\(提需求)}; + \node[box] (c) at (5,0) {开发团队}; + \draw[->, thick] (a) -- node[right]{业务需求} (c); + \draw[->, thick] (b) -- node[above]{用户需求} (c); + \end{tikzpicture} + \caption{TikZ 绘图示例} +\end{figure} + +% ---- 章节收尾(原教材每章固定这两节)---- +\oucsummary + +本章小结正文。原教材的小结通常是 1~2 段密集回顾,把本章的核心结论、 +关键数据、与其他章的衔接一次交代清楚,不重复正文细节。 + +\oucexercises + +\begin{enumerate} + \item 习题一示例。 + \item 习题二示例。 +\end{enumerate} + +%====================================================================== +% 附录 +% +% ⚠️ \appendix 之后章号自动变 A、B、C…… +% elegantbook 默认已是字母编号,但为保险显式重设一次 +% (原教材主文件也这么写)。 +%====================================================================== +\appendix +\renewcommand{\thechapter}{\Alph{chapter}} + +\chapter{附录标题示例} + +附录正文。常见附录内容:术语表、缩略语表、工具清单、 +实验数据、参考规范全文等。 + +\chapter{另一个附录} + +附录二正文。 + +%====================================================================== +% 参考文献 +% +% ⚠️ 用 biblatex(elegantbook 已配好 biblatex + biber/bibtex 后端) +% \addbibresource 在导言区、\printbibliography 在正文末尾。 +% +% 本示例的 reference.bib 只有 2 条假条目,仅供演示格式。 +% 实际使用时替换为真实文献。 +% +% ⚠️ \nocite{*} 表示"引用文献库里全部条目",模板演示用。 +% 正式写作应删掉它,只列实际引用的文献。 +%====================================================================== +\nocite{*} +\printbibliography[heading=bibintoc, title=\ebibname] + +\end{document} \ No newline at end of file