summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/hanzibox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-09-21 19:50:29 +0000
committerKarl Berry <karl@freefriends.org>2021-09-21 19:50:29 +0000
commit41c402e9df2d50c940889199aff1f4d598ba30cf (patch)
tree7e2deb7ae462aa62dc6decf3bb33bad1c2f445f1 /Master/texmf-dist/tex/xelatex/hanzibox
parent7ae12e79acacd03b0dc8508a6f64762c1d0b3ce0 (diff)
hanzibox (21sep21)
git-svn-id: svn://tug.org/texlive/trunk@60575 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/hanzibox')
-rw-r--r--Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty336
1 files changed, 336 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
new file mode 100644
index 00000000000..b2e6ae1281b
--- /dev/null
+++ b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
@@ -0,0 +1,336 @@
+%%
+%% This is file `hanzibox.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% hanzibox.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 Nan Geng.
+%%
+%% --------------------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}[2020/10/01]
+\RequirePackage{expl3}
+\GetIdInfo$Id: hanzibox.dtx 1.0.0 2021-09-18 20:00:00Z +0800 Nan Geng <nangeng@nwafu.edu.cn> $
+ {Boxed Chinese characters with Pinyin above and translation below.}
+\ProvidesExplPackage{\ExplFileName}
+ {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+
+\RequirePackage { xtemplate, l3keys2e, xparse }
+
+\sys_if_engine_xetex:F
+ {
+ \sys_if_engine_luatex:F
+ {
+ \msg_fatal:nnx { hanzibox } { unsupported-engine }
+ { \c_sys_engine_str }
+ }
+ }
+\msg_new:nnn { hanzibox } { unsupported-engine }
+ {
+ The~ hanzibox~ packages~ requires~ either~ XeTeX~ or~ LuaTeX. \\\\
+ "#1"~ is~ not~ supported~ at~ present.~ You~ must~ change \\
+ your~ typesetting~ engine~ to~ "xelatex"~ or~ "lualatex".
+ }
+
+\RequirePackage { tikz, xpinyin }
+
+\RequirePackage{etoolbox}
+\ExplSyntaxOff
+\patchcmd
+ {\pgfutil@InputIfFileExists}
+ {\input #1}
+ {%
+ \@pushfilename
+ \xdef\@currname{#1}%
+ \input #1 %
+ \@popfilename
+ }
+ {}{}
+\ExplSyntaxOn
+\usetikzlibrary{decorations}
+\usetikzlibrary{shapes.geometric}
+\usetikzlibrary{positioning}
+
+\tikzset{%
+ stretch~dash/.code~args={on~#1~off~#2}{%
+ \tikz@addoption{%
+ \pgfgetpath\currentpath%
+ \pgfprocessround{\currentpath}{\currentpath}%
+ \pgf@decorate@parsesoftpath{\currentpath}{\currentpath}%
+ \pgfmathparse{max(round((\pgf@decorate@totalpathlength-#1)/(#1+#2)),0)}%
+ \let\npattern=\pgfmathresult%
+ \pgfmathparse{\pgf@decorate@totalpathlength/(\npattern*(#1+#2)+#1)}%
+ \let\spattern=\pgfmathresult%
+ \pgfsetdash{{\spattern*#1}{\spattern*#2}}{0pt}%
+ }%
+ }%
+}
+
+\NewDocumentCommand{\hanzidialog}{ m O{} O{} }
+ {
+ \__hanzibox_dialog:nnnn { #1 } { #2 } { #3 }
+ }
+
+\NewDocumentCommand{\hanzibox}{ s O{} m O{} O{} }
+ {
+ \IfBooleanTF{#1}
+ {
+ \__hanzibox_star_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+ }{
+ \__hanzibox_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+ }
+ }
+
+\fp_new:N \l__hanzibox_ratio_fp
+\int_new:N \l__hanzibox_inner_int
+\bool_new:N \l__hanzibox_border_bool
+\dim_new:N \l__hanzibox_borderwidth_dim
+\tl_new:N \l__hanzibox_bordercolor_tl
+\tl_new:N \l__hanzibox_pinyin_tl
+\tl_new:N \l__hanzibox_character_tl
+\tl_new:N \l__hanzibox_translation_tl
+\int_new:N \l__hanzibox_pinyin_int
+\int_new:N \l__hanzibox_character_int
+\int_new:N \l__hanzibox_translation_int
+
+\keys_define:nn { hanzibox }
+ {
+ ratio .fp_set:N = \l__hanzibox_ratio_fp,
+ ratio .initial:n = 1.0,
+
+ inner .choice:,
+ inner .value_required:n = true,
+ inner .choices:nn =
+ { none,star,cross }
+ { \int_set_eq:NN \l__hanzibox_inner_int \l_keys_choice_int },
+ inner .initial:n = none,
+
+ border .bool_set:N = \l__hanzibox_border_bool,
+ border .default:n = true,
+ border .initial:n = true,
+
+ borderwidth .dim_set:N = \l__hanzibox_borderwidth_dim,
+ borderwidth .initial:n = 0.4 pt,
+
+ bordercolor .tl_set:N = \l__hanzibox_bordercolor_tl,
+ bordercolor .initial:n = black,
+
+ unknown .code:n = { \__hanzibox_error:n { unknown-option } }
+ }
+\msg_new:nnn { hanzibox } { unknown-option }
+ { package~ option~ "\l_keys_key_tl"~ is~ unknown. }
+
+\NewDocumentCommand \hanziboxset { m }
+ { \keys_set:nn { hanzibox } {#1} }
+\cs_new_protected:Npn \__hanzibox_dialog:nnnn #1#2#3
+ {
+ \tl_set:Nx \l__hanzibox_character_tl {#1}
+ \tl_set:Nx \l__hanzibox_pinyin_tl {#2}
+ \tl_set:Nx \l__hanzibox_translation_tl {#3}
+ \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+ \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
+ {\node[] at (1,1){\huge{\tl_use:N \l__hanzibox_character_tl}}};
+ {\node[label={\strut\small\textbf{\tl_use:N \l__hanzibox_pinyin_tl}},
+ text~height=1cm] (charr) at (1,1){};}%
+ {\node[align=center] at (1,-0.5)
+ {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};}%
+ }%
+ }%
+ }
+
+\cs_set_eq:NN \__hanzibox_pinyinaux:n \pinyin
+\cs_generate_variant:Nn \__hanzibox_pinyinaux:n { x }
+\cs_new_protected:Npn \__hanzibox_draw:nnnn #1#2#3#4
+ {
+ \keys_set:nn { hanzibox } { #1 }
+ \tl_set:Nx \l__hanzibox_character_tl {#2}
+ \tl_set:Nx \l__hanzibox_pinyin_tl {#3}
+ \tl_set:Nx \l__hanzibox_translation_tl {#4}
+ \int_set:Nn \l__hanzibox_character_int
+ {
+ \tl_count:V \l__hanzibox_character_tl
+ }
+ \int_set:Nn \l__hanzibox_pinyin_int
+ {
+ \tl_count:V \l__hanzibox_pinyin_tl
+ }
+ \int_set:Nn \l__hanzibox_translation_int
+ {
+ \tl_count:V \l__hanzibox_translation_tl
+ }
+
+ \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+ \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
+ \int_compare:nNnT { \l__hanzibox_character_int } < {2}
+ {
+ \int_case:nn {\l__hanzibox_inner_int}
+ {
+ {1}{
+ }
+ {2}{
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,0)--(2,2);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,2)--(2,0);%
+
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+ }
+ {3}{
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+ }
+ }
+ }
+ \int_compare:nNnTF { \l__hanzibox_character_int } = {0}
+ {
+ \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim,
+ \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2,2);
+ \node[] at (1,1){\huge{\tl_use:N \l__hanzibox_character_tl}};
+ \int_compare:nNnTF { \l__hanzibox_pinyin_int } = {0}
+ { }
+ {
+ \node[label={\strut\small\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+ text~height=1cm] (charr) at (1,1){};
+ }
+ \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
+ { }
+ {
+ \node[align=center] at (1,-0.5)
+ {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+ }
+ }
+ {
+ \bool_if:NTF \l__hanzibox_border_bool
+ {
+ \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim,
+ \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2*\l__hanzibox_character_int,2);
+ }{}
+
+ \node[] at (1*\l__hanzibox_character_int,1)
+ {\huge\tl_use:N \l__hanzibox_character_tl};
+
+ \int_compare:nNnTF { \l__hanzibox_pinyin_int } = {0}
+ { }
+ {
+ \node[label={\strut\small\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+ text~height=1cm] (charr) at (1*\l__hanzibox_character_int,1){};
+ }
+
+ \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
+ { }
+ {
+ \node[align=center] at (1*\l__hanzibox_character_int,-0.5)
+ {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+ }
+ }
+ }%
+ }%
+ }
+\cs_new_protected:Npn \__hanzibox_star_draw:nnnn #1#2#3#4
+ {
+ \keys_set:nn { hanzibox } { #1 }
+ \tl_set:Nx \l__hanzibox_character_tl {#2}
+ \tl_set:Nx \l__hanzibox_pinyin_tl {#3}
+ \tl_set:Nx \l__hanzibox_translation_tl {#4}
+ \int_set:Nn \l__hanzibox_character_int
+ {
+ \tl_count:V \l__hanzibox_character_tl
+ }
+ \int_set:Nn \l__hanzibox_pinyin_int
+ {
+ \tl_count:V \l__hanzibox_pinyin_tl
+ }
+ \int_set:Nn \l__hanzibox_translation_int
+ {
+ \tl_count:V \l__hanzibox_translation_tl
+ }
+
+ \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+ \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
+ \int_compare:nNnT { \l__hanzibox_character_int } < {2}
+ {
+ \int_case:nn {\l__hanzibox_inner_int}
+ {
+ {1}{
+ }
+ {2}{
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,0)--(2,2);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,2)--(2,0);%
+
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+ }
+ {3}{
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+ \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+ }
+ }
+ }
+ \int_compare:nNnTF { \l__hanzibox_character_int } = {0}
+ {
+ \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2,2);
+ \node[] at (1,1){\huge{\xpinyin*[vsep=0.85 cm]{\tl_use:N \l__hanzibox_character_tl}}};
+ \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
+ { }
+ {
+ \node[align=center] at (1,-1.0)
+ {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+ }
+ }
+ {
+ \bool_if:NTF \l__hanzibox_border_bool
+ {
+ \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim, yshift=-0.5cm,
+ \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2*\l__hanzibox_character_int,2);
+ }{}
+
+ \node[] at (1*\l__hanzibox_character_int,1)
+ {\huge{\xpinyin*[vsep=0.90 cm]{\tl_use:N \l__hanzibox_character_tl}}};
+
+ \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
+ { }
+ {
+ \node[align=center] at (1*\l__hanzibox_character_int,-1.0)
+ {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+ }
+ }
+ }%
+ }%
+ }
+%%
+%% This package consists of the file hanzibox.dtx,
+%% and the derived files hanzibox.sty,
+%% hanzibox.pdf,
+%% hanzibox.ins,
+%% README.md.
+%%
+%% End of file `hanzibox.sty'.