summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/codebox/codebox.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/codebox/codebox.sty')
-rw-r--r--Master/texmf-dist/tex/latex/codebox/codebox.sty393
1 files changed, 393 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/codebox/codebox.sty b/Master/texmf-dist/tex/latex/codebox/codebox.sty
new file mode 100644
index 00000000000..69d19d788af
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/codebox/codebox.sty
@@ -0,0 +1,393 @@
+%%
+%% This is file `codebox.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% codebox.dtx (with options: `package')
+%%
+%% Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn>
+%% --------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Nan Geng.
+%%
+%% --------------------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}[2020/10/01]
+\RequirePackage{expl3}
+\GetIdInfo$Id: codebox.dtx 1.0.0 2021-12-26 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $
+ {Code Box with tcolorbox and minted/listings.}
+\ProvidesExplPackage{\ExplFileName}
+ {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+\RequirePackage { xtemplate, l3keys2e, xparse }
+\RequirePackage {fontawesome5, tcolorbox, varwidth, xcolor, etoolbox}
+\ExplSyntaxOff
+\patchcmd
+{\tcb@input@library@in}
+ {%
+ \input\tcbpkgprefix#1\relax%
+ }
+ {%
+ \@pushfilename
+ \input\tcbpkgprefix#1\relax%
+ \@popfilename
+ }
+ {}{}
+
+\patchcmd
+{\pgfutil@InputIfFileExists}
+ {\input #1}
+ {%
+ \@pushfilename
+ \xdef\@currname{#1}%
+ \input #1 %
+ \@popfilename
+ }
+ {}{}
+\ExplSyntaxOn
+\tcbuselibrary{skins, xparse, breakable}
+\tcbuselibrary{minted,listings}
+\usetikzlibrary{shapes.geometric}
+\definecolor{cvgrayc}{RGB}{247,247,247}
+\definecolor{cvgray}{RGB}{220,220,220}
+\definecolor{cvgrayb}{RGB}{153,153,153}
+\definecolor{cvblue}{RGB}{223,238,255}
+\definecolor{chengse}{RGB}{250,140,53}
+\tcbset{%
+ skin=enhanced,
+ lang/.style={%
+ breakable,%
+ drop~shadow,%
+ colframe=gray!75!black,%
+ left=4.5mm,
+ enhanced,%
+ colframe=tcbcolback!60!black,%
+ colback=white,%
+ colbacktitle=tcbcolback!5!gray!10!white,%
+ fonttitle=\bfseries,%
+ coltitle=black,%
+ attach~boxed~title~to~top~center={%
+ yshift=-0.25mm-\tcboxedtitleheight/2,%
+ yshifttext=2mm-\tcboxedtitleheight/2%
+ },%
+ attach~boxed~title~to~top~left={%
+ xshift=1cm,%
+ yshift*=1mm-\tcboxedtitleheight%
+ },%
+ varwidth~boxed~title*=-3cm,%
+ boxed~title~style={%
+ frame~code={%
+ \path[fill=tcbcolback!30!black]([yshift=-1mm,xshift=-1mm]frame.north~west)%
+ arc[start~angle=0,end~angle=180,radius=1mm]([yshift=-1mm,xshift=1mm]frame.north~east)%
+ arc[start~angle=180,end~angle=0,radius=1mm];%
+ \path[left~color=tcbcolback!60!black,right~color=tcbcolback!60!black,
+ middle~color=tcbcolback!80!black]([xshift=-2mm]frame.north~west)%
+ --([xshift=2mm]frame.north~east)[rounded~corners=1mm]%
+ --([xshift=1mm,yshift=-1mm]frame.north~east)%
+ --(frame.south~east)%
+ --(frame.south~west)%
+ --([xshift=-1mm,yshift=-1mm]frame.north~west)[sharp~corners]%
+ --cycle;%
+ },%
+ interior~engine=empty%
+ },%
+ overlay={%
+ \begin{tcbclipinterior}
+ \fill[tcbcolback!80!black] (frame.south~west) rectangle
+ ([xshift=5mm]frame.north~west);
+ \end{tcbclipinterior}%
+ },
+ }%
+}%
+\tcbset{%
+ skin=enhanced,
+ cv/.style={
+ boxrule=0.4mm,
+ breakable,
+ top=0mm,
+ boxsep=1mm,
+ drop~shadow,
+ attach~boxed~title~to~top,
+ colframe=blue!75!black,
+ left=4.5mm,
+ right=0mm,
+ enhanced,
+ colframe=tcbcolback!60!black,
+ colback=white,
+ colbacktitle=cvgray,
+ fonttitle=\ttfamily,
+ coltitle=black,
+ % overlay~broken = {
+ % \begin{tcbclipinterior}
+ % \fill[cvblue] (frame.south~west) rectangle ([xshift=5.0mm]frame.north~west);
+ % \end{tcbclipinterior}
+ % },
+ underlay~boxed~title = {
+ \begin{tcbclipinterior}
+ \fill[cvblue] (frame.south~west) rectangle ([xshift=5.0mm,yshift=0mm]frame.north~west);
+ \end{tcbclipinterior}
+ }
+ }
+}%
+\bool_new:N \l__codebox_minted_bool
+\bool_new:N \l__codebox_comment_bool
+
+\tl_new:N \l__codebox_language_tl
+\tl_new:N \l__codebox_code_style_tl
+\tl_new:N \l__codebox_code_fontsize_tl
+\tl_new:N \l__codebox_code_name_tl
+\tl_new:N \l__codebox_comment_contents_tl
+\tl_new:N \l__codebox_comment_format_tl
+\fp_new:N \l__codebox_baseline_stretch_fp
+\fp_new:N \l__codebox_linenumber_sep_fp
+\keys_define:nn { codebox }
+ {
+ minted .bool_set:N = \l__codebox_minted_bool,
+ minted .default:n = true,
+ minted .initial:n = true,
+ lang .tl_set:N = \l__codebox_language_tl,
+ 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,
+ codestyle .initial:n = default,
+ codesize .tl_set:N = \l__codebox_code_fontsize_tl,
+ codesize .initial:n = \small,
+ comments .tl_set:N = \l__codebox_comment_contents_tl,
+ comments .initial:n = {},
+ commentf .tl_set:N = \l__codebox_comment_format_tl,
+ commentf .initial:n = \small\sffamily,
+ codestretch .code:n = { \fp_set:Nn \l__codebox_baseline_stretch_fp { #1 }
+ },
+ codestretch .initial:n = 1.0,
+ linenumsep .fp_set:N = \l__codebox_linenumber_sep_fp,
+ linenumsep .initial:n = 3.00,
+ unknown .code:n = { \__codebox_error:n { unknown-option } }
+ }
+\msg_new:nnn { codebox } { unknown-option }
+ { package~ option~ "\l_keys_key_tl"~ is~ unknown. }
+\NewDocumentCommand \codeset { m }
+ { \keys_set:nn { codebox } {#1} }
+\cs_new:Npn \__codebox_set_counter_parent:
+ {
+ \ifdef{\thechapter}
+ {
+ \newcounter{codecounter}[chapter]%
+ }{
+ \newcounter{codecounter}[section]%
+ }
+ }
+\cs_new:Npn \__codebox_code_engine_tcbset:n #1
+ {
+ \bool_if:NTF \l__codebox_minted_bool
+ {
+ \tcbset{
+ listing~engine=minted,%
+ minted~style=#1,
+ minted~options={%
+ % highlightlines={\ifodd\value{lstnumber}\value{lstnumber}\fi},
+ 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}
+ }
+ }%
+ }
+ }
+\cs_generate_variant:Nn \__codebox_code_engine_tcbset:n {V}
+\cs_new:Npn \__codebox_comment_tcbset:
+ {
+ \bool_if:NTF { \l__codebox_comment_bool }
+ {
+ \tcbset{%
+ listing~and~comment,%
+ colbacklower=tcbcolback!5!yellow!10!white,%
+ collower=tcbcolback!60!black,%
+ comment={\tl_use:N \l__codebox_comment_format_tl~
+ \tl_use:N \l__codebox_comment_contents_tl},%
+ }
+ }{
+ \tcbset{ listing~only,}
+ }
+ }
+\NewDocumentEnvironment{ codebox }{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_comment_tcbset:
+ \tcbset{lang, title={#2} }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+\NewDocumentEnvironment{ codebox* }{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_comment_tcbset:
+ \tcbset{lang, title={#2} }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+\NewDocumentCommand \codefile { s O{} m m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \bool_set_true:N \l__codebox_comment_bool
+ }{
+ \bool_set_false:N \l__codebox_comment_bool
+ }
+
+ \group_begin:
+ \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
+ \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl,
+ \__codebox_comment_tcbset:
+ \tcbset{
+ lang,
+ title={#3},
+ listing~file={#4},
+ }%
+ \tcbinputlisting{ }
+ \group_end:
+ }
+\__codebox_set_counter_parent:
+\DeclareTCBListing[use~counter=codecounter]{codeviewaux}{m}
+ {
+ title={\tl_use:N \l__codebox_code_name_tl\thecodecounter~#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_comment_tcbset:
+ \tcbset{
+ cv,
+ overlay~unbroken~and~first ={
+ \begin{tcbclipinterior}
+ \node[inner~sep=0pt,anchor=north~east,yshift=-3pt,xshift=-5pt,text=cvgrayb]
+ at (frame.north~east){
+ \ttfamily\faFile*\ \faCode\ \faCodeBranch\ \faCopy\ \faExternalLink*\
+ \MakeUppercase{\tl_use:N \l__codebox_language_tl}
+ };
+ \end{tcbclipinterior}
+ }
+ }%
+ \codeviewaux{#2}
+ }{
+ \endcodeviewaux
+ \group_end:
+ }
+\NewDocumentEnvironment{ codeview* }{O{} m }
+ {
+ \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_comment_tcbset:
+ \tcbset{
+ cv,
+ overlay~unbroken~and~first ={
+ \begin{tcbclipinterior}
+ \node[inner~sep=0pt,anchor=north~east,yshift=-3pt,xshift=-5pt,text=cvgrayb]
+ at (frame.north~east){
+ \ttfamily\faFile*\ \faCode\ \faCodeBranch\ \faCopy\ \faExternalLink*\
+ \MakeUppercase{\tl_use:N \l__codebox_language_tl}
+ };
+ \end{tcbclipinterior}
+ }
+ }%
+ \codeviewaux{#2}
+ }{
+ \endcodeviewaux
+ \group_end:
+ }
+\DeclareTCBInputListing[use~counter=codecounter]{\langfileaux}{m}
+ {
+ title={\tl_use:N \l__codebox_code_name_tl\thecodecounter~#1},
+ }
+\NewDocumentCommand \cvfile { s O{} m m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \bool_set_true:N \l__codebox_comment_bool
+ }{
+ \bool_set_false:N \l__codebox_comment_bool
+ }
+
+ \group_begin:
+ \IfNoValueF{#2}{ \keys_set:nn { codebox } { #2 } }
+ \__codebox_code_engine_tcbset:V \l__codebox_code_style_tl,
+ \__codebox_comment_tcbset:
+ \tcbset{
+ cv,
+ listing~file={#4},
+ overlay~unbroken~and~first ={
+ \begin{tcbclipinterior}
+ \node[inner~sep=0pt,anchor=north~east,yshift=-3pt,xshift=-5pt,text=cvgrayb]
+ at (frame.north~east){
+ \ttfamily\faFile*\ \faCode\ \faCodeBranch\ \faCopy\ \faExternalLink*\
+ \MakeUppercase{\tl_use:N \l__codebox_language_tl}
+ };
+ \end{tcbclipinterior}
+ }
+ }%
+ \langfileaux{#3}
+ \group_end:
+ }
+%%
+%% This package consists of the file codebox.dtx,
+%% and the derived files codebox.sty,
+%% codebox.pdf,
+%% codebox.ins,
+%% README.md.
+%%
+%% End of file `codebox.sty'.