Merge branch 'dev' of github.com:ElegantLaTeX/ElegantBook into dev

This commit is contained in:
EthanDeng
2022-08-12 10:32:32 +08:00
3 changed files with 474 additions and 203 deletions

View File

@@ -5,8 +5,8 @@
\author{Ethan Deng \& Liam Huang}
\institute{Elegant\LaTeX{} Program}
\date{April 9, 2022}
\version{4.3}
\date{June, 6, 2022}
\version{4.4}
\bioinfo{自定义}{信息}
\extrainfo{不要以为抹消过去,重新来过,即可发生什么改变。—— 比企谷八幡}
@@ -23,7 +23,7 @@
% 修改标题页的橙色带
% \definecolor{customcolor}{RGB}{32,178,170}
% \colorlet{coverlinecolor}{customcolor}
\usepackage{cprotect}
\begin{document}
\maketitle
@@ -46,6 +46,7 @@ Elegant\LaTeX{} 项目组致力于打造一系列美观、优雅、简便的模
\item 下载地址:\href{https://github.com/ElegantLaTeX/ElegantBook/releases}{正式发行版}\href{https://github.com/ElegantLaTeX/ElegantBook/archive/master.zip}{最新版}
\item 微博Elegant\LaTeX{}(密码有点忘了)
\item 微信公众号Elegant\LaTeX{}(不定期更新)
\item Bilibili\href{https://space.bilibili.com/516479629}{ElegantLaTeX}
\item 用户 QQ 群692108391建议加群
\item 邮件:\email{elegantlatex2e@gmail.com}
\end{itemize}
@@ -197,13 +198,13 @@ tlmgr update --self --all --reinstall-forcibly-removed
\centering
\caption{封面元素信息}
\begin{tabular}{p{0.07\textwidth}p{0.15\textwidth}|p{0.07\textwidth}p{0.15\textwidth}|p{0.07\textwidth}p{0.15\textwidth}}
\toprule
\hline
信息 & 命令 & 信息 & 命令 & 信息 & 命令 \\
\midrule
\hline
标题 & \lstinline|\title| & 副标题 & \lstinline|\subtitle| & 作者 & \lstinline|\author| \\
机构 & \lstinline|\institute| & 日期 & \lstinline|\date| & 版本 & \lstinline|\version| \\
箴言 & \lstinline|\extrainfo| & 封面图 & \lstinline|\cover| & 徽标 & \lstinline|\logo| \\
\bottomrule
\hline
\end{tabular}
\end{table}
@@ -263,33 +264,59 @@ tlmgr update --self --all --reinstall-forcibly-removed
\end{itemize}
\item \textit{示例类环境},有 \textbf{example、problem、exercise} 环境(对应于例、例题、练习),自动编号,编号以章节为单位,其中 \textbf{exercise} 有提示符。
\item \textit{提示类环境},有 \textbf{note} 环境,特点是:无编号,有引导符。
\item \textit{结论类环境},有 \textbf{conclusion、assumption、property、remark、solution} 环境\footnote{本模板还添加了一个 result 选项,用于隐藏 \lstinline{solution}\lstinline{proof} 环境,默认为显示(\lstinline{result=answer}),隐藏使用 \lstinline{result=noanswer}},三者均以粗体的引导词为开头,和普通段落格式一致。
\item \textit{结论类环境},有 \textbf{conclusion、assumption、property、remark、solution} 环境\footnote{本模板还添加了一个 \lstinline|result| 选项,用于隐藏 \lstinline{solution}\lstinline{proof} 环境,默认为显示(\lstinline{result=answer}),隐藏使用 \lstinline{result=noanswer}},三者均以粗体的引导词为开头,和普通段落格式一致。
\end{itemize}
其中,定理类环境均有带星号的版本:\textcolor{main}{\textbf{definition*}}\textcolor{second}{\textbf{theorem*}}\textcolor{second}{\textbf{lemma*}}\textcolor{second}{\textbf{corollary*}}\textcolor{second}{\textbf{axiom*}}\textcolor{second}{\textbf{postulate*}}\textcolor{third}{\textbf{proposition*}},带星号的定理类环境不会编号。
\subsection{定理类环境的使用}
由于本模板使用了 \lstinline{tcolorbox} 宏包来定制定理类环境,所以和普通的定理环境的使用有些许区别,定理的使用方法如下:
\subsubsection{\texttt{fancy} 模式}
\lstinline{fancy} 模式下使用了 \lstinline{tcolorbox} 宏包来定制定理类环境,所以和普通的定理环境的使用有些许区别,有编号定理的使用方法如下:
\begin{lstlisting}
% 有名字,有标签
\begin{theorem}{theorem name}{label}
The content of theorem.
这是一个有名字和标签的定理。
\ref{thm:label} 来引用这个定理。
\end{theorem}
% 无名字,有标签
\begin{theorem}{}{label no name}
这是一个没有名字但是有标签的定理。
\ref{thm:label no name} 来引用这个定理。
\end{theorem}
% 有名字,无标签
\begin{theorem}{theorem name}{}
这是一个有名字但是没有标签的定理。
这个定理不能被引用。
最后的 {} 可以省略不写。
\end{theorem}
% 无名字,无标签
\begin{theorem}{}{}
这是一个没有名字也没有标签的定理。
这个定理不能被引用。
两个 {} 均可以省略不写。
\end{theorem}
\end{lstlisting}
第一个选项 \lstinline{theorem name} 是定理的名字,如果定理没有名字请使用 \lstinline|{}|\cprotect\footnote{除非这个定理也没有标签,否则不能省略。}。第二个选项 \lstinline{label} 是交叉引用时所用到的标签,如果定理没有标签,可以不写 \lstinline|{label}| 或使用 \lstinline|{}|。交叉引用的方法为 \lstinline|\ref{thm:label}|。请注意,交叉引用时必须加上前缀 \lstinline{thm:}。其他相同用法的定理类环境见表 \ref{tab:theorem-class}
第一个必选项 \lstinline{theorem name} 是定理的名字,第二个必选项 \lstinline{label} 是交叉引用时所用到的标签,交叉引用的方法为 \verb|\ref{thm:label}|。请注意,交叉引用时必须加上前缀 \lstinline{thm:}
在用户多次反馈下4.x 之后,引入了原生定理的支持方式,也就是使用可选项方式:
不编号的定理使用方法如下:
\begin{lstlisting}
\begin{theorem}[theorem name] \label{thm:theorem-label}
The content of theorem.
\end{theorem}
% or
\begin{theorem} \label{thm:theorem-withou-name}
The content of theorem without name.
\end{theorem}
% 有名字
\begin{theorem*}{theorem name}
这是一个不编号的有名字的定理。
这个定理不能被引用。
\end{theorem*}
% 无名字
\begin{theorem*}{}
这是一个不编号且没有名字的定理。
最后的 {} 可以省略不写。
这个定理不能被引用。
\end{theorem*}
\end{lstlisting}
其他相同用法的定理类环境有:
其中的选项 \lstinline{theorem name} 是定理的名字,如果没有名字可以不写 \lstinline|{theorem name}| 或使用 \lstinline|{}|
\begin{table}[htbp]
\centering
@@ -308,11 +335,63 @@ tlmgr update --self --all --reinstall-forcibly-removed
\bottomrule
\end{tabular}%
\label{tab:theorem-class}%
\end{table}%
\end{table}%
在用户多次反馈下,在 4.1 版本引入了原生定理的支持方式,使用方法如下:
\begin{lstlisting}
% 有名字,有标签
\begin{theorem}[theorem name]\label{thm:label}
这是一个有名字和标签的定理。
\ref{thm:label} 来引用这个定理。
\end{theorem}
% 无名字,有标签
\begin{theorem}\label{thm:label no name}
这是一个没有名字但是有标签的定理。
\ref{thm:label no name} 来引用这个定理。
\end{theorem}
% 有名字,无标签
\begin{theorem}[theorem name]
这是一个有名字但是没有标签的定理。
这个定理不能被引用。
\end{theorem}
% 无名字,无标签
\begin{theorem}
这是一个没有名字也没有标签的定理。
这个定理不能被引用。
\end{theorem}
\end{lstlisting}
这时引用不需要加前缀,\lstinline{\ref} 中的内容与 \lstinline{\label} 中的内容相同,换句话说,这时的使用方法与使用原生定理环境的时候几乎相同。
\subsubsection{\texttt{simple} 模式}
\lstinline{simple} 模式下使用了 \lstinline{amsthm} 宏包,定理类环境使用方法与原生一致,定理的使用方法如下:
\begin{lstlisting}
% 有名字,有标签
\begin{theorem}[theorem name]\label{thm:label}
这是一个有名字和标签的定理。
\ref{thm:label} 来引用这个定理。
\end{theorem}
% 无名字,有标签
\begin{theorem}\label{thm:label no name}
这是一个没有名字但是有标签的定理。
\ref{thm:label no name} 来引用这个定理。
\end{theorem}
% 有名字,无标签
\begin{theorem}[theorem name]
这是一个有名字但是没有标签的定理。
这个定理不能被引用。
\end{theorem}
% 无名字,无标签
\begin{theorem}
这是一个没有名字也没有标签的定理。
这个定理不能被引用。
\end{theorem}
\end{lstlisting}
% \subsection{算法环境}
% \begin{algorithm}\label{alg:test}
% \Input{A bitmap $I$ of size $w \times l$}
% \Output{A partition of the bitmap}
@@ -342,13 +421,93 @@ tlmgr update --self --all --reinstall-forcibly-removed
\subsection{修改计数器}
当前定理等环境计数器按章计数,如果想修改定理类环境按节计数,可以修改计数器选项 thmcnt
当前定理等环境计数器按章计数,如果想修改定理类环境按节计数,可以修改计数器选项 \lstinline{thmcnt},可用选项为 \lstinline{chapter} (默认)与 \lstinline{section}
\begin{lstlisting}
\documentclass[section]{elegantbook} %or
\documentclass[thmcnt=section]{elegantbook}
\documentclass[section]{elegantbook} %or
\documentclass[thmcnt=section]{elegantbook}
\end{lstlisting}
\subsection{自定义定理类环境}
4.4 版本新增了一个自定义定理类环境的命令:\lstinline|\elegantnewtheorem|,它的参数含义如下:
\begin{lstlisting}
% fancy 模式(默认)
\elegantnewtheorem{env}{title}{style}{prefix}
% simple 模式
\elegantnewtheorem{env}{title}{style}
\end{lstlisting}
该命令可以同时定义编号环境 \lstinline|env| 和不编号环境 \lstinline|env*|。
其中 \lstinline|style| 支持的参数有:\lstinline|defstyle|\lstinline|thmstyle|\lstinline|prostyle|,分别对应“定义”,“定理”,“命题”三种样式。
\begin{itemize}
\item 在炫彩模式(\lstinline{fancy})下,需要 4 个参数来定义一个新的定理类环境,分别是:
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀:
\begin{lstlisting}
% 导言区
\elegantnewtheorem{examplefancy}{自定义定理类环境}{thmstyle}{exfancy}
% 正文
\begin{examplefancy}{定理名}{label}
这里是自定义定理类环境 \ref{exfancy:label}
\end{examplefancy}
\begin{examplefancy*}{定理名}
这里是无编号自定义定理类环境
\end{examplefancy*}
\end{lstlisting}
如果不给出第四个参数,或第四个参数置空的话,将会用定理类环境名来作为默认前缀,即
\begin{lstlisting}
% 导言区
\elegantnewtheorem{test}{TEST}{thmstyle}
% 或
\elegantnewtheorem{test}{TEST}{thmstyle}{}
% 正文
\begin{test}{name}{label}
默认前缀为 test。
使用 \ref{test:label} 来引用这个定理类环境。
\end{test}
\end{lstlisting}
这时会在终端以及 \verb|.log| 文件中输出一个警告信息来提示用户没有定义前缀:
\begin{lstlisting}[language=bash]
Class elegantbook Warning: Because you didn't provide a prefix.
(elegantbook) We use test as the default prefix.
(elegantbook) You have to use
(elegantbook) \ref {test:label} to refer a
(elegantbook) \begin {test}{name}{label} environment.
(elegantbook) on input line 3.
\end{lstlisting}
\item 在简单模式(\lstinline{simple})下,需要 3 个参数来定义一个新的定理类环境,分别是:
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀:
\begin{lstlisting}
% 导言区
\elegantnewtheorem{examplesimple}{自定义定理类环境}{thmstyle}
% 正文
\begin{examplesimple}[定理名]\label{exsimple:label}
这里是自定义定理类环境 \ref{exsimple:label}
\end{examplesimple}
\begin{examplesimple*}[定理名]
这里是无编号自定义定理类环境
\end{examplesimple*}
\end{lstlisting}
如果此时错误地给出了第四个参数,那么将会在终端以及 \verb|.log| 文件中输出一个错误信息:
\begin{lstlisting}
% elegantbook-cn.tex
\elegantnewtheorem{test}{TEST}{thmstyle}{}
% .log file
./elegantbook-cn.tex:3: Class elegantbook Error: You can't set a prefix in mode ``simple''.
(elegantbook) Just use
(elegantbook) \elegantnewtheorem {test}{TEST}{thmstyle} .
\end{lstlisting}
\end{itemize}
\subsection{其他环境的使用}
@@ -485,7 +644,7 @@ The content of introduction.
效果如下:
\begin{problemset}
\begin{problemset}[我的题目]
\item exercise 1
\item exercise 2
\item exercise 3
@@ -697,7 +856,7 @@ Lebesgue 积分有几种不同的定义方式。我们将采用逐步定义非
\int_{\mathcal{R}^p\times\mathcal{R}^q} f(x,y) dxdy=\int_{\mathcal{R}^p}\left(\int_{\mathcal{R}^q}f(x,y)dy\right)dx.
\end{equation}
2$f(x,y)$$\mathcal{R}^p\times\mathcal{R}^q$ 上的可积函数,则对几乎处处的 $x\in\mathcal{R}^p$$f(x,y)$ 作为 $y$ 的函数是 $\mathcal{R}^q$ 上的可积函数,并且 $g(x)=\int_{\mathcal{R}^q}f(x,y) dy$$\mathcal{R}^p$ 上的可积函数。而且~\ref{eq:461} 成立。
2$f(x,y)$$\mathcal{R}^p\times\mathcal{R}^q$ 上的可积函数,则对几乎处处的 $x\in\mathcal{R}^p$$f(x,y)$ 作为 $y$ 的函数是 $\mathcal{R}^q$ 上的可积函数,并且 $g(x)=\int_{\mathcal{R}^q}f(x,y) dy$$\mathcal{R}^p$ 上的可积函数。而且~\eqref{eq:461} 成立。
\end{theorem}
\ref{thm:fubi}
@@ -749,8 +908,6 @@ Lebesgue 积分有几种不同的定义方式。我们将采用逐步定义非
见前文介绍,可以使用 \lstinline{scheme=chinese} 设置。
\item \question{大佬,我想把正文字体改为亮色,背景色改为黑灰色。}
页面颜色可以使用 \lstinline{\pagecolor} 命令设置,文本命令可以参考\href{https://tex.stackexchange.com/questions/278544/xcolor-what-is-the-equivalent-of-default-text-color}{这里}进行设置。
\item \question{\lstinline[breaklines]{Package ctex Error: CTeX fontset 'Mac' is unavailable.}}
在 Mac 系统下,中文编译请使用 \hologo{XeLaTeX}
\item \question{\lstinline{! LaTeX Error: Unknown option 'scheme=plain' for package 'ctex'.}}
你用的 C\TeX{} 套装吧?这个里面的 \lstinline{ctex} 宏包已经是已经是 10 年前的了,与本模板使用的 \lstinline{ctex} 宏集有很大区别。不建议 C\TeX{} 套装了,请卸载并安装 \TeX{} Live 2022。
\item \question{我该使用什么版本?}
@@ -771,11 +928,20 @@ Lebesgue 积分有几种不同的定义方式。我们将采用逐步定义非
根据用户的反馈,我们不断修正和完善模板。由于 3.00 之前版本与现在版本差异非常大,在此不列出 3.00 之前的更新内容。
\datechange{2022/05/28}{版本 4.4 正式发布。}
\begin{change}
\item \textbf{重要改动}:提供了一个定义定理类环境的命令 \lstinline|\elegantnewtheorem|。
\item \textbf{重要改动}:为所有内置定理类环境提供了带星号的版本,带星号的定理类环境不会编号,修复 \href{https://github.com/ElegantLaTeX/ElegantBook/issues/167}{issue: \#167}
\item \textbf{重要改动}:在 \lstinline{scheme=chinese} 下将目录中的“第 1 章”修改为“第一章”;
\item 将 TeX Gyre Termes 改为 TeX Gyre TermesX使英文部分字形与 newtx 系列宏包更相近;
\item 重写了内置定理类环境的实现方法,修复了一些 bug由于修改部分较大如果引入了新的 bug请及时在 QQ 群或 \href{https://github.com/ElegantLaTeX}{Github} 上进行反馈;
\end{change}
\datechange{2022/04/09}{版本 4.3 正式发布。}
\begin{change}
\item 放弃 newtx 系列宏包的设置,改用 TeX Gyre Terms并设置其他字体
\item 放弃 newtx 系列宏包的设置,改用 TeX Gyre Termes并设置其他字体
\item 修改定理类环境内部字体设置,修复环境内部中文无法加粗问题;
\item 增加定理类环境的计数器选项 \lstinline{thmcnt},可选 \lstinline{chapter}\lstinline{section}
\item 增加 \lstinline{bibend} 选项,可选 \lstinline{bibend=biber}(默认)和 \lstinline{bibend=bibtex}
@@ -924,7 +1090,7 @@ Lebesgue 积分有几种不同的定义方式。我们将采用逐步定义非
\item 修改英文字体为 \lstinline{newtx} 系列,另外大型操作符号维持 cm 字体。
\item 中文字体改用 \lstinline{ctex} 宏包自动设置。
\item 删除 \lstinline{xeCJK} 字体设置,原因是不同系统字体不方便统一。
\item 定理换用 \lstinline{tcolobox} 宏包定义,并基本维持原有的定理样式,优化显示效果,支持跨页;定理类名字重命名,如 etheorem 改为 theorem 等等。
\item 定理换用 \lstinline{tcolorbox} 宏包定义,并基本维持原有的定理样式,优化显示效果,支持跨页;定理类名字重命名,如 etheorem 改为 theorem 等等。
\item 删去自定义的缩进命令 \lstinline{\Eindent}
\item 添加参考文献宏包 \lstinline{natbib}
\item 颜色名字重命名。

View File

@@ -5,8 +5,8 @@
\author{Ethan Deng \& Liam Huang}
\institute{Elegant\LaTeX{} Program}
\date{April 9, 2022}
\version{4.3}
\date{May 25, 2022}
\version{4.4}
\bioinfo{Bio}{Information}
\extrainfo{Victory won\rq t come to us unless we go to it. }
@@ -17,6 +17,7 @@
% modify the color in the middle of titlepage
\definecolor{customcolor}{RGB}{32,178,170}
\colorlet{coverlinecolor}{customcolor}
\usepackage{cprotect}
\begin{document}
@@ -94,7 +95,7 @@ The option for device (\lstinline{device}) was originally used in ElegantNote, n
\end{lstlisting}
\section{Color Themes}
This template contains 5 color themes, i.e. \textcolor{structure1}{\lstinline{green}}\footnote{Original default theme.}, \textcolor{structure2}{\lstinline{cyan}}, \textcolor{structure3}{\lstinline{blue}}(default), \textcolor{structure4}{\lstinline{gray}}, \textcolor{structure5}{\lstinline{black}}. You can choose \lstinline{green} with
This template contains 5 color themes, i.e., \textcolor{structure1}{\lstinline{green}}\footnote{Original default theme.}, \textcolor{structure2}{\lstinline{cyan}}, \textcolor{structure3}{\lstinline{blue}}(default), \textcolor{structure4}{\lstinline{gray}}, \textcolor{structure5}{\lstinline{black}}. You can choose \lstinline{green} with
\begin{lstlisting}
\documentclass[green]{elegantbook} %or
\documentclass[color=green]{elegantbook}
@@ -216,32 +217,45 @@ In this template, we defined four different theorem class environments
\item \textit{Conclusion Environment}, including \textbf{conclusion, assumption, property, remark and solution}\footnote{We also define an option \lstinline{result}, which can hide the \lstinline{solution} and \lstinline{proof} environments. You can switch between \lstinline{result=answer} and \lstinline{result=noanswer}.} environments, all of which begin with boldfaced words, with format consistent with normal paragraphs.
\end{itemize}
All of theorem environments have star versions: \textcolor{main}{\textbf{definition*}}, \textcolor{second}{\textbf{theorem*}}, \textcolor{second}{\textbf{lemma*}}, \textcolor{second}{\textbf{corollary*}}, \textcolor{second}{\textbf{axiom*}}, \textcolor{second}{\textbf{postulate*}}, \textcolor{third}{\textbf{proposition*}}. Environments with an asterisk are not numbered.
\subsection{Theorem Class Environments}
Since the template uses the \lstinline{tcolorbox} package to customize the theorem class environments, it is slightly different from the normal theorem environments. The usage is as follows:
\begin{lstlisting}
\begin{theorem}{theorem name}{label text}
The content of theorem.
\end{theorem}
\end{lstlisting}
The first parameter \lstinline{<theorem name>} represents the name of the theorem, and the second parameter \lstinline{label} represents the label used in cross-reference with \verb|ref{thm:label}|. Note that cross-references must be prefixed with \lstinline{thm:}.
\subsubsection{\lstinline{fancy} mode}
From version 4.1, you can write your theorem environments as follows:
In \lstinline{fancy} mode, the template uses the \lstinline{tcolorbox} package to customize the theorem class environments, it is slightly different from the normal theorem environments. The usage is as follows:
\begin{lstlisting}
\begin{theorem}[theorem name]\label{thm:label text}
The content of theorem.
\end{theorem}
% or
\begin{theorem}
The content of theorem.
\end{theorem}
\end{lstlisting}
% name + label
\begin{theorem}{theorem name}{label}
The content of a theorem with name and label.
Use \ref{thm:label} to refer this theorem.
\end{theorem}
% no name + label
\begin{theorem}{}{label no name}
The content of a theorem without name.
Use \ref{thm:label no name} to refer this theorem.
\end{theorem}
% name + no label
\begin{theorem}{theorem name}{}
The content of a theorem without label.
Can't refer this theorem.
The last {} can be removed.
\end{theorem}
% no name + no label
\begin{theorem}{}{}
The content of a theorem without name and label.
Can't refer this theorem.
Both of {} can be removed.
\end{theorem}
\end{lstlisting}
The first parameter \lstinline{theorem name} represents the name of the theorem. If the current theorem has no name, please use \lstinline|{}|\cprotect\footnote{Unless this theorem has neither no label, you should not omit this \verb|{}|.}, and the second parameter \lstinline{label} represents the label used in cross-reference with \verb|\ref{thm:label}|. Note that cross-references must be prefixed with \lstinline{thm:}.
Other theorem class environments with the same usage includes:
\begin{table}[htbp]
\centering
\caption{Theorem Class Environments}
\centering
\caption{Theorem Class Environments}
\begin{tabular}{llll}
\toprule
Environment & Label text & Prefix & Cross-reference \\
@@ -255,12 +269,39 @@ Other theorem class environments with the same usage includes:
proposition & label & pro & \lstinline|\ref{pro:label}| \\
\bottomrule
\end{tabular}%
\label{tab:theorem-class}%
\end{table}%
\label{tab:theorem-class}%
\end{table}%
From version 4.1, you can write your theorem environments as follows:
\begin{lstlisting}
\begin{theorem}[theorem name]\label{thm:theorem-label}
The content of theorem.
\end{theorem}
% or
\begin{theorem}\label{thm:theorem-without-name}
The content of theorem.
\end{theorem}
\end{lstlisting}
In this case, cross-reference don't have to be prefixed, i.e. the parameter of \lstinline{\ref} is the same as that of \lstinline{\label}.
\subsubsection{\lstinline{simple} mode}
In \lstinline{simple} mode, the template uses the \lstinline{amsthm} package to customize the theorem class environments. The usage is as follows:
\begin{lstlisting}
\begin{theorem}[theorem name]\label{thm:theorem-label}
The content of theorem.
\end{theorem}
% or
\begin{theorem}\label{thm:theorem-without-name}
The content of theorem without name.
\end{theorem}
\end{lstlisting}
\subsection{Counter for Theorem Environments}
You can use \lstinline{thmcnt} option to control the theorem counter/number display style for the theorem environments, the acceptable options are \lstinline{chapter} (default) and \lstinline{section}.
You can use \lstinline{thmcnt} option to control the theorem counter/number display style for the theorem environments, the acceptable options are \lstinline{chapter} (default) and \lstinline{section}:
\begin{lstlisting}
\documentclass[section]{elegantbook} % turn the Theorem 4.1 to Theorem 4.1.1
@@ -268,7 +309,6 @@ You can use \lstinline{thmcnt} option to control the theorem counter/number disp
\end{lstlisting}
\subsection{Other Customized Environments}
The other three math environments can be called directly since there are no additional option for them, e.g. \lstinline{example}:
\begin{lstlisting}
@@ -640,7 +680,7 @@ We revised our templates now and then. This section shows the version story of E
\datechange{2022/04/09}{release of v4.3.}
\begin{change}
\item Remove part newtx settings, set TeX Gyre Terms/Heros fonts under \hologo{XeLaTeX}.
\item Remove part newtx settings, set TeX Gyre Termes/Heros fonts under \hologo{XeLaTeX}.
\item Fix Chinese fonts in the theorem environments.
\item Add theorem counter option, \lstinline{thmcnt=section}.
\item Add bib option \lstinline{bibend}, which can take value of biber and bibtex.

View File

@@ -123,6 +123,10 @@
pdfborder={0 0 0},
linktocpage
}
\newif\ifELEGANT@Hy@later
\@ifpackagelater{hyperref}{2022/05/16}
{\ELEGANT@Hy@latertrue}
{\ELEGANT@Hy@laterfalse}
%% device settings
\RequirePackage{geometry}
@@ -242,7 +246,7 @@
\let\oldrmdefault\rmdefault
\let\oldsfdefault\sfdefault
\let\oldttdefault\ttdefault
\RequirePackage[T1]{fontenc}
\def\encodingdefault{T1}
\renewcommand{\rmdefault}{ntxtlf}
\renewcommand{\sfdefault}{qhv}
\renewcommand{\ttdefault}{ntxtt}
@@ -844,8 +848,22 @@
\ifdefstring{\ELEGANT@lang}{cn}{
\ifdefstring{\ELEGANT@scheme}{chinese}{
\newcommand{\xchaptertitle}{\zhnumber{\arabic{chapter}}} }{
\newcommand{\xchaptertitle}{ \thechapter{} }} }{
\newcommand{\xchaptertitle}{\chaptername~\thechapter~}}
\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}{
@@ -866,7 +884,9 @@
%%define the note and proof environment
%%define the
%%definition theorem postulate axiom corollary lemma proposition
%%and proof environment
\RequirePackage{pifont,manfnt,bbding}
\RequirePackage[many]{tcolorbox}
% \newlength{\normalparindent}
@@ -910,106 +930,77 @@
overlay unbroken and last={
\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {
\textcolor{second}{$\heartsuit$}};}},
propstyle/.style={
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$}};}},}
% \newtcbtheorem[auto counter,number within=chapter]{definition}{\definitionname}{defstyle}{def}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{definition}{ g o t\label g }{
common,defstyle,
IfValueTF={#1}
{title={\definitionname~\thetcbcounter\ (#1)}}
\textcolor{third}{$\spadesuit$}};}},
ELEGANT@title/.code n args={2}
{
IfValueTF={#2}
{title={\definitionname~\thetcbcounter\ (#2)}}
{title=\definitionname~\thetcbcounter}
\ifblank{#2}
{\tcbset{title={\csname #1name\endcsname~\thetcbcounter}}}
{\tcbset{title={\csname #1name\endcsname~\thetcbcounter\ (#2)}}}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={def:#4}}}
ELEGANT@label/.code n args={2}
{
\ifblank{#2}
{}{\tcbset{label={#1:#2}}}
}
}
% \newtcbtheorem[auto counter,number within=chapter]{theorem}{\theoremname}{thmstyle}{thm}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{theorem}{ g o t\label g }{
common,thmstyle,
IfValueTF={#1}
{title={\theoremname~\thetcbcounter\ (#1)}}
% 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.
\newcommand{\ELEGANT@newtheorem}[3]{
\ifcsundef{#1name}{%
\ClassError{elegantbook}{%
\ #1name undefined, \MessageBreak
Please check in language setting
}{}
}{\relax}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{#1}{ g o t\label g }{
common,#3,
IfValueTF={##1}
{ELEGANT@title={#1}{##1}}
{
IfValueTF={#2}
{title={\theoremname~\thetcbcounter\ (#2)}}
{title=\theoremname~\thetcbcounter}
IfValueTF={##2}
{ELEGANT@title={#1}{##2}}
{ELEGANT@title={#1}{}}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={thm:#4}}}
}
% \newtcbtheorem[auto counter,number within=chapter]{postulate}{\postulatename}{thmstyle}{pos}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{postulate}{ g o t\label g }{
common,thmstyle,
IfValueTF={#1}
{title={\postulatename~\thetcbcounter\ (#1)}}
IfValueT={##4}
{
IfValueTF={#2}
{title={\postulatename~\thetcbcounter\ (#2)}}
{title=\postulatename~\thetcbcounter}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={pos:#4}}}
IfBooleanTF={##3}
{label={##4}}
{ELEGANT@label={#2}{##4}}
}
% \newtcbtheorem[auto counter,number within=chapter]{axiom}{\axiomname}{thmstyle}{axi}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{axiom}{ g o t\label g }{
common,thmstyle,
IfValueTF={#1}
{title={\axiomname~\thetcbcounter\ (#1)}}
}
\DeclareTColorBox{#1*}{ g o }{
common,#3,
IfValueTF={##1}
{ELEGANT@title={#1}{##1}}
{
IfValueTF={#2}
{title={\axiomname~\thetcbcounter\ (#2)}}
{title=\axiomname~\thetcbcounter}
IfValueTF={##2}
{ELEGANT@title={#1}{##2}}
{ELEGANT@title={#1}{}}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={axi:#4}}}
}
% \newtcbtheorem[auto counter,number within=chapter]{corollary}{\corollaryname}{thmstyle}{cor}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{corollary}{ g o t\label g }{
common,thmstyle,
IfValueTF={#1}
{title={\corollaryname~\thetcbcounter\ (#1)}}
{
IfValueTF={#2}
{title={\corollaryname~\thetcbcounter\ (#2)}}
{title=\corollaryname~\thetcbcounter}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={cor:#4}}}
}
% \newtcbtheorem[auto counter,number within=chapter]{lemma}{\lemmaname}{thmstyle}{lem}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{lemma}{ g o t\label g }{
common,thmstyle,
IfValueTF={#1}
{title={\lemmaname~\thetcbcounter\ (#1)}}
{
IfValueTF={#2}
{title={\lemmaname~\thetcbcounter\ (#2)}}
{title=\lemmaname~\thetcbcounter}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={lem:#4}}}
}
% \newtcbtheorem[auto counter,number within=chapter]{proposition}{\propositionname}{propstyle}{pro}
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{proposition}{ g o t\label g }{
common,propstyle,
IfValueTF={#1}
{title={\propositionname~\thetcbcounter\ (#1)}}
{
IfValueTF={#2}
{title={\propositionname~\thetcbcounter\ (#2)}}
{title=\propositionname~\thetcbcounter}
},
IfValueT={#4}
{IfBooleanTF={#3}{label={#4}}{label={pro:#4}}}
}
% define several environment
% we define headers like \definitionname before
\ELEGANT@newtheorem{definition}{def}{defstyle}
\ELEGANT@newtheorem{theorem}{thm}{thmstyle}
\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}
@@ -1020,7 +1011,7 @@
% \let\proofname\relax
\let\endproof\relax
% declare a new theorem style
% 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}{
@@ -1028,21 +1019,85 @@
\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.
\newcommand{\ELEGANT@newtheorem}[2]{
\theoremstyle{#2}
\newtheorem{#1}{\csname #1name\endcsname}[\ELEGANT@thmcnt]
\newtheorem*{#1*}{\csname #1name\endcsname}
}
\theoremstyle{defstyle} % definition style
\newtheorem{definition}{\definitionname}[\ELEGANT@thmcnt]
\theoremstyle{thmstyle} %theorem style
\newtheorem{theorem}{\theoremname}[\ELEGANT@thmcnt]
\newtheorem{lemma}{\lemmaname}[\ELEGANT@thmcnt]
\newtheorem{corollary}{\corollaryname}[\ELEGANT@thmcnt]
\newtheorem{postulate}{\postulatename}[\ELEGANT@thmcnt]
\newtheorem{axiom}{\axiomname}[\ELEGANT@thmcnt]
\theoremstyle{prostyle} % proposition style
\newtheorem{proposition}{\propositionname}[\ELEGANT@thmcnt]
% define several environment
% we define headers like \definitionname before
\ELEGANT@newtheorem{definition}{defstyle}
\ELEGANT@newtheorem{theorem}{thmstyle}
\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}{}
\NewDocumentCommand\elegantnewtheorem{ m m m g }
{
\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.
}
}
\expandafter\def\csname #1name\endcsname{#2}
\ifdefstring{\ELEGANT@mode}{simple}{%
\IfValueTF{#4}
{\ELEGANT@newtheorem@error}
{\ELEGANT@newtheorem{#1}{#3}}
}{\relax}
\ifdefstring{\ELEGANT@mode}{fancy}{%
\IfValueTF{#4}
{
\def\ELEGANT@temp@prefix{#4}
\ifdefempty{\ELEGANT@temp@prefix}
{
\ELEGANT@newtheorem{#1}{#1}{#3}
\ELEGANT@newtheorem@warning
}
{\ELEGANT@newtheorem{#1}{#4}{#3}}
}
{
\ELEGANT@newtheorem{#1}{#1}{#3}
\ELEGANT@newtheorem@warning
}
}{\relax}
}
% maingreen-def): example exercise problem solution
% secondorange-thm: proof note remark
% thirdblue-prop): assumptions property conclusion custom
@@ -1263,7 +1318,7 @@
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},
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,hypersetup,mainmatter,frontmatter,tableofcontents,elegantpar,heiti,kaishu,lstset,pagecolor,zhnumber,marginpar,part,equote,marginnote,bioinfo,datechange,listofchange,lvert,lastpage,songti,heiti,fangsong,setCJKfamilyfont,textbf},
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},
frame=single,
tabsize=2,
rulecolor=\color{structurecolor},
@@ -1327,18 +1382,28 @@
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}%
\thispagestyle{empty}%
\newpage%
beforechap\newpage%
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
% https://tex.stackexchange.com/questions/56839/chaptername-is-used-even-for-appendix-chapters-in-toc
\usepackage{calc}
\usepackage[titles]{tocloft}
\RequirePackage{calc}
\RequirePackage[titles]{tocloft}
\ifdefstring{\ELEGANT@lang}{cn}{
\renewcommand{\cftchappresnum}{\beforechap\space}
\renewcommand{\cftchapaftersnum}{\space\afterchap}
% \renewcommand{\cftchappresnum}{\beforechap\space}
% \renewcommand{\cftchapaftersnum}{\space\afterchap}
\setlength{\cftchapnumwidth}{\widthof{\textbf{附录~999}}}
\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}{}%