From d3f2148c4234c9171c165b439eb4676801464bea Mon Sep 17 00:00:00 2001
From: atXY <y-xiong22@mails.tsinghua.edu.cn>
Date: Sun, 7 May 2023 19:08:01 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AE=9A=E7=90=86?=
 =?UTF-8?q?=E7=B1=BB=E7=8E=AF=E5=A2=83=E5=85=B1=E4=BA=AB=E8=AE=A1=E6=95=B0?=
 =?UTF-8?q?=E5=99=A8=E9=80=89=E9=A1=B9=20(#206,#207)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGELOG.md             | 10 +++++
 docs/njuthesis-setup.def | 15 ++++----
 source/njuthesis.dtx     | 82 ++++++++++++++++++++++++++++++----------
 3 files changed, 80 insertions(+), 27 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f655f4..793522f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,14 @@
 
 ## [鏈彂甯僝
 
+### 鏂板
+
+- 鏂板瀹氱悊绫荤幆澧冨叡浜鏁板櫒閫夐」 `theorem/share-counter` - [#207]
+
+### 淇
+
+- 淇鎵归噺鍒涘缓鐜鏃剁己灏� `\crefname` 鐨勯棶棰� - [#206]
+
 ## [1.2.1] - 2023-05-03
 
 ### 淇
@@ -547,6 +555,8 @@
 [#200]: https://github.com/nju-lug/NJUThesis/discussions/200
 [#202]: https://github.com/nju-lug/NJUThesis/discussions/202
 [#204]: https://github.com/nju-lug/NJUThesis/issues/204
+[#206]: https://github.com/nju-lug/NJUThesis/issues/206
+[#207]: https://github.com/nju-lug/NJUThesis/issues/207
 
 [鏇存柊鏃ュ織]: https://keepachangelog.com/zh-CN/1.0.0/
 [璇箟鍖栫増鏈琞: https://semver.org/lang/zh-CN/
diff --git a/docs/njuthesis-setup.def b/docs/njuthesis-setup.def
index 548396d..5652b48 100644
--- a/docs/njuthesis-setup.def
+++ b/docs/njuthesis-setup.def
@@ -1,4 +1,4 @@
-% njuthesis 鍙傛暟璁剧疆鏂囦欢 v1.2.1 2023-05-03
+% njuthesis 鍙傛暟璁剧疆鏂囦欢 v1.3.0 2023-05-07
 
 % 涓€浜涙彁閱掞細
 %   1. \njusetup 鍐呴儴鍗冧竾涓嶈鏈夌┖琛�
@@ -214,12 +214,13 @@
     % define,
     % 榛樿鍒涘缓鍐呯疆鐨勪竷绉嶅畾鐞嗙幆澧�
     %
-    % style       = remark,
-    % header-font = \sffamily \bfseries,
-    % body-font   = \normalfont,
-    % qed-symbol  = \ensuremath { \male },
-    % counter     = section,
-    % type        = {...}
+    % style         = remark,
+    % header-font   = \sffamily \bfseries,
+    % body-font     = \normalfont,
+    % qed-symbol    = \ensuremath { \male },
+    % counter       = section,
+    % share-counter = true,
+    % type          = {...}
     % 浠ヤ笂璁剧疆椤瑰湪閲嶆柊璋冪敤 theorem/define 鍚庣敓鏁�
 }
 
diff --git a/source/njuthesis.dtx b/source/njuthesis.dtx
index 649ca35..17478a7 100644
--- a/source/njuthesis.dtx
+++ b/source/njuthesis.dtx
@@ -109,7 +109,7 @@ To produce the documentation run the original source files ending with
 %
 %<class>\NeedsTeXFormat{LaTeX2e}
 %<*!(driver|install)>
-%<+!driver>\GetIdInfo $Id: njuthesis.dtx 1.2.1 2023-05-03 13:30:00
+%<+!driver>\GetIdInfo $Id: njuthesis.dtx 1.3.0 2023-05-07 19:00:00
 %<+!driver>  +0800 NJU LUG <git+nju-lug-email-3104-issue-@yaoge123.cn>$
 %<class>  {Thesis template for Nanjing University}
 %<class>\ProvidesExplClass{njuthesis}
@@ -380,7 +380,7 @@ To produce the documentation run the original source files ending with
 %   \thanks{E-mail: \href{mailto:git+nju-lug-email-3104-issue-@yaoge123.cn}
 %     {git+nju-lug-email-3104-issue-@yaoge123.cn}}}
 %
-% \date{v1.2.1 \quad 2023-05-03}
+% \date{v1.3.0 \quad 2023-05-07}
 %
 % \maketitle
 %
@@ -1870,16 +1870,24 @@ To produce the documentation run the original source files ending with
 % 瀹氱悊璁℃暟鍣ㄨ寖鍥淬€�
 % \end{function}
 %
+% \begin{function}[added=2023-05-07]{theorem/share-counter}
+%   \begin{syntax}
+%     \OPT{share-counter} = <\TFF>
+%   \end{syntax}
+% 鏄惁鍏变韩璁℃暟鍣ㄣ€�
+% \end{function}
+%
 % 妯℃澘鐨勯粯璁よ缃瓑鏁堜簬
 %
 % \begin{latexexample}[moretexcs={\njusetup,\bfseries,\itshape,\mdlgwhtsquare},
 %   emph={[2]theorem},emph={[3]style,header-font,body-font,qed-symbol,counter}]
 %   \njusetup[theorem]{
-%       style       = plain,
-%       header-font = \normalfont \bfseries ,
-%       body-font   = \itshape ,
-%       qed-symbol  = \ensuremath { \mdlgwhtsquare },
-%       counter     = chapter
+%       style         = plain,
+%       header-font   = \normalfont \bfseries ,
+%       body-font     = \itshape ,
+%       qed-symbol    = \ensuremath { \mdlgwhtsquare },
+%       counter       = chapter,
+%       share-counter = false
 %   }
 % \end{latexexample}
 %
@@ -1926,12 +1934,14 @@ To produce the documentation run the original source files ending with
 % \opt{theorem/type} 淇濆瓨鐨勫垪琛ㄤ互鍙婂墠鏂圭殑鏍峰紡璁剧疆骞跺垱寤虹浉搴旂幆澧冦€�
 % 杩欎篃灏辨剰鍛崇潃璇ラ€夐」鍦� \opt{theorem/type} 涓虹┖鏃朵細鎶ラ敊銆�
 %
-% 鍦ㄤ笅闈㈣繖涓緥瀛愪腑锛屾垜浠厛鍒涘缓浜嗛缃殑涓冪鐜锛岄殢鍚庡皢瀹氱悊鍐呴儴鏂囧瓧瀛椾綋鏀逛负
+% 鍦ㄤ笅闈㈣繖涓緥瀛愪腑锛屾垜浠厛鍒涘缓浜嗛缃殑涓冪鐜銆傞櫎浜嗘棤缂栧彿鐨�
+% \env{proof}锛屽叾浣欏叚绉嶅叡鐢ㄤ竴涓鏁板櫒銆傞殢鍚庢垜浠皢瀹氱悊鍐呴儴鏂囧瓧瀛椾綋鏀逛负
 % 瀹嬩綋锛屽畾涔変簡 \env{exercise} 鍜� \env{solution} 涓ょ瀹氱悊鐜锛屽悗鑰呮病鏈夌紪鍙枫€�
 %
 % \begin{latexexample}[moretexcs={\njusetup,\normalfont},
 %   emph={[2]theorem},emph={[3]define,body-font,type}]
 %   \njusetup[theorem]{
+%       share-counter = true ,
 %       define ,
 %       body-font   = \normalfont ,
 %       type        = {
@@ -6143,6 +6153,13 @@ To produce the documentation run the original source files ending with
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\l_@@_thm_share_tl}
+% 瀛樺偍鍏变韩鐨勮鏁板櫒鍚嶇О銆�
+%    \begin{macrocode}
+\tl_new:N \l_@@_thm_share_tl
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 \keys_define:nn { nju / theorem }
   {
@@ -6185,6 +6202,15 @@ To produce the documentation run the original source files ending with
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{theorem/share-counter}
+% \changes{v1.3}{2023/05/07}{鎵归噺鍒涘缓瀹氱悊绫荤幆澧冩椂鍙互鍏变韩璁℃暟鍣ㄣ€倉
+% 鏄惁鍦ㄥ垎缁勫唴浣跨敤鍚屼竴璁℃暟鍣ㄣ€�
+%    \begin{macrocode}
+    share-counter .bool_set:N = \l_@@_thm_share_bool,
+    share-counter  .initial:n = false,
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{theorem/define}
 % 鍒涘缓瀹氱悊绫荤幆澧冦€�
 %    \begin{macrocode}
@@ -6193,21 +6219,22 @@ To produce the documentation run the original source files ending with
       {
         \clist_if_empty:NT \g_@@_thm_type_clist
           { \msg_error:nn { njuthesis } { empty-theorem-type } }
+        \tl_clear:N \l_@@_thm_share_tl
         \clist_map_inline:Nn \g_@@_thm_type_clist
-          { \@@_thm_define:nn ##1 }
+          { \@@_thm_define:Nnn \l_@@_thm_share_tl ##1 }
       }
   }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_thm_define:nn}
+% \begin{macro}{\@@_thm_define:Nnn}
 % 閰嶇疆瀹氱悊鐜銆�
 % \begin{arguments}
 %   \item 鐜鍚嶄笌绫诲瀷鏍囪瘑锛寍clist| 鍨嬪彉閲�
 %   \item 瀹氱悊澶村悕绉�
 % \end{arguments}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_thm_define:nn #1#2
+\cs_new_protected:Npn \@@_thm_define:Nnn #1#2#3
   {
     \bool_if:NF \g_@@_opt_load_nthm_bool
       { \msg_error:nn { njuthesis } { missing-ntheorem } }
@@ -6218,7 +6245,7 @@ To produce the documentation run the original source files ending with
 % 鎷嗗垎鐜鍚嶄笌绫诲瀷鏍囪瘑銆傝繖閲屾槸鑰冭檻鍒版爣璇嗙涓嶄竴瀹氬嚭鐜板湪鐜鍚嶄腑锛�
 % 鍏稿瀷濡� \env{proof} 鐜榛樿鏃犵紪鍙蜂絾涔熶笉鍚槦鍙枫€�
 %    \begin{macrocode}
-    \clist_set:Nn \l_@@_tmp_clist { #1 }
+    \clist_set:Nn \l_@@_tmp_clist { #2 }
     \clist_pop:NN \l_@@_tmp_clist \l_@@_tmpa_tl
     \clist_pop:NN \l_@@_tmp_clist \l_@@_tmpb_tl
 %    \end{macrocode}
@@ -6227,10 +6254,21 @@ To produce the documentation run the original source files ending with
     \tl_if_in:NnT  \l_@@_tmpb_tl { + }
       { \exp_args:NV \theoremsymbol \l_@@_thm_qed_symbol_tl }
     \tl_if_in:NnTF \l_@@_tmpb_tl { * }
-      { \@@_thm_new:VVn \l_@@_tmpa_tl \c_novalue_tl        {#2} }
-      { \@@_thm_new:VVn \l_@@_tmpa_tl \l_@@_thm_counter_tl {#2} }
+      { \@@_thm_new:VVVn \l_@@_tmpa_tl \c_novalue_tl        #1 {#3} }
+      { \@@_thm_new:VVVn \l_@@_tmpa_tl \l_@@_thm_counter_tl #1 {#3} }
+%    \end{macrocode}
+% 瀛樺偍鍏变韩鐨勮鏁板櫒銆�
+%    \begin{macrocode}
+    \bool_if:NT \l_@@_thm_share_bool
+      {
+        \tl_gset_eq:NN #1 \l_@@_tmpa_tl
+        \bool_gset_false:N \l_@@_thm_share_bool
+      }
+%    \end{macrocode}
+% 璁剧疆 \pkg{cleveref} 寮曠敤鍚嶃€�
+%    \begin{macrocode}
     \bool_if:NT \g_@@_opt_load_cref_bool
-      { \crefname { \l_@@_tmpa_tl } {#2} {#2} }
+      { \exp_args:NV \crefname \l_@@_tmpa_tl {#3} {#3} }
 %    \end{macrocode}
 % 娓呴櫎淇濆瓨鐨勮瘉姣曠鍙枫€�
 %    \begin{macrocode}
@@ -6239,7 +6277,7 @@ To produce the documentation run the original source files ending with
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_thm_new:nnn,\@@_thm_new:VVn}
+% \begin{macro}{\@@_thm_new:nnnn,\@@_thm_new:VVVn}
 % 鍖呰 \tn{newtheorem} 浠ヤ究灞曞紑杈撳叆鐨勫彉閲忋€傛牴鎹� \file{interface3.pdf}
 % 鎵嬪唽 5.3 鑺傛渶鍚庝竴娈靛缓璁殑灞曞紑椤哄簭锛岃繖閲屽皢 |V| 鍨嬪弬鏁版斁鍦ㄩ潬鍓嶇殑浣嶇疆銆�
 % \begin{arguments}
@@ -6250,17 +6288,21 @@ To produce the documentation run the original source files ending with
 % 鏍规嵁鐜缁撴潫鍛戒护鏄惁瀛樺湪鍙互鍒ゆ柇璇ョ幆澧冩槸鍚︽湁瀹氫箟锛�
 % 鐩稿簲鍦板彲浠ュ埄鐢ㄥ眬閮ㄥ畾涔夊垏鎹㈠畾涔夊拰閲嶅畾涔夌幆澧冪殑鍛戒护銆�
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_thm_new:nnn #1#2#3
+\cs_new_protected:Npn \@@_thm_new:nnnn #1#2#3#4
   {
     \group_begin:
       \cs_if_exist:cT { end #1 }
         { \cs_set_eq:NN \newtheorem \renewtheorem }
       \tl_if_novalue:nTF {#2}
-        { \newtheorem * {#1} {#3}      }
-        { \newtheorem   {#1} {#3} [#2] }
+        { \newtheorem * {#1} {#4} }
+        {
+          \tl_if_empty:nTF {#3}
+            { \newtheorem {#1}      {#4} [#2] }
+            { \newtheorem {#1} [#3] {#4}      }
+        }
     \group_end:
   }
-\cs_generate_variant:Nn \@@_thm_new:nnn { VVn }
+\cs_generate_variant:Nn \@@_thm_new:nnnn { VVVn }
 %    \end{macrocode}
 % \end{macro}
 %
-- 
GitLab