From c63cfc5f3272dfb157585ad1ba271cd5f5e58ca6 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 6 Jan 2022 00:21:08 +0000 Subject: codebox (6jan22) git-svn-id: svn://tug.org/texlive/trunk@61502 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/codebox/README.md | 2 +- .../doc/latex/codebox/codebox-doc-en.pdf | Bin 70542 -> 71350 bytes .../doc/latex/codebox/codebox-doc-en.tex | 37 ++++++++++-- Master/texmf-dist/doc/latex/codebox/codebox.dtx | 62 +++++++++++++++++++-- Master/texmf-dist/doc/latex/codebox/codebox.pdf | Bin 292226 -> 300058 bytes 5 files changed, 89 insertions(+), 12 deletions(-) (limited to 'Master/texmf-dist/doc/latex/codebox') diff --git a/Master/texmf-dist/doc/latex/codebox/README.md b/Master/texmf-dist/doc/latex/codebox/README.md index f5372b8900a..38f669150c2 100644 --- a/Master/texmf-dist/doc/latex/codebox/README.md +++ b/Master/texmf-dist/doc/latex/codebox/README.md @@ -43,7 +43,7 @@ Contributing Copyright and Licence --------------------- - Copyright (C) 2020-2021 by Nan Geng + Copyright (C) 2020-2022 by Nan Geng ---------------------------------------------------------------------- This work may be distributed and/or modified under the diff --git a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf index c95ab86dfcf..f8edd671df1 100644 Binary files a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf and b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf differ diff --git a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex index cf4232e0880..3ad34985ded 100644 --- a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex +++ b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.tex @@ -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@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 @@ or command's \oarg{options}. 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 @@ The language can be set with \tn{codeset} macro. \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} diff --git a/Master/texmf-dist/doc/latex/codebox/codebox.dtx b/Master/texmf-dist/doc/latex/codebox/codebox.dtx index 4e7d767dbec..8365020d9f5 100644 --- a/Master/texmf-dist/doc/latex/codebox/codebox.dtx +++ b/Master/texmf-dist/doc/latex/codebox/codebox.dtx @@ -49,7 +49,7 @@ Contributing Copyright and Licence --------------------- - Copyright (C) 2020-2021 by Nan Geng + Copyright (C) 2020-2022 by Nan Geng ---------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -88,7 +88,7 @@ Copyright and Licence \preamble - Copyright (C) 2020-2021 by Nan Geng + Copyright (C) 2020-2022 by Nan Geng -------------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -148,7 +148,7 @@ Copyright and Licence % %\NeedsTeXFormat{LaTeX2e}[2020/10/01] %\RequirePackage{expl3} -%<+package>\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng $ +%<+package>\GetIdInfo$Id: codebox.dtx 1.0.3 2022-01-04 08:00:00 +0800 Nan Geng $ % {Code Box with tcolorbox and minted/listings.} %\ProvidesExplPackage{\ExplFileName} % {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -180,7 +180,7 @@ Copyright and Licence % % \changes{v1.0.0}{2021/12/25}{开始编写模板} % -% \CheckSum{295} +% \CheckSum{313} % \GetFileId{codebox.sty} % % \CharacterTable @@ -485,6 +485,20 @@ Copyright and Licence % 引擎有效,取浮点数,单位是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 @@ Copyright and Licence % % \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 @@ Copyright and Licence % \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 @@ Copyright and Licence \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 @@ Copyright and Licence % \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 @@ Copyright and Licence % \end{macrocode} % % \changes{v1.0.2}{2021/12/28}{为计数器两端添加\tn{nobreakspace}} +% \changes{v1.0.3}{2022/1/4}{为带编号代码盒子添加引用标签选项} % % 定义不带底线注释的代码盒子环境\env{codeview} % @@ -1080,6 +1111,12 @@ Copyright and Licence \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 @@ Copyright and Licence } % \end{macrocode} % +% % 定义带底线注释的代码盒子环境\env{codeview*} % % \begin{macrocode} @@ -1109,6 +1147,12 @@ Copyright and Licence \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 @@ Copyright and Licence \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}, diff --git a/Master/texmf-dist/doc/latex/codebox/codebox.pdf b/Master/texmf-dist/doc/latex/codebox/codebox.pdf index 1b078356ac6..b82446cb1c2 100644 Binary files a/Master/texmf-dist/doc/latex/codebox/codebox.pdf and b/Master/texmf-dist/doc/latex/codebox/codebox.pdf differ -- cgit v1.2.3