texlive[61502] Master/texmf-dist: codebox (6jan22)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 6 01:21:09 CET 2022


Revision: 61502
          http://tug.org/svn/texlive?view=revision&revision=61502
Author:   karl
Date:     2022-01-06 01:21:08 +0100 (Thu, 06 Jan 2022)
Log Message:
-----------
codebox (6jan22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/codebox/README.md
    trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf
    trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex
    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/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codebox/README.md	2022-01-06 00:20:54 UTC (rev 61501)
+++ trunk/Master/texmf-dist/doc/latex/codebox/README.md	2022-01-06 00:21:08 UTC (rev 61502)
@@ -43,7 +43,7 @@
 Copyright and Licence
 ---------------------
 
-    Copyright (C) 2020-2021 by Nan Geng <nangeng at nwafu.edu.cn>
+    Copyright (C) 2020-2022 by Nan Geng <nangeng at nwafu.edu.cn>
     ----------------------------------------------------------------------
 
     This work may be distributed and/or modified under the

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

Modified: trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex	2022-01-06 00:20:54 UTC (rev 61501)
+++ trunk/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex	2022-01-06 00:21:08 UTC (rev 61502)
@@ -5,7 +5,7 @@
 \usepackage{xcolor-material}
 \usepackage{codebox}
 
-\renewcommand{\thecodecounter}{\thesection.\arabic{codecounter}}
+% \renewcommand{\thecvcounter}{\thesection.\arabic{cvcounter}}
 \NewDocumentCommand{\init}{+v}{\hspace{\fill}Init~=~\textcolor{blue}{\bfseries#1}}
 \DeclareDocumentCommand\opt{m}{\texttt{#1}}
 \DeclareDocumentCommand\kvopt{mm}
@@ -14,7 +14,7 @@
 
 \title{\bfseries\pkg{codebox}:programming code box}
 \author{Nan Geng\\ \url{nangeng at nwafu.edu.cn}}
-\date{2021/12/26\qquad v1.0.0\thanks{\url{https://github.com/registor/codebox}}
+\date{2022/01/04\qquad v1.0.3\thanks{\url{https://github.com/registor/codebox}}
 \thanks{\url{https://gitee.com/nwafu_nan/codebox}}}
 
 \begin{document}
@@ -322,6 +322,32 @@
   The default is\textbf{3.0}.
 \end{function}
 
+\subsection{label}
+
+\begin{function}[added=2022-1-4,updated=2022-1-4]{label}
+  \begin{syntax}
+    label = \Arg{label name} \init{nothing}
+  \end{syntax}
+  \opt{label} is used to set \tn{ref} 's label name,
+  it is for \env{codeview}/\env{codeview*} and \tn{cvfile}/\tn{cvfile*}.
+  The default is \textbf{nothing}.
+\end{function}
+
+\section{The counter}
+
+\begin{function}[added=2021-12-28,updated=2021-12-28]{cvconuter}
+  The \pkg{codebox} package provides a \texttt{cvcounter} counter 
+  that can be used to count code boxes with environment \env{codeview}/\env{codeview*}
+  and the command \tn{cvfile}/\tn{cvfile*}. 
+
+  By default, if \tn{thechapter} exists, its parent counter is set to \textbf{chapter}
+  otherwise it will be counted uniformly by full text. 
+
+  You can use
+  \tn{renewcommand\{\tn{thecvcounter}\}\{\tn{thechapter.\tn{arabic\{cvcounter\}}}\}}
+  or something like this macro to change the numbered output.
+\end{function}
+
 \section{Examples}
 
 The \pkg{codebox} package can be used in situations
@@ -348,16 +374,17 @@
 \end{center}
 
 \subsection{Python code}
-The language can be set with \opt{options}.
+The language can be set with \opt{options}, of course you can label and ref it
+such as code \ref{code-test}.
 
 \begin{Verbatim}[frame=none,numbers=left,gobble=2]
   \centering
-  \cvfile[lang=python]{Python CodeBox}{hellopy.py}
+  \cvfile[lang=python,label=code-test]{Python CodeBox}{hellopy.py}
 \end{Verbatim}
 
 \begin{center}
   \begin{minipage}{0.85\textwidth}
-    \cvfile[lang=python]{Python CodeBox}{hellopy.py}
+    \cvfile[lang=python,label=code-test]{Python CodeBox}{hellopy.py}
   \end{minipage}
 \end{center}
 

Modified: trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx	2022-01-06 00:20:54 UTC (rev 61501)
+++ trunk/Master/texmf-dist/doc/latex/codebox/codebox.dtx	2022-01-06 00:21:08 UTC (rev 61502)
@@ -49,7 +49,7 @@
 Copyright and Licence
 ---------------------
 
-    Copyright (C) 2020-2021 by Nan Geng <nangeng at nwafu.edu.cn>
+    Copyright (C) 2020-2022 by Nan Geng <nangeng at nwafu.edu.cn>
     ----------------------------------------------------------------------
 
     This work may be distributed and/or modified under the
@@ -88,7 +88,7 @@
 
 \preamble
 
-    Copyright (C) 2020-2021 by Nan Geng <nangeng at nwafu.edu.cn>
+    Copyright (C) 2020-2022 by Nan Geng <nangeng at nwafu.edu.cn>
 --------------------------------------------------------------------------
 
     This work may be distributed and/or modified under the
@@ -148,7 +148,7 @@
 %</internal>
 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
 %<package>\RequirePackage{expl3}
-%<+package>\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+%<+package>\GetIdInfo$Id: codebox.dtx 1.0.3 2022-01-04 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{295}
+% \CheckSum{313}
 % \GetFileId{codebox.sty}
 %
 % \CharacterTable
@@ -485,6 +485,20 @@
 %   引擎有效,取浮点数,单位是mm。默认值为\textbf{3.0}。
 % \end{function}
 %
+% \changes{v1.0.3}{2022/1/4}{添加label引用标签选项的使用说明}
+%
+% \subsection{引用标签}
+%
+% \begin{function}[added=2022-1-4,updated=2022-1-4]{label}
+%   \begin{syntax}
+%     label = \Arg{引用标签名称} \init{空}
+%   \end{syntax}
+%   \opt{label} 用于设置带编号代码盒子的引用标签,
+%   该选项仅对\env{codeview}/\env{codeview*}环境
+%   或\tn{cvfile}/\tn{cvfile*}命令有效。
+%   默认值为\textbf{空}。
+% \end{function}
+%
 % \changes{v1.0.2}{2021/12/28}{添加cvcounter使用说明}
 %
 % \section{计数器}
@@ -524,15 +538,17 @@
 %
 % \subsection{Python代码}
 % 还可以使用环境或命令的\oarg{外观选项}设置代码语言。
+% 当然,也可以通过使用\opt{label}选项为编号代码添加引用标签,
+% 并通过\tn{ref}命令引用该标签,如代码\ref{code-test}所示。
 %
 %   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
 %     \centering
-%     \cvfile[lang=python]{Python代码示例}{hellopy.py}
+%     \cvfile[lang=python,label=code-test]{Python代码示例}{hellopy.py}
 %   \end{Verbatim}
 %
 %   \begin{center}
 % %     \begin{minipage}{0.85\textwidth}
-%       \cvfile[lang=python]{Python代码示例}{hellopy.py}
+%       \cvfile[lang=python,label=code-test]{Python代码示例}{hellopy.py}
 %     \end{minipage}
 %   \end{center}
 %
@@ -747,11 +763,14 @@
 % \l_@@_code_name_tl,
 % \l_@@_comment_contents_tl,
 % \l_@@_comment_format_tl,
+% \l_@@_label_name_tl,
 % \l_@@_baseline_stretch_fp,
 % \l_@@_linenumber_sep_fp
 %  }
 % 定义变量。
 %
+% \changes{v1.0.3}{2022/1/4}{增加\tn{\_@@_label_name_tl}变量}
+%
 %    \begin{macrocode}
 \bool_new:N   \l_@@_minted_bool
 \bool_new:N   \l_@@_comment_bool
@@ -762,6 +781,7 @@
 \tl_new:N     \l_@@_code_name_tl
 \tl_new:N     \l_@@_comment_contents_tl
 \tl_new:N     \l_@@_comment_format_tl
+\tl_new:N     \l_@@_label_name_tl
 \fp_new:N     \l_@@_baseline_stretch_fp
 \fp_new:N     \l_@@_linenumber_sep_fp
 %    \end{macrocode}
@@ -849,6 +869,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v1.0.3}{2022/1/4}{增加引用标签label选项}
+%
+% \begin{macro}{label}
+% 注释格式
+%    \begin{macrocode}
+    label .tl_set:N = \l_@@_label_name_tl,
+    label .initial:n = {},
+%    \end{macrocode}
+% \end{macro}
+%
 % 处理未知选项。
 %    \begin{macrocode}
     unknown .code:n = { \@@_error:n { unknown-option } }
@@ -1065,6 +1095,7 @@
 %    \end{macrocode}
 %
 % \changes{v1.0.2}{2021/12/28}{为计数器两端添加\tn{nobreakspace}}
+% \changes{v1.0.3}{2022/1/4}{为带编号代码盒子添加引用标签选项}
 %
 %  定义不带底线注释的代码盒子环境\env{codeview}
 %
@@ -1080,6 +1111,12 @@
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
     \@@_code_engine_tcbset:
     \@@_comment_tcbset:
+    \tl_if_empty:NF \l_@@_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l_@@_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       overlay~unbroken~and~first ={
@@ -1099,6 +1136,7 @@
   }
 %    \end{macrocode}
 %
+%
 %  定义带底线注释的代码盒子环境\env{codeview*}
 %
 %    \begin{macrocode}
@@ -1109,6 +1147,12 @@
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
     \@@_code_engine_tcbset:
     \@@_comment_tcbset:
+    \tl_if_empty:NF \l_@@_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l_@@_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       overlay~unbroken~and~first ={
@@ -1148,6 +1192,12 @@
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
     \@@_code_engine_tcbset:
     \@@_comment_tcbset:
+    \tl_if_empty:NF \l_@@_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l_@@_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       listing~file={#4},

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-06 00:20:54 UTC (rev 61501)
+++ trunk/Master/texmf-dist/tex/latex/codebox/codebox.sty	2022-01-06 00:21:08 UTC (rev 61502)
@@ -6,7 +6,7 @@
 %%
 %% codebox.dtx  (with options: `package')
 %% 
-%%     Copyright (C) 2020-2021 by Nan Geng <nangeng at nwafu.edu.cn>
+%%     Copyright (C) 2020-2022 by Nan Geng <nangeng at nwafu.edu.cn>
 %% --------------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
@@ -27,7 +27,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
 \RequirePackage{expl3}
-\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+\GetIdInfo$Id: codebox.dtx 1.0.3 2022-01-04 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
   {Code Box with tcolorbox and minted/listings.}
 \ProvidesExplPackage{\ExplFileName}
   {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -145,6 +145,7 @@
 \tl_new:N     \l__codebox_code_name_tl
 \tl_new:N     \l__codebox_comment_contents_tl
 \tl_new:N     \l__codebox_comment_format_tl
+\tl_new:N     \l__codebox_label_name_tl
 \fp_new:N     \l__codebox_baseline_stretch_fp
 \fp_new:N     \l__codebox_linenumber_sep_fp
 \keys_define:nn { codebox }
@@ -169,6 +170,8 @@
     codestretch .initial:n = 1.0,
     linenumsep .fp_set:N  = \l__codebox_linenumber_sep_fp,
     linenumsep .initial:n = 3.00,
+    label .tl_set:N = \l__codebox_label_name_tl,
+    label .initial:n = {},
     unknown .code:n = { \__codebox_error:n { unknown-option } }
   }
 \msg_new:nnn { codebox } { unknown-option }
@@ -312,6 +315,12 @@
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
     \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
+    \tl_if_empty:NF \l__codebox_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l__codebox_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       overlay~unbroken~and~first ={
@@ -336,6 +345,12 @@
     \IfNoValueF{#1}{ \keys_set:nn { codebox } { #1 } }
     \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
+    \tl_if_empty:NF \l__codebox_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l__codebox_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       overlay~unbroken~and~first ={
@@ -370,6 +385,12 @@
     \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
     \__codebox_code_engine_tcbset:
     \__codebox_comment_tcbset:
+    \tl_if_empty:NF \l__codebox_label_name_tl
+    {
+      \tcbset{
+        label=\tl_use:N \l__codebox_label_name_tl,
+      }
+    }
     \tcbset{
       cv,
       listing~file={#4},



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