texlive[61470] Master/texmf-dist: codebox (2jan22)

commits+karl at tug.org commits+karl at tug.org
Sun Jan 2 22:04:53 CET 2022


Revision: 61470
          http://tug.org/svn/texlive?view=revision&revision=61470
Author:   karl
Date:     2022-01-02 22:04:52 +0100 (Sun, 02 Jan 2022)
Log Message:
-----------
codebox (2jan22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf
    trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx
    trunk/Master/texmf-dist/doc/latex/codebox/codebox.pdf
    trunk/Master/texmf-dist/tex/latex/codebox/codebox.sty

Modified: trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx	2022-01-02 21:04:39 UTC (rev 61469)
+++ trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx	2022-01-02 21:04:52 UTC (rev 61470)
@@ -148,7 +148,7 @@
 %</internal>
 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
 %<package>\RequirePackage{expl3}
-%<+package>\GetIdInfo$Id: codebox.dtx 1.0.1 2021-12-27 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+%<+package>\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
 %<package>  {Code Box with tcolorbox and minted/listings.}
 %<package>\ProvidesExplPackage{\ExplFileName}
 %<package>  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -180,7 +180,7 @@
 %
 % \changes{v1.0.0}{2021/12/25}{开始编写模板}
 %
-% \CheckSum{286}
+% \CheckSum{295}
 % \GetFileId{codebox.sty}
 %
 % \CharacterTable
@@ -411,9 +411,9 @@
 %
 % \begin{function}[added=2021-12-26,updated=2021-12-26]{lang}
 %   \begin{syntax}
-%     lang = \Arg{代码语言} \init{C}
+%     lang = \Arg{代码语言} \init{c}
 %   \end{syntax}
-%   \opt{lang} 用于设置代码语言,默认值为\textbf{C语言}。
+%   \opt{lang} 用于设置代码语言,默认值为\textbf{c语言}。
 % \end{function}
 %
 % \subsection{代码名称}
@@ -485,6 +485,21 @@
 %   引擎有效,取浮点数,单位是mm。默认值为\textbf{3.0}。
 % \end{function}
 %
+% \changes{v1.0.2}{2021/12/28}{添加cvcounter使用说明}
+%
+% \section{计数器}
+%
+% \begin{function}[added=2021-12-28,updated=2021-12-28]{cvcounter}
+%   \pkg{codebox}宏包提供了一个计数器\texttt{cvcounter},
+%   当使用带编号环境\env{codeview}/\env{codeview*}和
+%   命令\tn{cvfile}/\tn{cvfile*}排版代码时,可以用于对代码盒子进行计数。
+%   默认情况下,如果存在\texttt{thechapter}计数器,则其父计数器设置为\texttt{chapter}
+%   否则将按全文统一计数。
+%
+%   可以使用类似\tn{renewcommand\{\tn{thecvcounter}\}\{\tn{thechapter.\tn{arabic\{cvcounter\}}}\}}
+%   的形式更改编号输出内容。
+% \end{function}
+%
 % \newpage
 % \section{排版样例}
 %
@@ -770,10 +785,10 @@
 % \end{macro}
 %
 % \begin{macro}{lang}
-% 设置排版代码语言,默认为C。
+% 设置排版代码语言,默认为c。
 %    \begin{macrocode}
     lang .tl_set:N = \l_@@_language_tl,
-    lang .initial:n = C,
+    lang .initial:n = c,
 %    \end{macrocode}
 % \end{macro}
 %
@@ -856,6 +871,8 @@
 %
 % \subsection{内部函数}
 %
+% \changes{v1.0.2}{2022/1/2}{修改按章编号时cvcounter的编号方式}
+%
 % \begin{macro}{\@@_set_counter_parent:}
 %
 % 设置代码编号计数器的父计数器。
@@ -865,9 +882,10 @@
   {
     \ifdef{\thechapter}
       {
-        \newcounter{codecounter}[chapter]%
+        \newcounter{cvcounter}[chapter]%
+        \renewcommand{\thecvcounter}{\thechapter.\arabic{cvcounter}}
       }{
-        \newcounter{codecounter}%[section]%
+        \newcounter{cvcounter}%[section]%
       }
   }
 %    \end{macrocode}
@@ -874,56 +892,79 @@
 % \end{macro}
 %
 % \changes{v1.0.1}{2021/12/26}{调整minted style选项为参数实现}
+% \changes{v1.0.2}{2021/12/28}{将minted/listings的参数设置独立为函数}
 %
-% \begin{macro}{\@@_code_engine_tcbset:}
+% \begin{macro}{\@@_minted_engine_tcbset:n #1}
 % 设置代码盒子minted宏包参数。
 %
 %    \begin{macrocode}
-\cs_new:Npn \@@_code_engine_tcbset:n #1
+\cs_new:Npn \@@_minted_engine_tcbset:n #1
   {
+    \tcbset{
+      listing~engine=minted,%
+      minted~style=#1,
+      minted~options={%
+        autogobble,
+        breaklines,%
+        fontsize=\tl_use:N \l_@@_code_fontsize_tl,%
+        baselinestretch=\fp_eval:n { \l_@@_baseline_stretch_fp },
+        breaksymbolleft={},%
+        linenos,%
+        numbersep=\fp_eval:n { \l_@@_linenumber_sep_fp }~mm,
+      },%
+      minted~language=\tl_use:N \l_@@_language_tl%
+    }
+  }
+\cs_generate_variant:Nn \@@_minted_engine_tcbset:n {V}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_listings_engine_tcbset:}
+% 设置代码盒子listings宏包参数。
+%
+%    \begin{macrocode}
+\cs_new:Npn \@@_listings_engine_tcbset:
+  {
+    \lstset{% general command to set parameter(s)
+      basicstyle=\ttfamily\tl_use:N \l_@@_code_fontsize_tl, % print whole listing small
+      keywordstyle=\color{chengse}\bfseries,%
+      identifierstyle=, % nothing happens
+      breaklines=true,
+      commentstyle=\itshape\color{gray},
+      stringstyle=\ttfamily, % typewriter type for strings
+      numbers=left,%
+      numberstyle=\tl_use:N \l_@@_code_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},%
+    }%
+    \tcbset{
+      overlay={%
+        \begin{tcbclipinterior}
+          \fill[tcbcolback!80!black] (frame.south~west) rectangle
+                                     ([xshift=5mm]frame.north~west);
+        \end{tcbclipinterior}%
+      },%
+      listing~options={
+        language=\tl_use:N \l_@@_language_tl,
+        numbersep=\fp_eval:n { \l_@@_linenumber_sep_fp }~mm,
+        %linebackgroundcolor={\ifodd\value{lstnumber}\color{cvgray}\fi}
+      }
+    }%
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_code_engine_tcbset:}
+% 设置代码盒子引擎宏包参数。
+%
+%    \begin{macrocode}
+\cs_new:Npn \@@_code_engine_tcbset:
+  {
     \bool_if:NTF \l_@@_minted_bool
       {
-        \tcbset{
-          listing~engine=minted,%
-          minted~style=#1,
-          minted~options={%
-            autogobble,
-            breaklines,%
-            fontsize=\tl_use:N \l_@@_code_fontsize_tl,%
-            baselinestretch=\fp_eval:n { \l_@@_baseline_stretch_fp },
-            breaksymbolleft={},%
-            linenos,%
-            numbersep=\fp_eval:n { \l_@@_linenumber_sep_fp }~mm,
-          },%
-          minted~language=\tl_use:N \l_@@_language_tl%
-        }
-       }{
-          \lstset{% general command to set parameter(s)
-            basicstyle=\ttfamily\tl_use:N \l_@@_code_fontsize_tl, % print whole listing small
-            keywordstyle=\color{chengse}\bfseries,%
-            identifierstyle=, % nothing happens
-            breaklines=true,
-            commentstyle=\itshape\color{gray},
-            stringstyle=\ttfamily, % typewriter type for strings
-            numbers=left,%
-            numberstyle=\tl_use:N \l_@@_code_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},%
-          }%
-          \tcbset{
-              overlay={%
-                \begin{tcbclipinterior}
-                  \fill[tcbcolback!80!black] (frame.south~west) rectangle
-                                             ([xshift=5mm]frame.north~west);
-                \end{tcbclipinterior}%
-              },%
-              listing~options={
-                language=\tl_use:N \l_@@_language_tl,
-                numbersep=\fp_eval:n { \l_@@_linenumber_sep_fp }~mm,
-                %linebackgroundcolor={\ifodd\value{lstnumber}\color{cvgray}\fi}
-              }
-            }%
-        }
+        \@@_minted_engine_tcbset:V \l_@@_code_style_tl
+      }{
+        \@@_listings_engine_tcbset:
+      }
   }
-\cs_generate_variant:Nn \@@_code_engine_tcbset:n {V}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -961,7 +1002,7 @@
     \bool_set_false:N  \l_@@_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{lang, title={#2} }%
     \tcblisting{}
@@ -979,7 +1020,7 @@
     \bool_set_false:N  \l_@@_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{lang, title={#2} }%
     \tcblisting{}
@@ -1003,7 +1044,7 @@
 
     \group_begin:
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{
       lang,
@@ -1023,12 +1064,14 @@
 \@@_set_counter_parent:
 %    \end{macrocode}
 %
+% \changes{v1.0.2}{2021/12/28}{为计数器两端添加\tn{nobreakspace}}
+%
 %  定义不带底线注释的代码盒子环境\env{codeview}
 %
 %    \begin{macrocode}
-\DeclareTCBListing[use~counter=codecounter]{codeviewaux}{m}
+\DeclareTCBListing[use~counter=cvcounter]{codeviewaux}{m}
   {
-    title={\tl_use:N \l_@@_code_name_tl\thecodecounter~#1},
+    title={\tl_use:N \l_@@_code_name_tl\nobreakspace\thecvcounter\nobreakspace~#1},
   }
 \NewDocumentEnvironment{ codeview }{O{} m }
   {
@@ -1035,7 +1078,7 @@
     \bool_set_false:N  \l_@@_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{
       cv,
@@ -1064,7 +1107,7 @@
     \bool_set_true:N  \l_@@_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{
       cv,
@@ -1088,9 +1131,9 @@
 %  定义带/不带底线注释的从文件读取内容的命令\tn{cvfile}/\tn{cvfile*}
 %
 %    \begin{macrocode}
-\DeclareTCBInputListing[use~counter=codecounter]{\langfileaux}{m}
+\DeclareTCBInputListing[use~counter=cvcounter]{\langfileaux}{m}
   {
-    title={\tl_use:N \l_@@_code_name_tl\thecodecounter~#1},
+    title={\tl_use:N \l_@@_code_name_tl\nobreakspace\thecvcounter\nobreakspace~#1},
   }
 \NewDocumentCommand \cvfile { s O{} m m }
   {
@@ -1103,7 +1146,7 @@
 
     \group_begin:
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
-    \@@_code_engine_tcbset:V \l_@@_code_style_tl
+    \@@_code_engine_tcbset:
     \@@_comment_tcbset:
     \tcbset{
       cv,

Modified: trunk/Master/texmf-dist/doc/latex/codebox/codebox.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/latex/codebox/codebox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/codebox/codebox.sty	2022-01-02 21:04:39 UTC (rev 61469)
+++ trunk/Master/texmf-dist/tex/latex/codebox/codebox.sty	2022-01-02 21:04:52 UTC (rev 61470)
@@ -27,7 +27,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
 \RequirePackage{expl3}
-\GetIdInfo$Id: codebox.dtx 1.0.1 2021-12-27 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
   {Code Box with tcolorbox and minted/listings.}
 \ProvidesExplPackage{\ExplFileName}
   {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -153,7 +153,7 @@
     minted .default:n = true,
     minted .initial:n = true,
     lang .tl_set:N = \l__codebox_language_tl,
-    lang .initial:n = C,
+    lang .initial:n = c,
     pretitle .tl_set:N = \l__codebox_code_name_tl,
     pretitle .initial:n = Code,
     codestyle .tl_set:N = \l__codebox_code_style_tl,
@@ -179,56 +179,65 @@
   {
     \ifdef{\thechapter}
       {
-        \newcounter{codecounter}[chapter]%
+        \newcounter{cvcounter}[chapter]%
+        \renewcommand{\thecvcounter}{\thechapter.\arabic{cvcounter}}
       }{
-        \newcounter{codecounter}%[section]%
+        \newcounter{cvcounter}%[section]%
       }
   }
-\cs_new:Npn \__codebox_code_engine_tcbset:n #1
+\cs_new:Npn \__codebox_minted_engine_tcbset:n #1
   {
+    \tcbset{
+      listing~engine=minted,%
+      minted~style=#1,
+      minted~options={%
+        autogobble,
+        breaklines,%
+        fontsize=\tl_use:N \l__codebox_code_fontsize_tl,%
+        baselinestretch=\fp_eval:n { \l__codebox_baseline_stretch_fp },
+        breaksymbolleft={},%
+        linenos,%
+        numbersep=\fp_eval:n { \l__codebox_linenumber_sep_fp }~mm,
+      },%
+      minted~language=\tl_use:N \l__codebox_language_tl%
+    }
+  }
+\cs_generate_variant:Nn \__codebox_minted_engine_tcbset:n {V}
+\cs_new:Npn \__codebox_listings_engine_tcbset:
+  {
+    \lstset{% general command to set parameter(s)
+      basicstyle=\ttfamily\tl_use:N \l__codebox_code_fontsize_tl, % print whole listing small
+      keywordstyle=\color{chengse}\bfseries,%
+      identifierstyle=, % nothing happens
+      breaklines=true,
+      commentstyle=\itshape\color{gray},
+      stringstyle=\ttfamily, % typewriter type for strings
+      numbers=left,%
+      numberstyle=\tl_use:N \l__codebox_code_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},%
+    }%
+    \tcbset{
+      overlay={%
+        \begin{tcbclipinterior}
+          \fill[tcbcolback!80!black] (frame.south~west) rectangle
+                                     ([xshift=5mm]frame.north~west);
+        \end{tcbclipinterior}%
+      },%
+      listing~options={
+        language=\tl_use:N \l__codebox_language_tl,
+        numbersep=\fp_eval:n { \l__codebox_linenumber_sep_fp }~mm,
+        %linebackgroundcolor={\ifodd\value{lstnumber}\color{cvgray}\fi}
+      }
+    }%
+  }
+\cs_new:Npn \__codebox_code_engine_tcbset:
+  {
     \bool_if:NTF \l__codebox_minted_bool
       {
-        \tcbset{
-          listing~engine=minted,%
-          minted~style=#1,
-          minted~options={%
-            autogobble,
-            breaklines,%
-            fontsize=\tl_use:N \l__codebox_code_fontsize_tl,%
-            baselinestretch=\fp_eval:n { \l__codebox_baseline_stretch_fp },
-            breaksymbolleft={},%
-            linenos,%
-            numbersep=\fp_eval:n { \l__codebox_linenumber_sep_fp }~mm,
-          },%
-          minted~language=\tl_use:N \l__codebox_language_tl%
-        }
-       }{
-          \lstset{% general command to set parameter(s)
-            basicstyle=\ttfamily\tl_use:N \l__codebox_code_fontsize_tl, % print whole listing small
-            keywordstyle=\color{chengse}\bfseries,%
-            identifierstyle=, % nothing happens
-            breaklines=true,
-            commentstyle=\itshape\color{gray},
-            stringstyle=\ttfamily, % typewriter type for strings
-            numbers=left,%
-            numberstyle=\tl_use:N \l__codebox_code_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},%
-          }%
-          \tcbset{
-              overlay={%
-                \begin{tcbclipinterior}
-                  \fill[tcbcolback!80!black] (frame.south~west) rectangle
-                                             ([xshift=5mm]frame.north~west);
-                \end{tcbclipinterior}%
-              },%
-              listing~options={
-                language=\tl_use:N \l__codebox_language_tl,
-                numbersep=\fp_eval:n { \l__codebox_linenumber_sep_fp }~mm,
-                %linebackgroundcolor={\ifodd\value{lstnumber}\color{cvgray}\fi}
-              }
-            }%
-        }
+        \__codebox_minted_engine_tcbset:V \l__codebox_code_style_tl
+      }{
+        \__codebox_listings_engine_tcbset:
+      }
   }
-\cs_generate_variant:Nn \__codebox_code_engine_tcbset:n {V}
 \cs_new:Npn \__codebox_comment_tcbset:
   {
     \bool_if:NTF { \l__codebox_comment_bool }
@@ -249,7 +258,7 @@
     \bool_set_false:N  \l__codebox_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{lang, title={#2} }%
     \tcblisting{}
@@ -262,7 +271,7 @@
     \bool_set_false:N  \l__codebox_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{lang, title={#2} }%
     \tcblisting{}
@@ -281,7 +290,7 @@
 
     \group_begin:
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{
       lang,
@@ -292,9 +301,9 @@
     \group_end:
   }
 \__codebox_set_counter_parent:
-\DeclareTCBListing[use~counter=codecounter]{codeviewaux}{m}
+\DeclareTCBListing[use~counter=cvcounter]{codeviewaux}{m}
   {
-    title={\tl_use:N \l__codebox_code_name_tl\thecodecounter~#1},
+    title={\tl_use:N \l__codebox_code_name_tl\nobreakspace\thecvcounter\nobreakspace~#1},
   }
 \NewDocumentEnvironment{ codeview }{O{} m }
   {
@@ -301,7 +310,7 @@
     \bool_set_false:N  \l__codebox_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{
       cv,
@@ -325,7 +334,7 @@
     \bool_set_true:N  \l__codebox_comment_bool
     \group_begin:
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{
       cv,
@@ -344,9 +353,9 @@
     \endcodeviewaux
     \group_end:
   }
-\DeclareTCBInputListing[use~counter=codecounter]{\langfileaux}{m}
+\DeclareTCBInputListing[use~counter=cvcounter]{\langfileaux}{m}
   {
-    title={\tl_use:N \l__codebox_code_name_tl\thecodecounter~#1},
+    title={\tl_use:N \l__codebox_code_name_tl\nobreakspace\thecvcounter\nobreakspace~#1},
   }
 \NewDocumentCommand \cvfile { s O{} m m }
   {
@@ -359,7 +368,7 @@
 
     \group_begin:
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
-    \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl
+    \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
     \tcbset{
       cv,



More information about the tex-live-commits mailing list.