diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-02 21:04:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-02 21:04:52 +0000 |
commit | 9f13483e2384738fc3476620f1f0d8b340a24434 (patch) | |
tree | 96d07d4e599a4011b056884ead1c945aaf7cf25c /Master/texmf-dist/doc/latex/codebox | |
parent | 0ddef2e8e5f31c48fb36effe09e338d8497cbd13 (diff) |
codebox (2jan22)
git-svn-id: svn://tug.org/texlive/trunk@61470 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/codebox')
-rw-r--r-- | Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf | bin | 69443 -> 70542 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/codebox/codebox.dtx | 163 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/codebox/codebox.pdf | bin | 281819 -> 292226 bytes |
3 files changed, 103 insertions, 60 deletions
diff --git a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf Binary files differindex be0b5155409..c95ab86dfcf 100644 --- a/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf +++ b/Master/texmf-dist/doc/latex/codebox/codebox-doc-en.pdf diff --git a/Master/texmf-dist/doc/latex/codebox/codebox.dtx b/Master/texmf-dist/doc/latex/codebox/codebox.dtx index e924279e3bf..4e7d767dbec 100644 --- a/Master/texmf-dist/doc/latex/codebox/codebox.dtx +++ b/Master/texmf-dist/doc/latex/codebox/codebox.dtx @@ -148,7 +148,7 @@ Copyright and Licence %</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@nwafu.edu.cn> $ +%<+package>\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ %<package> {Code Box with tcolorbox and minted/listings.} %<package>\ProvidesExplPackage{\ExplFileName} %<package> {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -180,7 +180,7 @@ Copyright and Licence % % \changes{v1.0.0}{2021/12/25}{开始编写模板} % -% \CheckSum{286} +% \CheckSum{295} % \GetFileId{codebox.sty} % % \CharacterTable @@ -411,9 +411,9 @@ Copyright and Licence % % \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 @@ Copyright and Licence % 引擎有效,取浮点数,单位是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 @@ Copyright and Licence % \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 @@ Copyright and Licence % % \subsection{内部函数} % +% \changes{v1.0.2}{2022/1/2}{修改按章编号时cvcounter的编号方式} +% % \begin{macro}{\@@_set_counter_parent:} % % 设置代码编号计数器的父计数器。 @@ -865,65 +882,89 @@ Copyright and Licence { \ifdef{\thechapter} { - \newcounter{codecounter}[chapter]% + \newcounter{cvcounter}[chapter]% + \renewcommand{\thecvcounter}{\thechapter.\arabic{cvcounter}} }{ - \newcounter{codecounter}%[section]% + \newcounter{cvcounter}%[section]% } } % \end{macrocode} % \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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,19 +1064,21 @@ Copyright and Licence \@@_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 } { \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 @@ Copyright and Licence \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 @@ Copyright and Licence % 定义带/不带底线注释的从文件读取内容的命令\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 @@ Copyright and Licence \group_begin: \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } } - \@@_code_engine_tcbset:V \l_@@_code_style_tl + \@@_code_engine_tcbset: \@@_comment_tcbset: \tcbset{ cv, diff --git a/Master/texmf-dist/doc/latex/codebox/codebox.pdf b/Master/texmf-dist/doc/latex/codebox/codebox.pdf Binary files differindex 4e1e51d5856..1b078356ac6 100644 --- a/Master/texmf-dist/doc/latex/codebox/codebox.pdf +++ b/Master/texmf-dist/doc/latex/codebox/codebox.pdf |