summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-02 21:04:52 +0000
committerKarl Berry <karl@freefriends.org>2022-01-02 21:04:52 +0000
commit9f13483e2384738fc3476620f1f0d8b340a24434 (patch)
tree96d07d4e599a4011b056884ead1c945aaf7cf25c /Master/texmf-dist/tex
parent0ddef2e8e5f31c48fb36effe09e338d8497cbd13 (diff)
codebox (2jan22)
git-svn-id: svn://tug.org/texlive/trunk@61470 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/codebox/codebox.sty119
1 files changed, 64 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/codebox/codebox.sty b/Master/texmf-dist/tex/latex/codebox/codebox.sty
index 4c8637ce0b9..c4c49b804fa 100644
--- a/Master/texmf-dist/tex/latex/codebox/codebox.sty
+++ b/Master/texmf-dist/tex/latex/codebox/codebox.sty
@@ -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@nwafu.edu.cn> $
+\GetIdInfo$Id: codebox.dtx 1.0.2 2022-01-02 08:00:00 +0800 Nan Geng <nangeng@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,16 +301,16 @@
\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 }
{
\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,