mirror of
https://github.com/ElegantLaTeX/ElegantBook.git
synced 2026-01-26 04:14:35 +08:00
- 增强对定理类环境的计数器的控制
- 增加文档类选项 `usesamecnt`, 使全文的定理类环境计数器统一. - 为 `\elegantnewtheorem` 增加新的可选参数, 来选择该定理类环境的计数器统一的计数器
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
\author{Ethan Deng \& Liam Huang}
|
\author{Ethan Deng \& Liam Huang}
|
||||||
\institute{Elegant\LaTeX{} Program}
|
\institute{Elegant\LaTeX{} Program}
|
||||||
\date{Aug 15, 2022}
|
\date{Aug 17, 2022}
|
||||||
\version{4.4}
|
\version{4.5}
|
||||||
\bioinfo{自定义}{信息}
|
\bioinfo{自定义}{信息}
|
||||||
|
|
||||||
\extrainfo{要让一群人团结起来,需要的不是英明的领导,而是共同的敌人。—— 比企谷八幡}
|
\extrainfo{要让一群人团结起来,需要的不是英明的领导,而是共同的敌人。—— 比企谷八幡}
|
||||||
@@ -446,24 +446,36 @@ tlmgr update --self --all --reinstall-forcibly-removed
|
|||||||
\documentclass[thmcnt=section]{elegantbook}
|
\documentclass[thmcnt=section]{elegantbook}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
|
如果希望全局的定理类环境使用同一个计数器,可以使用文档类选项 \lstinline{usesamecnt}:
|
||||||
|
|
||||||
|
\begin{lstlisting}
|
||||||
|
\documentclass[usesamecnt]{elegantbook}
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
\subsection{自定义定理类环境}
|
\subsection{自定义定理类环境}
|
||||||
|
|
||||||
4.4 版本新增了一个自定义定理类环境的命令:\lstinline|\elegantnewtheorem|,它的参数含义如下:
|
4.4 版本新增了一个自定义定理类环境的命令:\lstinline|\elegantnewtheorem|,它的参数含义如下:
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
% fancy 模式(默认)
|
% fancy 模式(默认)
|
||||||
\elegantnewtheorem{env}{title}{style}{prefix}
|
\elegantnewtheorem{env}{title}{style}{prefix}[numbered-like]
|
||||||
% simple 模式
|
% simple 模式
|
||||||
\elegantnewtheorem{env}{title}{style}
|
\elegantnewtheorem{env}{title}{style}[numbered-like]
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
该命令可以同时定义编号环境 \lstinline|env| 和不编号环境 \lstinline|env*|。
|
该命令可以同时定义编号环境 \lstinline|env| 和不编号环境 \lstinline|env*|。
|
||||||
|
|
||||||
其中 \lstinline|style| 支持的参数有:\lstinline|defstyle|,\lstinline|thmstyle|,\lstinline|prostyle|,分别对应“定义”,“定理”,“命题”三种样式。
|
其中 \lstinline|style| 支持的参数有:\lstinline|defstyle|,\lstinline|thmstyle|,\lstinline|prostyle|,分别对应“定义”,“定理”,“命题”三种样式。
|
||||||
|
|
||||||
|
如果添加了可选参数 \lstinline{numbered-like},将会使该定理类环境与名为 \lstinline{numbered-like} 的定理类环境使用同一计数器。\textbf{注意}:该参数在使用 \lstinline{usesamecnt} 选项时不起作用,并且会在终端以及 \lstinline{.log} 文件中输出一个警告,来提示用户该选项不起作用:
|
||||||
|
|
||||||
|
\begin{lstlisting}
|
||||||
|
[numbered-like] won't make sence with option
|
||||||
|
`usesamecnt'.
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item 在炫彩模式(\lstinline{fancy})下,需要 4 个参数来定义一个新的定理类环境,分别是:
|
\item 在炫彩模式(\lstinline{fancy})下,需要 5 个参数来定义一个新的定理类环境,分别是:
|
||||||
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀:
|
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀,(可选)该定理类环境继承的定理类环境:
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
% 导言区
|
% 导言区
|
||||||
@@ -501,8 +513,8 @@ Class elegantbook Warning: Because you didn't provide a prefix.
|
|||||||
(elegantbook) on input line 3.
|
(elegantbook) on input line 3.
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
\item 在简单模式(\lstinline{simple})下,需要 3 个参数来定义一个新的定理类环境,分别是:
|
\item 在简单模式(\lstinline{simple})下,需要 4 个参数来定义一个新的定理类环境,分别是:
|
||||||
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀:
|
定理类环境名,定理类环境的标题,定理类环境的样式,该定理类环境的前缀,(可选)该定理类环境继承的定理类环境:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
% 导言区
|
% 导言区
|
||||||
\elegantnewtheorem{examplesimple}{自定义定理类环境}{thmstyle}
|
\elegantnewtheorem{examplesimple}{自定义定理类环境}{thmstyle}
|
||||||
@@ -965,6 +977,12 @@ Lebesgue 积分有几种不同的定义方式。我们将采用逐步定义非
|
|||||||
|
|
||||||
根据用户的反馈,我们不断修正和完善模板。由于 3.00 之前版本与现在版本差异非常大,在此不列出 3.00 之前的更新内容。
|
根据用户的反馈,我们不断修正和完善模板。由于 3.00 之前版本与现在版本差异非常大,在此不列出 3.00 之前的更新内容。
|
||||||
|
|
||||||
|
\datechange{2022/08/17}{版本 4.5 pre}
|
||||||
|
\begin{change}
|
||||||
|
\item \textbf{重要改动}:提供了一个新的文档类选项 \lstinline|usesamecnt|,可以使全局的定理类环境使用同一个计数器。
|
||||||
|
\item \textbf{重要改动}:修改了 \lstinline|\elegantnewtheorem| 命令,使其有第五个(可选)参数。
|
||||||
|
\end{change}
|
||||||
|
|
||||||
\datechange{2022/08/15}{版本 4.4 正式发布。}
|
\datechange{2022/08/15}{版本 4.4 正式发布。}
|
||||||
|
|
||||||
\begin{change}
|
\begin{change}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
\RequirePackage{etoolbox}
|
\RequirePackage{etoolbox}
|
||||||
\SetupKeyvalOptions{family=ELEGANT, prefix=ELEGANT@, setkeys=\kvsetkeys}
|
\SetupKeyvalOptions{family=ELEGANT, prefix=ELEGANT@, setkeys=\kvsetkeys}
|
||||||
\newcommand{\ekv}[1]{\kvsetkeys{ELEGANT}{#1}}
|
\newcommand{\ekv}[1]{\kvsetkeys{ELEGANT}{#1}}
|
||||||
|
|
||||||
% ----- Colors -----
|
% ----- Colors -----
|
||||||
\DeclareStringOption[blue]{color}
|
\DeclareStringOption[blue]{color}
|
||||||
\DeclareStringOption[en]{lang}
|
\DeclareStringOption[en]{lang}
|
||||||
@@ -56,6 +55,7 @@
|
|||||||
|
|
||||||
\DeclareVoidOption{fancy}{\ekv{mode=fancy}}
|
\DeclareVoidOption{fancy}{\ekv{mode=fancy}}
|
||||||
\DeclareVoidOption{simple}{\ekv{mode=simple}}
|
\DeclareVoidOption{simple}{\ekv{mode=simple}}
|
||||||
|
\DeclareBoolOption[false]{usesamecnt}
|
||||||
|
|
||||||
\DeclareVoidOption{answer}{\ekv{result=answer}}
|
\DeclareVoidOption{answer}{\ekv{result=answer}}
|
||||||
\DeclareVoidOption{noanswer}{\ekv{result=noanswer}}
|
\DeclareVoidOption{noanswer}{\ekv{result=noanswer}}
|
||||||
@@ -895,6 +895,19 @@
|
|||||||
\RequirePackage[many]{tcolorbox}
|
\RequirePackage[many]{tcolorbox}
|
||||||
% \newlength{\normalparindent}
|
% \newlength{\normalparindent}
|
||||||
% \setlength{\normalparindent}{\parindent}
|
% \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}{
|
\ifdefstring{\ELEGANT@mode}{fancy}{
|
||||||
\tcbset{
|
\tcbset{
|
||||||
common/.style={
|
common/.style={
|
||||||
@@ -962,14 +975,23 @@
|
|||||||
% will define two environments: numbered ``theorem'' and no-numbered ``theorem*''
|
% will define two environments: numbered ``theorem'' and no-numbered ``theorem*''
|
||||||
% WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition,
|
% WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition,
|
||||||
% WARNING FOR MULTILINGUAL: it should be defined in language settings.
|
% WARNING FOR MULTILINGUAL: it should be defined in language settings.
|
||||||
\newcommand{\ELEGANT@newtheorem}[3]{
|
\NewDocumentCommand \ELEGANT@newtheorem { m m m O{} }{
|
||||||
\ifcsundef{#1name}{%
|
\ifcsundef{#1name}{%
|
||||||
\ClassError{elegantbook}{%
|
\ClassError{elegantbook}{%
|
||||||
\ #1name undefined, \MessageBreak
|
\ #1name undefined, \MessageBreak
|
||||||
Please check in language setting
|
Please check in language setting
|
||||||
}{}
|
}{}
|
||||||
}{\relax}
|
}{\relax}
|
||||||
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt]{#1}{ g o t\label g }{
|
\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,
|
common,#3,
|
||||||
IfValueTF={##1}
|
IfValueTF={##1}
|
||||||
{ELEGANT@title={#1}{##1}}
|
{ELEGANT@title={#1}{##1}}
|
||||||
@@ -998,8 +1020,8 @@
|
|||||||
}
|
}
|
||||||
% define several environment
|
% define several environment
|
||||||
% we define headers like \definitionname before
|
% we define headers like \definitionname before
|
||||||
\ELEGANT@newtheorem{definition}{def}{defstyle}
|
|
||||||
\ELEGANT@newtheorem{theorem}{thm}{thmstyle}
|
\ELEGANT@newtheorem{theorem}{thm}{thmstyle}
|
||||||
|
\ELEGANT@newtheorem{definition}{def}{defstyle}
|
||||||
\ELEGANT@newtheorem{postulate}{pos}{thmstyle}
|
\ELEGANT@newtheorem{postulate}{pos}{thmstyle}
|
||||||
\ELEGANT@newtheorem{axiom}{axi}{thmstyle}
|
\ELEGANT@newtheorem{axiom}{axi}{thmstyle}
|
||||||
\ELEGANT@newtheorem{corollary}{cor}{thmstyle}
|
\ELEGANT@newtheorem{corollary}{cor}{thmstyle}
|
||||||
@@ -1030,16 +1052,24 @@
|
|||||||
% will define two environments: numbered ``theorem'' and no-numbered ``theorem*''
|
% will define two environments: numbered ``theorem'' and no-numbered ``theorem*''
|
||||||
% WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition,
|
% WARNING FOR MULTILINGUAL: this cs will automatically find \theoremname's definition,
|
||||||
% WARNING FOR MULTILINGUAL: it should be defined in language settings.
|
% WARNING FOR MULTILINGUAL: it should be defined in language settings.
|
||||||
\newcommand{\ELEGANT@newtheorem}[2]{
|
\NewDocumentCommand \ELEGANT@newtheorem { m m O{} } {
|
||||||
\theoremstyle{#2}
|
\theoremstyle{#2}
|
||||||
\newtheorem{#1}{\csname #1name\endcsname}[\ELEGANT@thmcnt]
|
\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}
|
\newtheorem*{#1*}{\csname #1name\endcsname}
|
||||||
}
|
}
|
||||||
|
|
||||||
% define several environment
|
% define several environment
|
||||||
% we define headers like \definitionname before
|
% we define headers like \definitionname before
|
||||||
\ELEGANT@newtheorem{definition}{defstyle}
|
|
||||||
\ELEGANT@newtheorem{theorem}{thmstyle}
|
\ELEGANT@newtheorem{theorem}{thmstyle}
|
||||||
|
\ELEGANT@newtheorem{definition}{defstyle}
|
||||||
\ELEGANT@newtheorem{postulate}{thmstyle}
|
\ELEGANT@newtheorem{postulate}{thmstyle}
|
||||||
\ELEGANT@newtheorem{axiom}{thmstyle}
|
\ELEGANT@newtheorem{axiom}{thmstyle}
|
||||||
\ELEGANT@newtheorem{corollary}{thmstyle}
|
\ELEGANT@newtheorem{corollary}{thmstyle}
|
||||||
@@ -1056,12 +1086,19 @@
|
|||||||
% and a warning will be raised
|
% and a warning will be raised
|
||||||
\newcommand{\ELEGANT@newtheorem@warning}{}
|
\newcommand{\ELEGANT@newtheorem@warning}{}
|
||||||
\newcommand{\ELEGANT@newtheorem@error}{}
|
\newcommand{\ELEGANT@newtheorem@error}{}
|
||||||
\NewDocumentCommand\elegantnewtheorem{ m m m g }
|
\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}{
|
\renewcommand{\ELEGANT@newtheorem@warning}{
|
||||||
\ClassWarning{elegantbook}{%
|
\ClassWarning{elegantbook}{%
|
||||||
Because you didn't provide a prefix. \MessageBreak
|
Because you didn't provide a prefix, \MessageBreak
|
||||||
We use #1 as the default prefix. \MessageBreak
|
we use #1 as the default prefix. \MessageBreak
|
||||||
You have to use \MessageBreak
|
You have to use \MessageBreak
|
||||||
\ref{#1:label} to refer a \MessageBreak
|
\ref{#1:label} to refer a \MessageBreak
|
||||||
\begin{#1}{name}{label} environment. \MessageBreak
|
\begin{#1}{name}{label} environment. \MessageBreak
|
||||||
@@ -1078,11 +1115,16 @@
|
|||||||
The 4th parameter ``prefix'' isn't allowed.
|
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}
|
\expandafter\def\csname #1name\endcsname{#2}
|
||||||
\ifdefstring{\ELEGANT@mode}{simple}{%
|
\ifdefstring{\ELEGANT@mode}{simple}{%
|
||||||
\IfValueTF{#4}
|
\IfValueTF{#4}
|
||||||
{\ELEGANT@newtheorem@error}
|
{\ELEGANT@newtheorem@error}
|
||||||
{\ELEGANT@newtheorem{#1}{#3}}
|
{\ELEGANT@newtheorem{#1}{#3}[\ELEGANT@tmp@tl]}
|
||||||
}{\relax}
|
}{\relax}
|
||||||
\ifdefstring{\ELEGANT@mode}{fancy}{%
|
\ifdefstring{\ELEGANT@mode}{fancy}{%
|
||||||
\IfValueTF{#4}
|
\IfValueTF{#4}
|
||||||
@@ -1090,13 +1132,13 @@
|
|||||||
\def\ELEGANT@temp@prefix{#4}
|
\def\ELEGANT@temp@prefix{#4}
|
||||||
\ifdefempty{\ELEGANT@temp@prefix}
|
\ifdefempty{\ELEGANT@temp@prefix}
|
||||||
{
|
{
|
||||||
\ELEGANT@newtheorem{#1}{#1}{#3}
|
\ELEGANT@newtheorem{#1}{#1}{#3}[\ELEGANT@tmp@tl]
|
||||||
\ELEGANT@newtheorem@warning
|
\ELEGANT@newtheorem@warning
|
||||||
}
|
}
|
||||||
{\ELEGANT@newtheorem{#1}{#4}{#3}}
|
{\ELEGANT@newtheorem{#1}{#4}{#3}[\ELEGANT@tmp@tl]}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
\ELEGANT@newtheorem{#1}{#1}{#3}
|
\ELEGANT@newtheorem{#1}{#1}{#3}[\ELEGANT@tmp@tl]
|
||||||
\ELEGANT@newtheorem@warning
|
\ELEGANT@newtheorem@warning
|
||||||
}
|
}
|
||||||
}{\relax}
|
}{\relax}
|
||||||
@@ -1323,7 +1365,7 @@
|
|||||||
commentstyle=\color{gray},
|
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},
|
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}},
|
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},
|
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,
|
frame=single,
|
||||||
tabsize=2,
|
tabsize=2,
|
||||||
rulecolor=\color{structurecolor},
|
rulecolor=\color{structurecolor},
|
||||||
|
|||||||
Reference in New Issue
Block a user