diff options
author | Karl Berry <karl@freefriends.org> | 2017-06-05 23:15:19 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-06-05 23:15:19 +0000 |
commit | caef61ed4952aee5804397dbdc93deb54f043a98 (patch) | |
tree | 1e573ee472800ed59f289b3df677b55760cd333a /Master/texmf-dist/tex/latex/bxbase | |
parent | 2709e0f96ccfa1759997b079880998184fc725cf (diff) |
bxbase (30may17)
git-svn-id: svn://tug.org/texlive/trunk@44481 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/bxbase')
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxbase.def | 750 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxbase.sty | 73 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ext.def | 563 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ja.def | 186 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxtoolbox.def | 1078 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxtoolbox.sty | 27 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxucs.sty | 109 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxutf8.def | 152 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxutf8x.def | 64 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/zxbase.sty | 78 |
10 files changed, 2369 insertions, 711 deletions
diff --git a/Master/texmf-dist/tex/latex/bxbase/bxbase.def b/Master/texmf-dist/tex/latex/bxbase/bxbase.def index 1488f6fa1c4..614ac5dcc81 100644 --- a/Master/texmf-dist/tex/latex/bxbase/bxbase.def +++ b/Master/texmf-dist/tex/latex/bxbase/bxbase.def @@ -1,94 +1,101 @@ -% -% bxbase.def -% - -% Note: bxbase.def and pxbase.def provide same set of functionality. -% To avoid version clash, when a version of one of them is loaded, -% load of an older version of the other is aborted. - -%%%% stuffs read when \input'ed -\ifx\bxbaseOk\undefined -\bgroup -\catcode`\@=11 -\gdef\bx@defextension{def} -\gdef\bx@ver@#1{\expandafter\expandafter\expandafter\@parse@version - \csname ver@#1.\@currext\endcsname//00\@nil} - %% \bxInputDefFile{<def_name>} -\gdef\bxInputDefFile#1{\@onefilewithoptions{#1}[][]\bx@defextension} - %% \bxCheckCPart{<def_name>} -\gdef\bxCheckCPart#1{% - \@ifl@aded\@currext{#1}{% - \ifnum\bx@ver@{#1}>\bx@ver@\@currname \expandafter\endinput\fi}{}} -\egroup -\let\bxbaseOk=t -\bxInputDefFile{bxbase} %% read this file again -\expandafter\endinput\fi - -%%--------------- folloing stuffs are read by \bxTnext - -%%%% file declaration +%% +%% This is file 'bxbase.def'. +%% + +%% file declaration \NeedsTeXFormat{LaTeX2e} -\ProvidesFile{bxbase.def}[2010/06/15 v0.5 BX/PX base library] -\bxCheckCPart{pxbase} -%* v0.5.r13 - -%%%% error messages -\def\bx@b@pkgname{BX/PXbase} % bundle name -\def\bx@b@error{\PackageError\bx@b@pkgname} -\def\bx@err@nobbl{\bx@b@error{babel not yet loaded}\@eha} -\def\bx@err@oorng{\bx@b@error{Number out of range}\@eha} -\def\bx@err@nanbc{\bx@b@error{Non-BMP characters not supported}\@eha} -\def\bx@err@ilnfm{\bx@b@error{Illegal number format}\@eha} -\def\bx@err@uddrv#1{\bx@b@error{\string#1 is undefined}\@eha} - -%%%% common stuffs -\ifx\bxUcv\@undefined -\newcount\bxUcv % argument of \bx@Ux -\fi -\newif\ifbxOk % all-purpsoe switch +\ProvidesFile{bxbase.def}[2017/05/29 v1.1 BX base library] +\def\bx@pkgname{BXbase} % bundle name + +%% check intergrity +\edef\bxbz@tmpa{\@currname.\@currext}\def\bxbz@tmpb{bxbase.def} +\ifx\bxbz@tmpa\bxbz@tmpb\else + \PackageError\bx@pkgname{Illegal load sequence}\@eha +\expandafter\endinput\fi\relax + +%% code guards +\edef\bxbz@restore@codes{% + \catcode33=\the\catcode33% + \catcode34=\the\catcode34% + \catcode39=\the\catcode39% + \catcode43=\the\catcode43% + \catcode45=\the\catcode45% + \catcode46=\the\catcode46% + \catcode47=\the\catcode47% + \catcode58=\the\catcode58% + \catcode60=\the\catcode60% + \catcode62=\the\catcode62% + \catcode94=\the\catcode94% + \catcode96=\the\catcode96% +\relax} +\catcode33=12 % <!> +\catcode34=12 % <"> +\catcode39=12 % <'> +\catcode43=12 % <+> +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\catcode58=12 % <:> +\catcode60=12 % <<> +\catcode62=12 % <>> +\catcode94=7 % <^> +\catcode96=12 % <`> +\AtEndOfPackage{% + \bxbz@restore@codes + \let\bxbz@restore@codes\@undefined} + +%--------------------------------------- general + +%% packages +\RequirePackage{bxtoolbox}[2017/05/29] + +%% variables \let\bxHex\relax % result of \bxToHex... \let\bxRes\relax % result of \bxToLower -\edef\bx@b@resetcatcodes{% < ! " ' + ^ > - \catcode33=\the\catcode33\catcode34=\the\catcode34% - \catcode39=\the\catcode39\catcode43=\the\catcode43% - \catcode94=\the\catcode94\relax} -\catcode33=12 \catcode34=12 \catcode39=12 \catcode43=12 -\catcode94=6 - -%%------ Programming tools - -%%%% \bxNullify\CS -% Make \CS void and unoverridable by \providecommand. -\def\bxNullify#1{\global\let#1\bx@nullified} -\def\bx@nullified{\@gobble\bx@@nullified} - -%%%% \bxDebug{<text>} -% If \bxUseDebug is defined when bxbase is loaded, this command -% prints debug messages; otherwise it is ignored. -%\let\bx@typeout\typeout -%\ifx\bxUseDebug\@undefined \let\bxDebug\@gobble -%\else \def\bxDebug#1{\bx@typeout{BX debug: #1}}\fi -\providecommand*\bxDebug{\@gobble} - -%%%% \bxCheckMA\CS <text> \bxEndCheckMA +\ifundef\bxUcv{\newcount\bxUcv}{} % argument of \bx@Ux + +%% unique tokens +\def\bxbz@uniq{\bxbz@uniq@} + +%% error messages +\def\bx@error{\PackageError\bx@pkgname} +\def\bx@warn{\PackageWarningNoLine\bx@pkgname} +\def\bx@err@nobbl{\bx@error{babel not yet loaded}\@eha} +\def\bx@err@nanbc{\bx@error{Non-BMP characters not supported}\@eha} +\def\bx@err@ilnfm{\bx@error{Illegal number format}\@eha} +\def\bx@err@uddrv#1{\bx@error{\string#1 is undefined}\@eha} +\def\bxbz@warn@depre#1#2{% + \PackageWarning\bx@pkgname + {The command '\string#1' is obsolete and\MessageBreak + its use is deprecated% + \ifx\relax#2\relax, \else + \MessageBreak (use #2 instead),\MessageBreak + \fi detected}} + +%--------------------------------------- programming tools + +%%<+> \bxCheckMA\CS <text> \bxEndCheckMA % If this construct appears in moving arguments, it expands to % an error message command. \def\bxCheckMA{\let\bx@chkma@a\bx@chkma@a\noexpand} \let\bxEndCheckMA\@empty \let\bx@chkma@z\relax \def\bx@chkma@a#1{\bx@chkma@z\relax\bx@chkma@b} \def\bx@chkma@b#1#2#3\bxEncCheckMA{\noexpand\bx@err@ivfrg#1#2} -\def\bx@err@ivfrg#1{\bx@b@error{Cannot use \string#1 here}\@eha} +\def\bx@err@ivfrg#1{\bx@error{Cannot use \string#1 here}\@eha} -%%------ TeX engine distinction +%%<+D> \bxCheckCounterpart{<base_name>} +% Compares the version between the current file and <base_name> +% with the extension of current file, and if the latter file is +% already loaded and moreover turns out to be newer than the +% system aborts loading the current file. +\bxPreamble\newcommand*\bxCheckCounterpart[1]{% + \PackageWarning\bx@pkgname + {'\string\bxCheckCounterpart' is no more supported,% + \MessageBreak detected}} -%%%% \bxIfPrimitive\CS{<yes>}{<no>} -% Checks if \CS is a primitive. -\def\bxIfPrimitive#1{% - \edef\bx@tmpa{\string#1}\edef\bx@tmpb{\meaning#1}% - \ifx\bx@tmpa\bx@tmpb \expandafter\@firstoftwo - \else \expandafter\@secondoftwo \fi} +%--------------------------------------- TeX engine distinction -%%%% \bxEngineTypeX / \bxEngineTypeY +%%<+> \bxEngineTypeX / \bxEngineTypeY % Numbers that signify what I am. % \bxEngineTypeX values \chardef\bxETTeX=0 % none of those @@ -98,27 +105,35 @@ % \bxEngineTypeY values (plus \bxETTeX) \chardef\bxETeTeX=1 % e-TeX-extended \chardef\bxETpdfTeX=3 % pdfTeX-extended +\chardef\bxETLuaTeX=5 % LuaTeX-extended % (here old pdfTeX without e-TeX is ignored) % -\bxIfPrimitive\kansuji{\let\bxEngineTypeX\bxETpTeX}{% -\bxIfPrimitive\XeTeXversion{\let\bxEngineTypeX\bxETXeTeX}{% -\bxIfPrimitive\Omegaversion{\let\bxEngineTypeX\bxETOmega}{% - \let\bxEngineTypeX\bxETTeX}}} -\bxIfPrimitive\eTeXversion{\let\bxEngineTypeY\bxETeTeX}{% -\bxIfPrimitive\pdftexversion{\let\bxEngineTypeY\bxETpdfTeX}{% - \let\bxEngineTypeY\bxETTeX}} - -%%%% \bx@b@uptex -\bxIfPrimitive\kchar{\chardef\bx@b@uptex\@ne}{\chardef\bx@b@uptex\z@} - -%%------ Babel something + % Note: + % Originally LuaTeX was supposed to be 'both pdfTeX- and Omega- + % extended' (\bxEngineTypeX/Y = 3/3); however, It seems that + % in today's LaTeX world LuaTeX is no longer seen as Omega- + % extended (indeed, current LuaTeX drops many of the Omega- + % specific features). So LuaTeX got relocated at \bxEngineTypeX/Y + % = 0/5. +\ifbxinpTeX \let\bxEngineTypeX\bxETpTeX +\else\ifbxinXeTeX \let\bxEngineTypeX\bxETXeTeX +\else\ifbxinOmega \let\bxEngineTypeX\bxETOmega +\else \let\bxEngineTypeX\bxETTeX +\fi\fi\fi +\ifbxineTeX \let\bxEngineTypeY\bxETeTeX +\else\ifbxinpdfTeX \let\bxEngineTypeY\bxETpdfTeX +\else\ifbxinLuaTeX \let\bxEngineTypeY\bxETLuaTeX +\else \let\bxEngineTypeY\bxETTeX +\fi\fi\fi +\bxDebug{engine type = \the\bxEngineTypeX/\the\bxEngineTypeY} + +%--------------------------------------- Babel something %%<+> \bxBDHookBabel % A begindocument-hook about Babel. -\newif\ifbx@bbl@inuse -\def\bx@bbl@bdhook{} -\providecommand\bxBDHookBabel{\bx@bdhook@babel@do} -\def\bx@bdhook@babel@do{% +\newbool{bx@bbl@inuse} +\bxPreamble\def\bx@bbl@bdhook{} +\bxPreamble\newcommand*\bxBDHookBabel{% \AtBeginDocument{% \@ifpackageloaded{babel}{% \bx@bbl@inusetrue @@ -126,241 +141,96 @@ \bx@bbl@bdhook }{}}% \bxNullify\bxBDHookBabel} -\@onlypreamble\bxBDHookBabel -\@onlypreamble\bx@bdhook@babel@do %%<+> \bxAtBeginDocumentBabel{<text>} -% Register a begin-document hook that willl be invoked only when babel +% Register a begin-document hook that will be invoked only when babel % is loaded. -\def\bxAtBeginDocumentBabel{% +\bxPreamble\newcommand\bxAtBeginDocumentBabel{% \g@addto@macro\bx@bbl@bdhook} -\@onlypreamble\bxAtBeginDocumentBabel -\@onlypreamble\bx@bbl@bdhook -%%%% \bx@bbl@patch@sel@lang +%% \bx@bbl@patch@sel@lang % A patch to \select@language that disables automatic switching of % caption language. -\def\bx@bbl@patch@sel@lang{% this wlll be never invoked twice +\bxPreamble\def\bx@bbl@patch@sel@lang{% + \global\let\bx@bbl@patch@sel@lang\relax \global\let\bx@bbl@org@select@language\select@language \gdef\select@language##1{% \bx@bbl@copy{**C}{##1}\bx@bbl@copy{##1}{**Z}% \bx@bbl@org@select@language{##1}\bx@bbl@copy{##1}{**C}}} -\@onlypreamble\bx@bbl@patch@sel@lang - -%%%% \bx@bbl@do@captlang -\def\bx@bbl@@main{main} -\def\bx@bbl@@default{default} -\def\bx@bbl@do@captlang{% - % set captions - \ifx\bx@bbl@captlang\bx@bbl@@main - \let\bx@bbl@captlang\bbl@main@language \fi - \ifx\bx@bbl@captlang\bx@bbl@@default - \else\expandafter\ifx\csname l@\bx@bbl@captlang\endcsname\relax - \@nolanerr\bx@bbl@captlang - \else \csname date\bx@bbl@captlang\endcsname - \csname captions\bx@bbl@captlang\endcsname - \fi\fi} -\@onlypreamble\bx@bbl@do@captlang - -%%%% \bx@bbl@copy{<lang1>}{<lang2>} + +%% \bx@bbl@do@captlang +% Sets the caption language of Babel according to the value of +% \bx@bbl@captlang. +\bxPreamble\def\bx@bbl@do@captlang{% + \bxIfExpToEqual{\bx@bbl@captlang}{main}% + {\let\bx@bbl@captlang\bbl@main@language}{}% + \bxIfExpToEqual{\bx@bbl@captlang}{default}{}%else + {\bxIfcsundef{l@\bx@bbl@captlang}{\@nolanerr\bx@bbl@captlang}% + {\@nameuse{date\bx@bbl@captlang}% + \@nameuse{captions\bx@bbl@captlang}}}} + +%% \bx@bbl@copy{<lang1>}{<lang2>} % Copies \captions... and \date... for save. \def\bx@bbl@copy#1#2{% - \bx@bbl@copy@a{#1}{#2}{captions}% - \bx@bbl@copy@a{#1}{#2}{date}} -\def\bx@bbl@copy@a#1#2#3{% - \edef\bx@tmpa{\let\expandafter\noexpand\csname#3#1\endcsname - \expandafter\noexpand\csname#3#2\endcsname}\bx@tmpa} -\@namedef{captions**Z}{\@empty} -\@namedef{date**Z}{\@empty} - -%%<*> \bxcaptionlanguage{<lang>} + \csletcs{captions#1}{captions#2}% + \csletcs{date#1}{date#2}} +\csdef{captions**Z}{\@empty} +\csdef{date**Z}{\@empty} + +%%<*D> \fixcaptionlanguage{<lang>} +%%<+> \bxFixCaptionLanguage{<lang>} % Change the caption language manually, with disabling automatic % switching on it. -\def\bxcaptionlanguage#1{% +\bxPreamble\newcommand*\fixcaptionlanguage[1]{% + \bxbz@warn@depre\fixcaptionlanguage{}% + \bxFixCaptionLanguage{#1}} +\bxPreamble\newcommand*\bxFixCaptionLanguage[1]{% \@ifpackageloaded{babel}% - {\ifx\bx@bbl@captlang\@undefined \bx@bbl@patch@sel@lang \fi + {\bx@bbl@patch@sel@lang \xdef\bx@bbl@captlang{#1}}% {\bx@err@nobbl}} -\@onlypreamble\bxcaptionlanguage -%%<*> \bxmainlanguage{<lang>} +%%<+> \bxProvideCaptionLanguage{<lang>} +\bxPreamble\newcommand*\bxProvideCaptionLanguage[1]{% + \ifundef\bx@bbl@captlang + {\bxFixCaptionLanguage{#1}}{}} + +%%<*> \setmainlanguage{<lang>} % Changes the 'main' language (one that is effective at beginning). -\def\bxmainlanguage#1{% - \expandafter\ifx\csname date#1\endcsname\relax - \@nolanerr{#1}\fi +\bxPreamble\newcommand*\setmainlanguage[1]{% + \bxIfcsundef{date#1}{\@nolanerr{#1}}{}% \xdef\bbl@main@language{#1}} -\@onlypreamble\bxmainlanguage %%<+> \bxTrivLangDef{<lang>} % Makes a fake language option. -\def\bxTrivLangDef#1{% - \@ifundefined{date#1}{% - \@ifundefined{l@#1}% +\bxPreamble\newcommand*\bxTrivLangDef[1]{% + \bxIfcsundefX{date#1}{% + \bxIfcsundefX{l@#1}% {\expandafter\chardef\csname l@#1\endcsname\z@}{}% - \@namedef{date#1}{\relax}% - \@namedef{captions#1}{\relax}% - \@namedef{extras#1}{\relax}% - \@namedef{noextras#1}{\relax}% - \@namedef{date#1}{\relax}% + \csdef{date#1}{\relax}% + \csdef{captions#1}{\relax}% + \csdef{extras#1}{\relax}% + \csdef{noextras#1}{\relax}% + \csdef{date#1}{\relax}% }{}} -\@onlypreamble\bxTrivLangDef - -%%------ 'Number-to-hex-string' functions -% All public commands put their result in \bxHex. - -%%%% preparation -\newif\ifbx@hx@bigchar -\ifnum\bxEngineTypeX>\@ne \bx@hx@bigchartrue \fi -\ifnum\bx@b@uptex>\z@ \bx@hx@bigchartrue \fi - -%%<+> \bxToHexTiny -% For one-to-two-digit hex strings. -\def\bxToHexTiny#1{% - \chardef\bxHex=#1\relax - \expandafter\bx@hx@tohextiny@a\meaning\bxHex\@nil} -\def\bx@hx@tohextiny@a#1"#2\@nil{\def\bxHex{#2}} - -%%<+> \bxToHexSmall -% For one-to-three-digit hex strings. -\def\bxToHexSmall#1{% - \mathchardef\bxHex=#1\relax - \expandafter\bx@hx@tohexsmall@a\meaning\bxHex\@nil} -\def\bx@hx@tohexsmall@a#1"#2\@nil{\def\bxHex{#2}} - -%%<+> \bxToHexTwo -% For zero-padded two-digit hex strings. -\def\bxToHexTwo#1{% - \chardef\bxHex=#1\relax - \expandafter\bx@hx@tohextwo@a\meaning\bxHex"0\@nil} -\def\bx@hx@tohextwo@a#1"#2#3#4#5\@nil{\bx@hx@tohextwo@b#2#3#4\@nil} -\def\bx@hx@tohextwo@b#1"#2\@nil{\def\bxHex{#2#1}} - -%%<+> \bxToHexThree -% For zero-padded three-digit hex strings. -\def\bxToHexThree#1{% - \mathchardef\bxHex=#1\relax - \expandafter\bx@hx@tohexthree@a\meaning\bxHex"00\@nil} -\def\bx@hx@tohexthree@a#1"#2#3#4#5#6\@nil{\bx@hx@tohexthree@b#2#3#4#5\@nil} -\def\bx@hx@tohexthree@b#1"#2\@nil{\def\bxHex{#2#1}} - -%%<+> \bxToHexFour -% For zero-padded four-digit hex strings. -\ifbx@hx@bigchar %----<*bigchar> -\def\bxToHexFour#1{% - \chardef\bxHex=#1\relax - \expandafter\bx@hx@tohexfour@a\meaning\bxHex"000\@nil} -\def\bx@hx@tohexfour@a#1"#2#3#4#5#6#7\@nil{\bx@hx@tohexfour@b#2#3#4#5#6\@nil} -\def\bx@hx@tohexfour@b#1"#2\@nil{\def\bxHex{#2#1}} -\else %----<*!bigchar> -\mathchardef\bx@hx@fzzz="4000 -\def\bxToHexFour#1{\bgroup - \@tempcnta=#1\relax\@tempcntb\@tempcnta\divide\@tempcntb\bx@hx@fzzz - \ifcase\@tempcntb \advance\@tempcnta\bx@hx@fzzz \or \or - \advance\@tempcnta-\bx@hx@fzzz \or \advance\@tempcnta-"8000 \or - \@tempcnta\z@ \fi - \mathchardef\bx@hx@tmp\@tempcnta - \expandafter\bx@hx@tohexfour@a\meaning\bx@hx@tmp\@nil - \egroup \let\bxHex\bx@hx@gtmp} -\def\bx@hx@tohexfour@a#1"#2#3\@nil{% - \expandafter\let\expandafter\bx@hx@tmp - \csname bxhx@X/\the\@tempcntb#2\endcsname - \ifx\bx@hx@tmp\relax \bx@err@oorng \global\let\bx@hx@gtmp\@empty - \else \xdef\bx@hx@gtmp{\bx@hx@tmp#3}\fi} -\def\bx@hx@nxt#1#2#3{\bgroup\catcode`#3=12 - \global\expandafter\def\csname bxhx@X/#1#2\endcsname{#3}\egroup} -\@for\bx@hx@tmp:={040,051,062,073,144,155,166,177,248,259,26A,27B,% - 34C,35D,36E,37F}\do{\expandafter\bx@hx@nxt\bx@hx@tmp} -\fi %----</bigchar> - -%%<+> \bxToHexFive -%%<+> \bxToHexFiveX -% For zero-padded five-digit hex strings. -\def\bxToHexFive{\bx@tohexfive@aa\relax} -\def\bxToHexFiveX{\bx@tohexfive@aa - {\ifnum\@tempcnta>\bx@hx@vdmax \@tempcnta=\bx@hx@vdmax\fi}} -\ifbx@hx@bigchar %----<*bigchar> -\chardef\bx@hx@vdmax="FFFFF -\def\bx@tohexfive@aa#1#2{% - {\@tempcnta=#2\relax#1\global\chardef\bx@hx@gtmp=\@tempcnta}% - \expandafter\bx@hx@tohexfivex@a\meaning\bx@hx@gtmp"0000\@nil} -\def\bx@hx@tohexfivex@a#1"#2#3#4#5#6#7#8\@nil{% - \bx@hx@tohexfivex@b#2#3#4#5#6#7\@nil} -\def\bx@hx@tohexfivex@b#1"#2\@nil{\edef\bxHex{#2#1}} -\else %----<*!bigchar> -\edef\bx@hx@vdmax{"FFFFF\space} -\def\bx@tohexfive@aa#1#2{% - \bgroup \@tempcnta=#2\relax#1% - \@tempcntb=\@tempcnta \divide\@tempcnta\bx@hx@m\relax - \bxToHexTwo\@tempcnta \let\bx@hx@tmp\bxHex - \multiply\@tempcnta-\bx@hx@m\advance\@tempcnta\@tempcntb\relax - \bxToHexThree\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% - \egroup \let\bxHex\bx@hx@gtmp} -\fi %----</bigchar> - -%%<+> \bxToHexEight -% For zero-padded eight-digit hex strings. -\def\bxToHexEight#1{% - \bgroup \@tempcnta=#1\relax - \@tempcntb=\@tempcnta\divide\@tempcnta\p@\relax - \bxToHexFour\@tempcnta \let\bx@hx@tmp\bxHex - \multiply\@tempcnta-\p@\advance\@tempcnta\@tempcntb\relax - \bxToHexFour\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% - \egroup \let\bxHex\bx@hx@gtmp} - -%%<+> \bxToHexUC -% For zero-padded four-to-six-digit hex strings. -\ifbx@hx@bigchar %----<*bigchar> -\def\bxToHexUC#1{% - \chardef\bxHex=#1\relax - \expandafter\bx@hx@tohexuc@a\meaning\bxHex"\@empty\@empty000\@nil} -\def\bx@hx@tohexuc@a#1"#2#3#4#5#6#7#8#9\@nil{% - \bx@hx@tohexuc@b#2#3#4#5#6#7#8\@nil} -\def\bx@hx@tohexuc@b#1"#2\@nil{\edef\bxHex{#2#1}} -\else %----<*!bigchar> -\mathchardef\bx@hx@m="1000 -\def\bxToHexUC#1{% - \bgroup \@tempcnta=#1\relax - \@tempcntb=\@tempcnta \divide\@tempcnta\bx@hx@m\relax - \bxToHexSmall\@tempcnta \let\bx@hx@tmp\bxHex - \multiply\@tempcnta-\bx@hx@m\advance\@tempcnta\@tempcntb\relax - \bxToHexThree\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% - \egroup \let\bxHex\bx@hx@gtmp} -\fi %----</bigchar> - -%%<+> \bxToDecFour -\def\bxToDecFour#1{% - \expandafter\bx@hx@todecfour@a\number#1"000\@nil} -\def\bx@hx@todecfour@a#1#2#3#4#5#6\@nil{\bx@hx@todecfour@b#1#2#3#4#5\@nil} -\def\bx@hx@todecfour@b#1"#2\@nil{\def\bxHex{#2#1}} - -%%<+> \bxToDecFive -\def\bxToDecFive#1{% - \expandafter\bx@hx@todecfive@a\number#1"0000\@nil} -\def\bx@hx@todecfive@a#1#2#3#4#5#6#7\@nil{\bx@hx@todecfive@b#1#2#3#4#5#6\@nil} -\def\bx@hx@todecfive@b#1"#2\@nil{\def\bxHex{#2#1}} - -%%------ Input through code values + +%--------------------------------------- input through code values %%<+> \bxBDHookUnicode % A begindocument-hook about Unicode (& CID) input. -\providecommand\bxBDHookUnicode{\bx@bdhook@unicode@do} -\def\bx@bdhook@unicode@do{% +\bxPreamble\newcommand*\bxBDHookUnicode{% \AtBeginDocument{\bx@assign@Ux}% \bxNullify\bxBDHookUnicode} -\@onlypreamble\bxBDHookUnicode -\@onlypreamble\bx@bdhook@unicode@do %%<+> \bxBDHookJisInput % A begindocument-hook about JIS-code input. -\providecommand\bxBDHookJisInput{\bx@bdhook@jisinput@do} -\def\bx@bdhook@jisinput@do{% +\bxPreamble\newcommand*\bxBDHookJisInput{% \AtBeginDocument{\bx@assign@JI}% \bxNullify\bxBDHookJisInput} -\@onlypreamble\bxBDHookJisInput -\@onlypreamble\bx@bdhook@jisinput@do -%%<+> \bxFallbackSym -\def\bxFallbackSym#1{\leavevmode\bx@fbs@fnt{\dimen@=\bx@junit\relax +%%<+> \bxFallbackSym{<code>} +\newcommand*\bxFallbackSym[1]{% + \leavevmode\bx@fbs@fnt{\dimen@=\bx@junit\relax \hb@xt@\dimen@{\hss\vrule\@width\z@\@height.88\dimen@\@depth.12\dimen@ \frame{\lower.04\dimen@\hb@xt@.84\dimen@{\hss\vbox to.84\dimen@{\vss \hsize=.84\dimen@\baselineskip\z@\lineskip.01\dimen@\parskip\z@skip @@ -375,7 +245,7 @@ %%<+> \bxCodeValueSeq\CS{<text>} % Dispatcher for code value sequences. -\def\bxCodeValueSeq{% +\newcommand*\bxCodeValueSeq{% \let\bx@cvseq@branch\bx@cvseq@branch@hex \bx@cvseq@a} \def\bx@cvseq@a#1#2{% @@ -404,32 +274,31 @@ %%<+> \bxCodeValueSeqD\CS{<text>} % Same as \bxCodeValueSeq, except that it defaults to decimal. -\def\bxCodeValueSeqD{% +\newcommand*\bxCodeValueSeqD{% \let\bx@cvseq@branch\bx@cvseq@branch@dec \bx@cvseq@a} \def\bx@cvseq@branch@dec{% \if !\bx@toka \let\bx@nxt\bx@cvseq@fin \else \let\bx@nxt\bx@cvseq@pfx \fi \bx@nxt} -%%<+> \bxUx, \bxUI, \bxAJ, \bxJI, \bxKI +%%<*> \bxUx, \bxUI, \bxAJ, \bxJI, \bxKI % The prefixed names for \Ux, etc. They are (more likely to be) % collision-safe. -\let\bxUx\relax -\DeclareRobustCommand*\bxUx{\bxCodeValueSeq\bx@Ux} -\let\bxUI\relax -\DeclareRobustCommand*\bxUI{\bxCodeValueSeq\bx@UI} -\let\bxAJ\relax -\DeclareRobustCommand*\bxAJ{\bxCodeValueSeqD\bx@AJ} -\let\bxJI\relax -\DeclareRobustCommand*\bxJI{\bxCodeValueSeq\bx@JI} -\let\bxKI\relax -\DeclareRobustCommand*\bxKI{\bxCodeValueSeqD\bx@KI} +\bxNewrobustcmd*\bxUx{\bxCodeValueSeq\bx@Ux} +\bxNewrobustcmd*\bxUI{\bxCodeValueSeq\bx@UI} +\bxNewrobustcmd*\bxAJ{\bxCodeValueSeqD\bx@AJ} +\bxNewrobustcmd*\bxJI{\bxCodeValueSeq\bx@JI} +\bxNewrobustcmd*\bxKI{\bxCodeValueSeqD\bx@KI} %%<+> \bxUHex{<value>}, \bxUInt{<value>} % Alternative entry points for \Ux. The code value is specified in % hexadecimal (\bxUHex) / decimal (\bxUInt) numerals. -\def\bxUHex{\protect\bx@Uxh} -\def\bxUqInt{\protect\bx@UInt} +\def\bxbz@tmpa{\bxUIntDummyBxutfx} +\bxIfx{\bxUInt\bxbz@tmpa}{\undef\bxUInt}{} +\def\bxbz@tmpa{\bxUHexDummyBxutf} +\bxIfx{\bxUHex\bxbz@tmpa}{\undef\bxUHex}{} +\newcommand*\bxUHex{\protect\bx@Uxh} +\newcommand*\bxUInt{\protect\bx@UInt} \def\bx@UInt#1{\bxUcv=#1\relax\bx@Ux} %% \bx@UIh@fb, \bx@AJ@fb @@ -447,7 +316,7 @@ \bxFallbackSym{{\sml#6}\\#1#2\\#3#4}} \def\bx@hx@supzero#1{\ifx0#1\else\expandafter#1\fi} -%%%% \bx@assign@Ux +%% \bx@assign@Ux % Picks up appropriate drivers \bx@Ux etc. according to current % load-states of packages. % [driver] [purpose] [argument] [default] @@ -477,7 +346,7 @@ \def\bx@UIh@ums#1{\expandafter\UMS\expandafter{#1}} % \CID with \bxUcv \def\bx@AJ@otf{\CID\bxUcv} -\def\bx@assign@Ux{% +\bxPreamble\def\bx@assign@Ux{% % If I have bxucs, then set \bx@Ux to \bx@Ux@ucs % (which fallbacks on \bx@UI in failure). \@ifpackageloaded{bxucs}{% @@ -495,7 +364,7 @@ \@ifpackageloaded{pxotf}{% \let\bx@UIh\bxUIh@otf \let\bx@UI\pxUcvUTF \let\bx@AJ\pxUcvCID}{}% % If I am upTeX I use \kchar. - \ifnum\bx@b@uptex>\z@ + \ifbxinupTeX \def\bx@UI{\kchar\bxUcv}\def\bx@UIh##1{\kchar"##1\relax}% % If I am a Unicode-aware engine, then... \else\ifnum\bxEngineTypeX>\@ne % @@ -515,17 +384,16 @@ \ifx\bx@AJ@usr\@undefined\else \let\bx@AJ\bx@AJ@usr \fi \let\bx@setajdriver@a\bx@setajdriver@b } -\@onlypreamble\bx@assign@Ux -%%%% \setUIdriver\CS -\def\setUIdriver#1{% +%%<*> \setUIdriver\CS +\newcommand*\setUIdriver[1]{% \ifx#1\@undefined \bx@err@uddrv#1% \else \bx@setuidriver@a#1\fi} \def\bx@setuidriver@a#1{\let\bx@UIh@usr#1} \def\bx@setuidriver@b#1{\let\bx@UIh#1} -%%%% \setAJdriver\CS -\def\setAJdriver#1{% +%%<*> \setAJdriver\CS +\newcommand*\setAJdriver[1]{% \ifx#1\@undefined \bx@err@uddrv#1% \else \bx@setajdriver@a#1\fi} \def\bx@setajdriver@a#1{\let\bx@AJ@usr#1} @@ -538,7 +406,7 @@ % \bx@KI Kuten-code \bxUcv fallback \def\bx@JI{\bx@JI@fb} \def\bx@KI{\bx@KI@fb} -\def\bx@assign@JI{% +\bxPreamble\def\bx@assign@JI{% % \JI & \KI are available only in (u)pTeX \ifnum\bxEngineTypeX=\@ne \def\bx@JI{\char\jis\bxUcv\relax}\let\bx@KI\bx@KI@pTeX @@ -557,7 +425,7 @@ \ifnum\bxUcv<\bx@ki@myr \advance\bxUcv\bx@ki@myr \fi \expandafter\bx@ki@ptex@a\the\bxUcv\@nil \bx@ki@char\jis\bxUcv\relax} -\bgroup \@tempcnta=94 +\begingroup \@tempcnta=94 \@for\bx@tmpa:=01,08,03,04,05,12,13,14,15\do{\advance\@tempcnta\@ne \expandafter\xdef\csname bx@JSH/\bx@tmpa\endcsname{\the\@tempcnta}} \@tempcntb=77 \loop @@ -565,111 +433,45 @@ \expandafter\xdef\csname bx@JSH/\the\@tempcntb\endcsname {\the\@tempcnta}% \ifnum\@tempcntb<94 \repeat -\egroup +\endgroup \def\bx@ki@ptex@a#1#2#3#4#5#6\@nil{% \ifnum#1=\@ne \bxUcv=#2#3\relax \else \bxUcv=0\csname bx@JSH/#2#3\endcsname\relax \fi \multiply\bxUcv\@cclvi \advance\bxUcv#4#5\relax \advance\bxUcv\bx@ki@bas} \fi %----</pTeX> -\@onlypreamble\bx@assign@JI - -%%------ Assignment check - -%%%% \bxAssign <assignment>\relax -\def\bxAssign{% - \bxOkfalse\afterassignment\bx@b@assign@a} -\def\bx@b@assign@a#1\relax{% - \def\bx@tmpa{#1}\ifx\bx@tmpa\@empty\bxOktrue\fi} - -%%------ Case conversion - -%%%% \bxToLower{<string>} -% Sets to \bxRes <string> converted to lowercase. -\def\bxToLower#1{% - \edef\bxRes{\lowercase{\def\noexpand\bxRes{#1}}}\bxRes} - -%%%% \bxToUpper{<string>} -\def\bxToUpper#1{% - \edef\bxRes{\uppercase{\def\noexpand\bxRes{#1}}}\bxRes} - -%%------ Document-level specials -% Such specials must come before any typeset commands in DVI. - -%%%% \bxDocumentSpecial{<text>} -% Appends \special{<text>} to the list of 'document-level specials'. -% A simple use of \AtBeginDvi will do in this case. -\def\bxDocumentSpecial#1{% - \AtBeginDvi{\special{#1}}} -\@onlypreamble\bxDocumentSpecial - -%%%% \bxDocumentSpecialUrgent{<text>} -% Similar to the above, but it demands that the given special be -% placed as early as possible. -\def\bxDocumentSpecialUrgent#1{% - \bx@docspec@urgent@init - \bx@prepend@box\bx@dsu@box{\special{#1}}} -\def\bx@prepend@box#1#2{% - \global\setbox#1\vbox{#2\unvbox#1}} -\providecommand\bx@docspec@urgent@init{\bx@docspec@urgent@init@do} -\def\bx@docspec@urgent@init@do{% - \newbox\bx@dsu@box - \AtBeginDocument{% - \ifx\AtBeginShipoutFirst\@undefined - \bx@prepend@box\@begindvibox{\unvbox\bx@dsu@box}% - \else % 'atbegshi' package is in use - {\toks@{\unvbox\bx@dsu@box}% - \toks\tw@\expandafter{\AtBegShi@HookFirst}% - \xdef\AtBegShi@HookFirst{\the\toks@\the\toks\tw@}} - \fi}% - \bxNullify\bx@docspec@urgent@init} -\@onlypreamble\bxDocumentSpecialUrgent -\@onlypreamble\bx@docspec@urgent@init -\@onlypreamble\bx@docspec@urgent@init@do - -%%%% \recordpapersize -\def\recordpapersize{% - \bxDocumentSpecial{papersize=\the\paperwidth,\the\paperheight}% - \bxNullify\recordpapersize} -\@onlypreamble\recordpapersize - -%%<*> \dvipdfmxmapline{<text>} -%%<*> \dvipdfmxmapfile{<text>} -\def\dvipdfmxmapline#1{\bxDocumentSpecial{pdf:mapline #1}} -\@onlypreamble\dvipdfmxmapline -\def\dvipdfmxmapfile#1{\bxDocumentSpecial{pdf:mapfile #1}} -\@onlypreamble\dvipdfmxmapfile - -%%----- "safe-caret" module -\newif\ifbx@acr@ok -\newif\ifbx@acr@needed \bx@acr@neededfalse -\newif\ifbx@safecaret \bx@safecaretfalse -\catcode`\^=13 - -%%%%<*> \safecaret -\def\safecaret{% + +%--------------------------------------- "safe-caret" module + +%% variables +\newbool{bx@acr@ok} +\newbool{bx@acr@needed} +\newbool{bx@safecaret} + +\catcode`\^=13 %---- make caret active + +%%<*> \safecaret +\bxPreamble\newcommand*\safecaret{% \bx@safecarettrue} -\@onlypreamble\safecaret -%%%% \bxEnableSafeCaret -\def\bxEnableSafeCaret{% +%%<+> \bxEnableSafeCaret +\bxPreamble\newcommand*\bxEnableSafeCaret{% \bx@acr@neededtrue} -\@onlypreamble\bxEnableSafeCaret -%%%% \bx@acr@defbytes -\def\bx@acr@defbytes{% +%% \bx@acr@defbytes +\bxPreamble\def\bx@acr@defbytes{% \bgroup\@tempcnta128\lccode`\Z=`\B\catcode`\^\active \@whilenum\@tempcnta<256 \do{% \lccode`\^\@tempcnta \chardef\bx@acr@tok\@tempcnta \expandafter\bx@acr@defbytes@do@a\meaning\bx@acr@tok\@nil \advance\@tempcnta\@ne}\egroup} -\def\bx@acr@defbytes@do@a#1"#2\@nil{% name is bx@acr@B/ab etc. +\bxPreamble\def\bx@acr@defbytes@do@a#1"#2\@nil{% name is bx@acr@B/ab etc. \lowercase{\expandafter\gdef\csname bx@acr@Z/#2\endcsname{^}}} \@onlypreamble\bx@acr@defbytes \@onlypreamble\bx@acr@defbytes@do@a -%%%% \bx@acr@caret -%% This command should be \let'd to active <^>. +%% \bx@acr@caret +% This command should be \let'd to active <^>. \def\bx@acr@caret{% \let\bx@acr@out\@empty \bx@acr@caret@a} \def\bx@acr@caret@a{% @@ -720,13 +522,12 @@ \bx@acr@normcaret #2} \let\bx@acr@normcaret\sp % this does not mean much -%%%% \bx@acr@initialize -\def\bx@acr@initialize{% +%% \bx@acr@initialize +\bxPreamble\def\bx@acr@initialize{% \bx@acr@defbytes} -\@onlypreamble\bx@acr@initialize -%%%% \bx@acr@annihilate -\def\bx@acr@annihilate{% +%% \bx@acr@annihilate +\bxPreamble\def\bx@acr@annihilate{% \let\bx@acr@caret\relax\let\bx@acr@caret@a\relax \let\bx@acr@caret@b\relax\let\bx@acr@caret@c\relax \let\bx@acr@caret@d\relax\let\bx@acr@caret@e\relax @@ -734,30 +535,28 @@ \let\bx@acr@nextcaret\relax\let\bx@acr@nextcaret@a\relax \let\bx@acr@nexthexdgt\relax\let\bx@acr@nexthexdgt@a\relax \let\bx@acr@finish\relax\let\bx@acr@finish@a\relax} -\@onlypreamble\bx@acr@annihilate -%%%% \bx@acr@babel@hookcaret -\def\bx@acr@babel@hookcaret{% +%% \bx@acr@babel@hookcaret +\bxPreamble\def\bx@acr@babel@hookcaret{% \expandafter\ifx\csname active@char\string^\endcsname\relax\else \declare@shorthand\system@group{^}{\bx@acr@caret}% \let\bx@acr@normcaret\bx@acr@babel@normcaret \bxEnableSafeCaret \fi} -\@onlypreamble\bx@acr@babel@hookcaret \edef\bx@acr@babel@normcaret{% \expandafter\noexpand\csname normal@char\string^\endcsname} -%%%% \bx@acr@verbatim@hookcaret -\def\bx@acr@verbatim@hookcaret{% +%% \bx@acr@verbatim@hookcaret +\bxPreamble\def\bx@acr@verbatim@hookcaret{% \g@addto@macro\@noligs{\catcode`\^\active\let^\bx@acr@caret \let\bx@acr@normcaret\bx@acr@verb@normcaret}% \bxEnableSafeCaret} \begingroup \catcode`\^=12 -\global\let\bx@acr@verb@normcaret=^\endgroup -\@onlypreamble\bx@acr@verbatim@hookcaret +\global\let\bx@acr@verb@normcaret=^% +\endgroup -%%%% begin-document hook -\providecommand*\bxBDHookSafeCaret{\bx@bdhook@safecaret@do} -\def\bx@bdhook@safecaret@do{% +%%<+> \bxBDHookSafeCaret +% Begin-document hook. +\bxPreamble\newcommand*\bxBDHookSafeCaret{% \AtBeginDocument{% %% function activated by '\safecaret' \ifbx@safecaret @@ -769,23 +568,106 @@ \else \bx@acr@annihilate \fi \let\bxEnableSafeCaret\@undefined}% \bxNullify\bxBDHookSafeCaret} -\@onlypreamble\bx@bdhook@safecaret@do -\catcode`\^=6 -%%------ "shadow map" module +\catcode`\^=7 %---- make caret normal + +%--------------------------------------- hyphenation something -%%%% \bxUseShadowMap\CS{<map_tfm>} -\def\bxUseShadowMap#1#2{% - \global\font#1=#2\relax} +%%<*> 'withnohyph' environment +\expandafter\ifx\csname l@nohyphenation\endcsname\relax + \newlanguage\l@nohyphenation \fi +\def\withnohyph{\language\l@nohyphenation} +\let\endwithnohyph\relax -%%%% \bxMap\CS -\mathchardef\bx@m@cc=256 -\def\bxMap#1{\begingroup\count@\bxUcv\divide\count@\bx@m@cc - \chardef\bx@m@hb\count@ \multiply\count@\bx@m@cc - \advance\bxUcv-\count@ \setbox\z@\hbox{#1\bx@m@hb\char\bxUcv}% - \global\bxUcv\wd\z@ \endgroup} +%--------------------------------------- patch for 'ucs' package + +%% \bxBDHookUcsFastErrors +% The begin-document hook, which forces the 'fasterrors' option +% of 'ucs' package when running on pTeX. +\bxPreamble\newcommand*\bxBDHookUcsFastErrors{% + \ifbxinpTeX + \AtBeginDocument{% + \@ifpackageloaded{ucs}{% + \let\UnicodeOptionfasterrorsfalse\UnicodeOptionfasterrorstrue + \UnicodeOptionfasterrorstrue}{}}% + \fi + \bxNullify\bxBDHookUcsFastErrors} + +%--------------------------------------- DVI-specials + +%%<*D> \usejapanesepdfstring +\bxPreamble\newcommand*\usejapanesepdfstring{} +\if s\bxInternalJaEncoding + \def\usejapanesepdfstring{% why use CP932?? + \bxDocumentSpecialUrgent{pdf:tounicode 90ms-RKSJ-UCS2}% + \bxNullify\usejapanesepdfstring} +\else\if e\bxInternalJaEncoding + \def\usejapanesepdfstring{% + \bxDocumentSpecialUrgent{pdf:tounicode EUC-UCS2}% + \bxNullify\usejapanesepdfstring} +\else\if u\bxInternalJaEncoding + \def\usejapanesepdfstring{% + \bxDocumentSpecialUrgent{pdf:tounicode UTF8-UCS2}% + \bxNullify\usejapanesepdfstring} +\else + \def\usejapanesepdfstring{% + \bx@warn{\string\usejapanesepdfstring\space ignored,\MessageBreak + since internal encoding is unknown}% + \bxNullify\usejapanesepdfstring} +\fi\fi\fi +\preto\usejapanesepdfstring{% + \bxbz@warn@depre\usejapanesepdfstring{'pxjahyper' package}} + +%%<*D> \recordpapersize +\bxPreamble\newcommand*\recordpapersize{% + \bxbz@warn@depre\recordpapersize{'bxpapersize' package}% + \bxDocumentSpecial{papersize=\the\paperwidth,\the\paperheight}% + \bxNullify\recordpapersize} -%%------ all done -\bx@b@resetcatcodes \let\bx@nxt\relax +%%<*D> \dvipdfmxmapline{<text>} +%%<*D> \dvipdfmxmapfile{<text>} +\bxPreamble\newcommand*\dvipdfmxmapline[1]{% + \bxbz@warn@depre@dpxmap + \bxDocumentSpecial{pdf:mapline #1}} +\bxPreamble\newcommand*\dvipdfmxmapfile[1]{% + \bxbz@warn@depre@dpxmap + \bxDocumentSpecial{pdf:mapfile #1}} +\def\bxbz@warn@depre@dpxmap{% + \bxbz@warn@depre\dvipdfmxmapfile{'pxchfon' package}% + \global\let\bxbz@warn@depre@dpxmap\relax} + +%--------------------------------------- CJK font scaling + +%% \bxbz@doc@class@type +%%<+D> \pxDocClassType +% 1 = pLaTeX standard class +% 2 = New standard classes by Okumura +% 0 = otherwise +\bxUcv=\z@ +\@ifclassloaded{jarticle}{\bxUcv=\@ne}{} +\@ifclassloaded{jreport}{\bxUcv=\@ne}{} +\@ifclassloaded{jbook}{\bxUcv=\@ne}{} +\@ifclassloaded{tarticle}{\bxUcv=\@ne}{} +\@ifclassloaded{treport}{\bxUcv=\@ne}{} +\@ifclassloaded{tbook}{\bxUcv=\@ne}{} +\@ifclassloaded{ujarticle}{\bxUcv=\@ne}{} +\@ifclassloaded{ujreport}{\bxUcv=\@ne}{} +\@ifclassloaded{ujbook}{\bxUcv=\@ne}{} +\@ifclassloaded{utarticle}{\bxUcv=\@ne}{} +\@ifclassloaded{utreport}{\bxUcv=\@ne}{} +\@ifclassloaded{utbook}{\bxUcv=\@ne}{} +\@ifclassloaded{jsarticle}{\bxUcv=\tw@}{} +\@ifclassloaded{jsreport}{\bxUcv=\tw@}{} +\@ifclassloaded{jsbook}{\bxUcv=\tw@}{} +\chardef\bxbz@doc@class@type=\bxUcv +\chardef\pxDocClassType=\bxUcv + +%%<+> \pxUpScale +\edef\pxUpScale{% + \ifx\Cjascale\@undefined + \ifcase\bxbz@doc@class@type 1\or 0.962216\or 0.924690\else 1\fi + \else \Cjascale \fi} + +%--------------------------------------- all done \endinput %% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxbase.sty b/Master/texmf-dist/tex/latex/bxbase/bxbase.sty index d506fc37a62..194d7ccf3f0 100644 --- a/Master/texmf-dist/tex/latex/bxbase/bxbase.sty +++ b/Master/texmf-dist/tex/latex/bxbase/bxbase.sty @@ -1,49 +1,51 @@ -% -% bxbase.sty -% +%% +%% This is file 'bxbase.sty'. +%% +%% Copyright (c) 2017 Takayuki YATO (aka. "ZR") +%% GitHub: https://github.com/zr-tex8r +%% Twitter: @zr_tex8r +%% +%% This package is distributed under the MIT License. +%% -%%%% package declaration +%% package declaration \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{bxbase}[2010/06/15 v0.5 BX base library] +\ProvidesPackage{bxbase}[2017/05/29 v1.1 BX base library] + +%--------------------------------------- main + +%% load submodule +\providecommand*\bxRequireDefinition[1]{% + \def\bxbz@ext{def}\@onefilewithoptions{#1}[][]\bxbz@ext} +\bxRequireDefinition{bxbase} -%%%% include 'bxbase.def' -\input{bxbase.def} +%% enable begin-document hooks \bxBDHookBabel \bxBDHookUnicode +\bxBDHookJisInput \bxBDHookSafeCaret +\bxBDHookUcsFastErrors -%%%% error messages -\def\bx@pkgname{bxbase} -\def\bx@error{\PackageError\bx@pkgname} -\def\bx@alert{\PackageWarningNoLine\bx@pkgname} -\def\bx@warn{\PackageInfo\bx@pkgname} -\def\bx@warn@aecs#1{\px@warn{Command \string#1 already exists}} +%% error messages +\def\bxbz@pkgname{bxbase} +\def\bxbz@inf@aecsq#1{% + \PackageInfo\bxbz@pkgname + {Command \string#1 already exists}} -%%------ +%--------------------------------------- extra -%%<*> \Ux, \UI, \AJ -\ifx\Ux\@undefined \def\Ux{\bxUx}% -\else \px@warn@aecs\Ux \fi -\ifx\UI\@undefined \def\UI{\bxUI}% -\else \px@warn@aecs\UI \fi -\ifx\AJ\@undefined \def\AJ{\bxAJ}% -\else \px@warn@aecs\AJ \fi +%%<*> \Ux / \UI / \AJ / \JI / \KI +% define commands unless their name is already used +\bxPreamble\def\bxbz@charcmd#1#2{% + \ifundef#1{\def#1{#2}}{\bxbz@inf@aecsq#1}} +\bxbz@charcmd\Ux\bxUx +\bxbz@charcmd\UI\bxUI +\bxbz@charcmd\AJ\bxAJ +\bxbz@charcmd\JI\bxJI +\bxbz@charcmd\KI\bxKI -%%<*> \JI, \KI -\ifx\JI\@undefined \def\JI{\bxJI}% -\else \px@warn@aecs\JI \fi -\ifx\KI\@undefined \def\KI{\bxKI}% -\else \px@warn@aecs\KI \fi - -%%%% withnohyph environment -\expandafter\ifx\csname l@nohyphenation\endcsname\relax - \newlanguage\l@nohyphenation \fi -\def\withnohyph{\language\l@nohyphenation} -\let\endwithnohyph\relax - -%%------ all done +%--------------------------------------- all done \endinput -%% EOF % % * bxbase provides: % - bx@Uxh@fb (terminal) @@ -68,3 +70,4 @@ % v v % bx@UI > bx@UIh = bx@Uxh@fb or bx@UIh@p % +%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ext.def b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ext.def new file mode 100644 index 00000000000..63b7927f5c6 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ext.def @@ -0,0 +1,563 @@ +%% +%% This is file 'bxtoolbox-ext.def'. +%% + +%% file declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{bxtoolbox-ext.def}[2017/05/29 v1.1] + +%% check intergrity +\edef\bxtb@tmpa{\@currname.\@currext}\def\bxtb@tmpb{bxtoolbox-ext.def} +\ifx\bxtb@tmpa\bxtb@tmpb\else + \PackageError\bxtb@pkgname{Illegal load sequence}\@eha +\expandafter\endinput\fi\relax + +%% load submodule +\providecommand*\bxRequireDefinition[1]{% + \def\bx@@def{def}\@onefilewithoptions{#1}[][]\bx@@def} +\bxRequireDefinition{bxtoolbox} + +%% code guards +\edef\bxtb@x@restore@codes{% + \catcode33=\the\catcode33% + \catcode34=\the\catcode34% + \catcode39=\the\catcode39% + \catcode45=\the\catcode45% + \catcode46=\the\catcode46% + \catcode47=\the\catcode47% + \catcode58=\the\catcode58% + \catcode59=\the\catcode59% + \catcode60=\the\catcode60% + \catcode62=\the\catcode62% + \catcode96=\the\catcode96% +\relax} +\catcode33=12 % <!> +\catcode34=12 % <"> +\catcode39=12 % <'> +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\catcode58=12 % <:> +\catcode59=12 % <;> +\catcode60=12 % <<> +\catcode62=12 % <>> +\catcode96=12 % <`> +\AtEndOfPackage{% + \bxtb@x@restore@codes + \undef\bxtb@x@restore@codes} + +%--------------------------------------- general + +%% variables +\bxIfcsundefX{ifbxOk}{\newbool{bxOk}}{} % all-purpsoe switch +\bxIfcsundefX{bxResDim}{\newdimen\bxResDim}{} +\let\bxHex\relax % result of \bxToHex... +\let\bxRes\relax % result of \bxToLower + +%% error messages +\def\bxtb@err@oorng{\bxtb@error{Number out of range}\@eha} + +%--------------------------------------- programming tools + +%%<+> \bxDebug{<text>} +% Prints a debug message. By default, it is no-op. +\providecommand*\bxDebug{\@gobble} + +%%<+> \bxShowbool{<name>} +\newcommand*{\bxShowbool}[1]{\ifbool{#1}{true}{false}} + +%%<+> \bxShowtoggle{<name>} +\newcommand*{\bxShowtoggle}[1]{\iftoggle{#1}{true}{false}} + +%%<+> \bxRequireDefinition +% Same as \RequirePackage except that it loads '.def' files. +% [Definition appears near the top of this file] +%%<+D> \bxInputDefFile +% Old name for \bxRequireDefinition +\bxPreamble\newcommand*{\bxInputDefFile}{\bxRequireDefinition} + +%%<+> \bxNullify\CS +% Make \CS void and unoverridable by \providecommand. +\def\bxNullify#1{\global\let#1\bx@nullified} +\def\bx@nullified{\@gobble\bx@@nullified} + +%%<+> \bxForEachIn<arg>,...\do{<repl_text>} +%%<+> \bxForEachTokenIn<arg>,...\do{<repl_text>} +\newcommand*\bxForEachIn{\bxtb@forei@a\@for} +\newcommand*\bxForEachTokenIn{\bxtb@forei@a\@tfor} +\def\bxtb@forei@a#1#2\do#{% + \def\bxtb@forei@b{#1\bxtb@forei@x:=#2\do + {\expandafter\bxtb@forei@do\expandafter{\bxtb@forei@x}}}% + \afterassignment\bxtb@forei@b \def\bxtb@forei@do##1} + +%%<+> \bxWithArgExpd{<arg1>}\do{<repl-text>} +%%<+> \bxWithArgFullExpd{<arg1>}\do{<repl-text>} +\newcommand*\bxWithArgExpd{} +\def\bxWithArgExpd#1\do#{% + \expandafter\bxtb@with@arg@expd@a#1\@nil} +\def\bxtb@with@arg@expd@a#1\@nil{% + \def\bxtb@with@args@expd@do{\bxtb@do{#1}}% + \afterassignment\bxtb@with@args@expd@do + \def\bxtb@do##1} +\newcommand*\bxWithArgFullExpd{} +\def\bxWithArgFullExpd#1\do#{% + \edef\bxtb@args{{#1}}% + \def\bxtb@with@args@expd@do{\expandafter\bxtb@do\bxtb@args}% + \afterassignment\bxtb@with@args@expd@do + \def\bxtb@do##1} + +%%<+> \bxWithArgsExpd{<arg1>}...\do{<repl-text>} +%%<+> \bxWithArgsFullExpd{<arg1>}...\do{<repl-text>} +\newcommand*\bxWithArgsExpd{% + \begingroup + \count@=\z@ \let\do\bxtb@uniq + \let\bxtb@l@tmpa\@empty + \bxtb@with@args@expd@gth@a} +\def\bxtb@with@args@expd@gth@a{% + \futurelet\bxtb@tok\bxtb@with@args@expd@gth@b} +\def\bxtb@with@args@expd@gth@b{% + \bxIfx{\bxtb@tok\bxtb@uniq}% + {\bxtb@with@args@expd@pst@a}% + {\bxtb@with@args@expd@gth@c}} +\def\bxtb@with@args@expd@gth@c#1{% + \expandafter\bxtb@with@args@expd@gth@d#1\@nil} +\def\bxtb@with@args@expd@gth@d#1\@nil{% + \ifnum\count@<9 + \appto\bxtb@l@tmpa{{#1}}% + \advance\count@\@ne + \fi + \bxtb@with@args@expd@gth@a} +\def\bxtb@with@args@expd@pst@a#1{% + \@whilenum\count@<9 \do{% + \appto\bxtb@l@tmpa{{}}\advance\count@\@ne}% + \expandafter\def\expandafter\bxtb@l@tmpa\expandafter{% + \expandafter{\bxtb@l@tmpa}}% + \xpreto\bxtb@l@tmpa{\noexpand\bxtb@with@args@expd@ppst@a}% + \expandafter\endgroup\bxtb@l@tmpa} +\newcommand*\bxWithArgsFullExpd{% + \bxtb@with@args@fexpd@a\@nil} +\def\bxtb@with@args@fexpd@a\@nil#1\do{% + \bxtb@with@args@fexpd@b#1{}{}{}{}{}{}{}{}{}\do} +\def\bxtb@with@args@fexpd@b#1#2#3#4#5#6#7#8#9{% + \edef\bxtb@with@args@fexpd@d{% + \noexpand\bxtb@with@args@expd@ppst@a + {{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}}% + \bxtb@with@args@fexpd@c} +\def\bxtb@with@args@fexpd@c#1\do#{% + \bxtb@with@args@fexpd@d} +\def\bxtb@with@args@expd@ppst@a#1{% + \def\bxtb@with@args@expd@do{\bxtb@do#1}% + \afterassignment\bxtb@with@args@expd@do + \def\bxtb@do##1##2##3##4##5##6##7##8##9} + +%%<+> \bxAssign <assignment>\relax +% Do an assignment and checks if the assignment statement is +% free of garbage and returns the result to \ifbxOk. +\newcommand*\bxAssign{% + \bxOkfalse\afterassignment\bx@b@assign@a} +\def\bx@b@assign@a#1\relax{% + \def\bx@tmpa{#1}\ifx\bx@tmpa\@empty\bxOktrue\fi} + +%%<+> \bxChompComma\CS +\newcommand*\bxChompComma[1]{% + \expandafter\bxtb@chomp@comma@a#1\bxtb@chomp@comma@end#1} +\def\bxtb@chomp@comma@a{% + \futurelet\bxtb@tmpa\bxtb@chomp@comma@b} +\def\bxtb@chomp@comma@b{% + \bxIfx{,\bxtb@tmpa}{\bxtb@chomp@comma@c}% + {\bxtb@chomp@comma@skip}} +\def\bxtb@chomp@comma@c#1\bxtb@chomp@comma@end#2{% + \expandafter\def\expandafter#2\expandafter{\@gobble#1}} +\def\bxtb@chomp@comma@skip#1\bxtb@chomp@comma@end#2{} + +%% \bxProcessOptions[*] +\newcommand*\bxProcessOptions{% + \@ifstar{\@tempswatrue\bxtb@process@options}% + {\@tempswafalse\bxtb@process@options}} +\def\bxtb@process@options{% + \let\bxtb@org@@removeelement\@removeelement + \let\@removeelement\bxtb@@removeelement + \if@tempswa \ProcessOptions*% + \else \ProcessOptions\relax \fi + \let\@removeelement\bxtb@org@@removeelement} +\def\bxtb@@removeelement#1#2#3{% + \bxtb@rem@elt@check#1\relax{}\bxtb@rem@elt@end + \if@tempswa \bxtb@org@@removeelement{#1}{#2}#3\fi} +\def\bxtb@rem@elt@check#1#{\bxtb@rem@elt@check@a} +\def\bxtb@rem@elt@check@a#1#2\bxtb@rem@elt@end{% + \ifstrempty{#2}{\@tempswatrue}{\@tempswafalse}} + +%--------------------------------------- character tokens + +%%<+> \ifbxHasUcsChar +\newbool{bxHasUcsChar} +\ifbxinOmega \bxHasUcsChartrue \fi +\ifbxinXeTeX \bxHasUcsChartrue \fi +\ifbxinLuaTeX \bxHasUcsChartrue \fi +\ifbxinupTeX \bxHasUcsChartrue \fi +\csletcs{ifbx@hx@bigchar}{ifbxHasUcsChar} + +%%<+> \ifbxHasAlUcsChar +\newbool{bxHasAlUcsChar} +\ifbxinOmega \bxHasAlUcsChartrue \fi +\ifbxinXeTeX \bxHasAlUcsChartrue \fi +\ifbxinLuaTeX \bxHasAlUcsChartrue \fi + +%%<+> \bxToChar{<num>} +% Makes \bxRes expand to a single character token with character +% code <num>. Note that in (u)pTeX this is valid only for 'alphabet' +% characters. +\newcommand*\bxToChar[1]{% + \bgroup \lccode`!=#1\relax + \lowercase{\xdef\bx@tch@g@temp{!}}% + \egroup \let\bxRes\bx@tch@g@temp} + +%%<+> \bxToJaChar{<num>} +% Makes \bxRes expand to a single CJK character token with +% character code <num> (in internal CJK encoding). +\ifbxinpTeX + \newcommand*\bxToJaChar[1]{% + \bgroup \bxtb@forcecjktoken + \kansujichar\@ne=#1\relax + \xdef\bx@tch@g@temp{\kansuji\@ne}% + \egroup \let\bxRes\bx@tch@g@temp} + \ifdef{\forcecjktoken}% + {\let\bxtb@forcecjktoken\forcecjktoken}% + {\let\bxtb@forcecjktoken\relax}% +\fi + +%%<+> \bxToUcsChar{<num>} +% Makes \bxRes expand to a single character token with +% character code <num> (in Unicode); valid for Unicode-aware +% engines plus upTeX. +\ifbxinupTeX +\let\bxToUcsChar\bxToJaChar +\else\ifbxHasAlUcsChar +\let\bxToUcsChar\bxToChar +\fi\fi + +%%<+> \bxToUcsCharDual{<jis>}{<ucs>} +% Makes \bxRes expand to a single character token with the following +% character code: (1) on pTeX, <jis> in internal CJK encoding; and +% (2) on Unicode-aware engines, <ucs> in Unicode. +\ifdef{\bxToUcsChar} + {\newcommand*\bxToUcsCharDual[2]{\bxToUcsChar{#2}}}% + {\newcommand*\bxToUcsCharDual[2]{\bxToJaChar{\jis#1}}} + +%%<+> \bxToUcsCharSeq{<jis>:<ucs>,...} +\newcommand*\bxToUcsCharSeq[1]{% + \let\bx@tch@temp\@empty + \bxForEachIn#1\do{\bxtb@toucs@charseq@a##1\bxtb@end}% + \let\bxRes\bx@tch@temp} +\def\bxtb@toucs@charseq@a#1:#2\bxtb@end{% + \bxToUcsCharDual{"#1}{"#2}% + \eappto\bx@tch@temp{\bxRes}} + +%--------------------------------------- number to hex-string +% All public commands put their result in \bxHex. + +%%<+> \bxToHexTiny +% For one-to-two-digit hex strings. +\newcommand*\bxToHexTiny[1]{% + \chardef\bxHex=#1\relax + \expandafter\bx@hx@tohextiny@a\meaning\bxHex\@nil} +\def\bx@hx@tohextiny@a#1"#2\@nil{\def\bxHex{#2}} + +%%<+> \bxToHexSmall +% For one-to-three-digit hex strings. +\newcommand*\bxToHexSmall[1]{% + \mathchardef\bxHex=#1\relax + \expandafter\bx@hx@tohexsmall@a\meaning\bxHex\@nil} +\def\bx@hx@tohexsmall@a#1"#2\@nil{\def\bxHex{#2}} + +%%<+> \bxToHexTwo +% For zero-padded two-digit hex strings. +\newcommand*\bxToHexTwo[1]{% + \chardef\bxHex=#1\relax + \expandafter\bx@hx@tohextwo@a\meaning\bxHex"0\@nil} +\def\bx@hx@tohextwo@a#1"#2#3#4#5\@nil{\bx@hx@tohextwo@b#2#3#4\@nil} +\def\bx@hx@tohextwo@b#1"#2\@nil{\def\bxHex{#2#1}} + +%%<+> \bxToHexThree +% For zero-padded three-digit hex strings. +\newcommand*\bxToHexThree[1]{% + \mathchardef\bxHex=#1\relax + \expandafter\bx@hx@tohexthree@a\meaning\bxHex"00\@nil} +\def\bx@hx@tohexthree@a#1"#2#3#4#5#6\@nil{\bx@hx@tohexthree@b#2#3#4#5\@nil} +\def\bx@hx@tohexthree@b#1"#2\@nil{\def\bxHex{#2#1}} + +%%<+> \bxToHexFour +% For zero-padded four-digit hex strings. +\ifbx@hx@bigchar %----<*bigchar> +\newcommand*\bxToHexFour[1]{% + \chardef\bxHex=#1\relax + \expandafter\bx@hx@tohexfour@a\meaning\bxHex"000\@nil} +\def\bx@hx@tohexfour@a#1"#2#3#4#5#6#7\@nil{\bx@hx@tohexfour@b#2#3#4#5#6\@nil} +\def\bx@hx@tohexfour@b#1"#2\@nil{\def\bxHex{#2#1}} +\else %----<*!bigchar> +\mathchardef\bx@hx@fzzz="4000 +\newcommand*\bxToHexFour[1]{\bgroup + \@tempcnta=#1\relax\@tempcntb\@tempcnta\divide\@tempcntb\bx@hx@fzzz + \ifcase\@tempcntb \advance\@tempcnta\bx@hx@fzzz \or \or + \advance\@tempcnta-\bx@hx@fzzz \or \advance\@tempcnta-"8000 \or + \@tempcnta\z@ \fi + \mathchardef\bx@hx@tmp\@tempcnta + \expandafter\bx@hx@tohexfour@a\meaning\bx@hx@tmp\@nil + \egroup \let\bxHex\bx@hx@gtmp} +\def\bx@hx@tohexfour@a#1"#2#3\@nil{% + \expandafter\let\expandafter\bx@hx@tmp + \csname bxhx@X/\the\@tempcntb#2\endcsname + \ifx\bx@hx@tmp\relax \bxtb@err@oorng \global\let\bx@hx@gtmp\@empty + \else \xdef\bx@hx@gtmp{\bx@hx@tmp#3}\fi} +\def\bx@hx@nxt#1#2#3{\bgroup\catcode`#3=12 + \global\expandafter\def\csname bxhx@X/#1#2\endcsname{#3}\egroup} +\@for\bx@hx@tmp:={040,051,062,073,144,155,166,177,248,259,26A,27B,% + 34C,35D,36E,37F}\do{\expandafter\bx@hx@nxt\bx@hx@tmp} +\fi %----</bigchar> + +%%<+> \bxToHexFive +%%<+> \bxToHexFiveX +% For zero-padded five-digit hex strings. +\newcommand*\bxToHexFive{\bx@tohexfive@aa\relax} +\newcommand*\bxToHexFiveX{\bx@tohexfive@aa + {\ifnum\@tempcnta>\bx@hx@vdmax \@tempcnta=\bx@hx@vdmax\fi}} +\ifbx@hx@bigchar %----<*bigchar> +\chardef\bx@hx@vdmax="FFFFF +\def\bx@tohexfive@aa#1#2{% + {\@tempcnta=#2\relax#1\global\chardef\bx@hx@gtmp=\@tempcnta}% + \expandafter\bx@hx@tohexfivex@a\meaning\bx@hx@gtmp"0000\@nil} +\def\bx@hx@tohexfivex@a#1"#2#3#4#5#6#7#8\@nil{% + \bx@hx@tohexfivex@b#2#3#4#5#6#7\@nil} +\def\bx@hx@tohexfivex@b#1"#2\@nil{\edef\bxHex{#2#1}} +\else %----<*!bigchar> +\edef\bx@hx@vdmax{"FFFFF\space} +\def\bx@tohexfive@aa#1#2{% + \bgroup \@tempcnta=#2\relax#1% + \@tempcntb=\@tempcnta \divide\@tempcnta\bx@hx@m\relax + \bxToHexTwo\@tempcnta \let\bx@hx@tmp\bxHex + \multiply\@tempcnta-\bx@hx@m\advance\@tempcnta\@tempcntb\relax + \bxToHexThree\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% + \egroup \let\bxHex\bx@hx@gtmp} +\fi %----</bigchar> + +%%<+> \bxToHexEight +% For zero-padded eight-digit hex strings. +\newcommand*\bxToHexEight[1]{% + \bgroup \@tempcnta=#1\relax + \@tempcntb=\@tempcnta\divide\@tempcnta\p@\relax + \bxToHexFour\@tempcnta \let\bx@hx@tmp\bxHex + \multiply\@tempcnta-\p@\advance\@tempcnta\@tempcntb\relax + \bxToHexFour\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% + \egroup \let\bxHex\bx@hx@gtmp} + +%%<+> \bxToHexUC +% For zero-padded four-to-six-digit hex strings. +\ifbx@hx@bigchar %----<*bigchar> +\newcommand*\bxToHexUC[1]{% + \chardef\bxHex=#1\relax + \expandafter\bx@hx@tohexuc@a\meaning\bxHex"\@empty\@empty000\@nil} +\def\bx@hx@tohexuc@a#1"#2#3#4#5#6#7#8#9\@nil{% + \bx@hx@tohexuc@b#2#3#4#5#6#7#8\@nil} +\def\bx@hx@tohexuc@b#1"#2\@nil{\edef\bxHex{#2#1}} +\else %----<*!bigchar> +\mathchardef\bx@hx@m="1000 +\newcommand*\bxToHexUC[1]{% + \bgroup \@tempcnta=#1\relax + \@tempcntb=\@tempcnta \divide\@tempcnta\bx@hx@m\relax + \bxToHexSmall\@tempcnta \let\bx@hx@tmp\bxHex + \multiply\@tempcnta-\bx@hx@m\advance\@tempcnta\@tempcntb\relax + \bxToHexThree\@tempcnta \xdef\bx@hx@gtmp{\bx@hx@tmp\bxHex}% + \egroup \let\bxHex\bx@hx@gtmp} +\fi %----</bigchar> + +%%<+> \bxToDecFour +\newcommand*\bxToDecFour[1]{% + \expandafter\bx@hx@todecfour@a\number#1"000\@nil} +\def\bx@hx@todecfour@a#1#2#3#4#5#6\@nil{\bx@hx@todecfour@b#1#2#3#4#5\@nil} +\def\bx@hx@todecfour@b#1"#2\@nil{\def\bxHex{#2#1}} + +%%<+> \bxToDecFive +\newcommand*\bxToDecFive[1]{% + \expandafter\bx@hx@todecfive@a\number#1"0000\@nil} +\def\bx@hx@todecfive@a#1#2#3#4#5#6#7\@nil{\bx@hx@todecfive@b#1#2#3#4#5#6\@nil} +\def\bx@hx@todecfive@b#1"#2\@nil{\def\bxHex{#2#1}} + +%--------------------------------------- case conversion + +%%<+> \bxToLower{<string>} +% Sets to \bxRes <string> converted to lowercase. +\newcommand*\bxToLower[1]{% + \edef\bxRes{\lowercase{\def\noexpand\bxRes{#1}}}\bxRes} + +%%<+> \bxToUpper{<string>} +\newcommand*\bxToUpper[1]{% + \edef\bxRes{\uppercase{\def\noexpand\bxRes{#1}}}\bxRes} + +%--------------------------------------- document-level specials +% Such specials must come before any typeset commands in DVI. + +%%<+> \bxDocumentSpecial{<text>} +% Appends \special{<text>} to the list of 'document-level specials'. +% A simple use of \AtBeginDvi will do in this case. +\bxPreamble\newcommand*\bxDocumentSpecial[1]{% + \bxAtBeginDviX{\special{#1}}} + +%%%% \bxDocumentSpecialUrgent{<text>} +% Similar to the above, but it demands that the given special be +% placed as early as possible. +\bxPreamble\newcommand*\bxDocumentSpecialUrgent[1]{% + \bx@docspec@urgent@init + \bx@prepend@box\bx@dsu@box{\special{#1}}} +\def\bx@prepend@box#1#2{% + \global\setbox#1\vbox{\bxToYokoDir#2\unvbox#1}} +\bxPreamble\def\bx@docspec@urgent@init{% + \newbox\bx@dsu@box + \AtBeginDocument{% + \ifx\AtBeginShipoutFirst\@undefined + \bx@prepend@box\@begindvibox{\unvbox\bx@dsu@box}% + \else % 'atbegshi' package is in use + {\toks@{\unvbox\bx@dsu@box}% + \toks\tw@\expandafter{\AtBegShi@HookFirst}% + \xdef\AtBegShi@HookFirst{\the\toks@\the\toks\tw@}} + \fi}% + \bxNullify\bx@docspec@urgent@init} + +%--------------------------------------- "shadow map" module + +%%<+> \bxUseShadowMap\CS{<map_tfm>} +\bxPreamble\newcommand*\bxUseShadowMap[2]{% + \global\font#1=#2\relax} + +%%<+> \bxMap\CS +\mathchardef\bx@m@cc=256 +\bxPreamble\newcommand*\bxMap[1]{% + \begingroup\count@\bxUcv\divide\count@\bx@m@cc + \chardef\bx@m@hb\count@ \multiply\count@\bx@m@cc + \advance\bxUcv-\count@ \setbox\z@\hbox{#1\bx@m@hb\char\bxUcv}% + \global\bxUcv\wd\z@ \endgroup} + +%--------------------------------------- module name + +%%<+> \bxSetModuleName{<name>} +\newcommand*\bxSetModuleName[1]{% + \csxdef{bx@modname/\@currname.\@currext}{#1}} +\let\bxtb@modname@default\bx@pkgname % name of this bundle + +%%<+> \bxModuleName +\@ifpackageloaded{ifptex}{\undef\bxModuleName}{} +\newcommand*\bxModuleName{% + \bxIfcsundefX{bx@modname/\@currname.\@currext}% + {\bxIfx{\@currname\@empty}{\bxtb@modname@default}% + {\@currname}}% + {\@nameuse{bx@modname/\@currname.\@currext}}} + +%%<+> \bxCurrentError / \bxCurrentWarning +%%<+> \bxCurrentWarningNoLine / \bxCurrentInfo +\newcommand*\bxCurrentError{\PackageError\bxModuleName} +\newcommand*\bxCurrentWarning{\PackageWarning\bxModuleName} +\newcommand*\bxCurrentWarningNoLine{% + \PackageWarningNoLine\bxModuleName} +\newcommand*\bxCurrentInfo{\PackageInfo\bxModuleName} + +%--------------------------------------- keyval extension + +%%<+> \bxPrepareSetKeysSafe +\bxPreamble\newcommand*\bxPrepareSetKeysSafe{% + \IfFileExists{xkeyval.sty}{\@tempswatrue}{\@tempswafalse}% + \if@tempswa + \RequirePackage{xkeyval}% + \def\bxtb@setkeys@safe##1##2{% + \setkeys*{##1}{##2}% +% \bxDebug{\XKV@rm}% + \bxForEachIn\XKV@rm\do{\bxtb@setkeys@safe@a####1=\@nil}}% + \def\bxtb@setkeys@safe@a##1=##2\@nil{% + \bxtb@setkeys@safe@b{##1}}% + \else + \RequirePackage{keyval}% + \def\bxtb@setkeys@safe##1##2{% + \let\bxtb@KV@errx\KV@errx + \let\KV@errx\bxtb@setkeys@safe@a + \setkeys{##1}{##2}% + \let\KV@errx\bxtb@KV@errx}% + \def\bxtb@setkeys@safe@a##1{% + \expandafter\bxtb@setkeys@safe@b\expandafter{\@tempa}}% + \fi + \let\bxPrepareSetKeysSafe\relax} + +%%<+> \bxSetKeysSafe +\newcommand*\bxSetKeysSafe[2]{% + \let\bxRestKeys\@empty + \bxtb@setkeys@safe{#1}{#2}% + \edef\bxRestKeys{\expandafter\@gobble\bxRestKeys\@empty}} +\def\bxtb@setkeys@safe@b#1{% + \edef\bxRestKeys{\bxRestKeys,#1}} +\def\bxtb@setkeys@safe#1#2{\bxCurrentError + {\string\bxSetKeysSafe\space not enabled}\@ehc} + +%--------------------------------------- driver handling + +%%<+> \bxDriverList +\providecommand*\bxDriverList{dvips,dvipdfmx,dviout} + +%%<+> \bxDriverInherent +\newcommand*\bxDriverInherent{} +\bxIfinXeTeX{\def\bxDriverInherent{xetex}}{} +\bxIfPdfOutput{\def\bxDriverInherent{pdftex}}{} + +%%<+> \bxDriver +\newcommand*\bxDriver{% + \bxIfx{\bxDriverInherent\@empty}% + {\bxIfcsundefX{bx@driver/\@currname.\@currext}{default}% + {\@nameuse{bx@driver/\@currname.\@currext}}}% + {\bxDriverInherent}} + +%%<+> \bxSetDriver[<file>]{<driver>} +\newcommand*\bxSetDriver{% + \@ifnextchar[% + {\bxtb@set@driver@a}{\bxtb@set@driver@a[\@currname.\@currext]}} +\def\bxtb@set@driver@a[#1]#2{% + \bxIfx{\bxDriverInherent\@empty}{}{\bx@warn@ivdrv{#2}}% +% \bxDebug{set driver for #1 to #2}% + \csxdef{bx@driver/#1}{#2}} +\def\bx@warn@ivdrv#1{\bxCurrentWarningNoLine + {Driver specification '#1' ignored;\MessageBreak + driver is inherently set to '\bxDriverInherent'}} + +%%<+> \bxDriverSpecifiedFor{<file>} +\newcommand*\bxDriverSpecifiedFor[1]{% + \bxCsuseX{bx@driver/#1}} + +%%<+> \bxDefineDDProcess{<name>}{<driver>}{<text>} +%%<+> \bxDefineDDProcessDefault{<name>}{<text>} +\newcommand*\bxDefineDDProcess[2]{% + \csdef{#1@@#2}} +\newcommand*\bxDefineDDProcessDefault[1]{% + \csdef{#1@@default}} + +%%<+> \bxDoDDProcess{<name>} +\bxNewrobustcmd*\bxDoDDProcess[1]{% + \edef\bxtb@drv{\bxDriver}% + \def\bxtb@do@ddproc@try{\bxtb@do@ddproc@try@a{#1}}% + \bxtb@do@ddproc@try\bxtb@drv + \bxCsuse{bxtb@do@ddproc@fb@@\bxtb@drv}% + \bxtb@do@ddproc@try{default}% + \bxtb@do@ddproc@try@end} +\def\bxtb@do@ddproc@try@a#1#2{% +% \bxDebug{try #1@@#2}% + \bxIfcsundefX{#1@@#2}{}% + {\csname#1@@#2\endcsname + \bxtb@do@ddproc@skip}} +\def\bxtb@do@ddproc@skip#1\bxtb@do@ddproc@try@end{} +\let\bxtb@do@ddproc@try@end\@empty +\def\do{\noexpand\bxtb@do@ddproc@try} +% fallback setup +\edef\bxtb@do@ddproc@fb@@xetex{\do{dvipdfmx}} + +%%<+> \bxDeclareDriverOptions +\newcommand*\bxDeclareDriverOptions{% + \bxForEachIn\bxDriverList\do{% + \DeclareOption{##1}{\bxSetDriver{##1}}}} + +%--------------------------------------- all done +\endinput +%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ja.def b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ja.def new file mode 100644 index 00000000000..a522d6e29a8 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox-ja.def @@ -0,0 +1,186 @@ +%% +%% This is file 'bxtoolbox-ja.def'. +%% + +%% file declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{bxtoolbox-ja.def}[2017/05/29 v1.1] + +%% check intergrity +\edef\bxtb@tmpa{\@currname.\@currext}\def\bxtb@tmpb{bxtoolbox-ja.def} +\ifx\bxtb@tmpa\bxtb@tmpb\else + \PackageError\bxtb@pkgname{Illegal load sequence}\@eha +\expandafter\endinput\fi\relax + +%% load submodule +\providecommand*\bxRequireDefinition[1]{% + \def\bx@@def{def}\@onefilewithoptions{#1}[][]\bx@@def} +\bxRequireDefinition{bxtoolbox-ext} + +%% code guards +\edef\bxtb@j@restore@codes{% + \catcode34=\the\catcode34% + \catcode45=\the\catcode45% + \catcode46=\the\catcode46% + \catcode47=\the\catcode47% + \catcode58=\the\catcode58% + \catcode59=\the\catcode59% + \catcode63=\the\catcode63% + \catcode96=\the\catcode96% +\relax} +\catcode34=12 % <"> +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\catcode58=12 % <:> +\catcode59=12 % <;> +\catcode63=12 % <?> +\catcode96=12 % <`> +\AtEndOfPackage{% + \bxtb@j@restore@codes + \undef\bxtb@j@restore@codes} + +%--------------------------------------- pTeX something + +%% switch 'bxtb@pxbase@ok' +\newbool{bxtb@pxbase@ok} +\ifbxinpTeX + \IfFileExists{pxbase.sty}{% + \bxtb@pxbase@oktrue + }{} +\fi + +%%<+> \bxToYokoDir +% Switches to horizontal(yoko) writing direction +% when using pTeX. +\ifbxinpTeX %----<*pTeX> +\newcommand*\bxToYokoDir{% + \bxIfydir{}{\yoko}} +\else %----<*!pTeX> +\newcommand*\bxToYokoDir{} +\fi %----</pTeX> + +%%<+> \bxAtBeginDviX +% \AtBeginDvi that is safe to use in pTeX. +\newcommand\bxAtBeginDviX[1]{% + \global\setbox\@begindvibox\vbox{% + \bxToYokoDir\unvbox\@begindvibox#1}} + +%--------------------------------------- Japanese something + +%%<+> \bxGetZenkakuWidth +% Assigns 1zw to \bxResDim +\ifbxinpTeX + \bxNewrobustcmd*\bxGetZenkakuWidth{% + \bxResDim=1zw\relax} +\else\ifbxHasAlUcsChar + \bxToUcsChar{"4E00}\let\bx@jan@onekanji\bxRes + \bxNewrobustcmd*\bxGetZenkakuWidth{% + \begingroup \setbox\z@\hbox{\bx@jan@onekanji}% + \xdef\bx@jan@g@next{\bxResDim=\the\wd\z@\relax}% + \endgroup \bx@jan@g@next} + \AtBeginDocument{% + \ifdef\jsZw{% + \bxRenewrobustcmd*\bxGetZenkakuWidth{% + \bxResDim=1\jsZw}}{}% + \ifdef\zw{% + \bxRenewrobustcmd*\bxGetZenkakuWidth{% + \bxResDim=1\zw}}{}% + } +\fi\fi + +%%<+> \bxIfCharToken{<token>}{<yes>}{<no>} +% Tests if the token is a character token with catcode 11 or 12. +\newcommand*\bxIfCharToken[1]{% + \bxIfcat{\relax\noexpand#1}{\@secondoftwo}% + {\expandafter\bxtb@ifchartok@a\meaning#1\bxtb@end}} +\def\bxtb@ifchartok@a#1{% + \bxIfcsundefX{bxtb@ICTF/#1}{\bxtb@ifchartok@false}% + {\bxtb@ifchartok@b#1}} +\def\bxtb@ifchartok@b#1#2#3#4#5#6{% + \bxIfcsundefX{bxtb@ICT/#1#2#3#4#5#6}{\bxtb@ifchartok@false}% + {\bxtb@ifchartok@true}} +\def\bxtb@ifchartok@true#1\bxtb@end#2#3{#2} +\def\bxtb@ifchartok@false#1\bxtb@end#2#3{#3} +\def\do#1#2:{\cslet{bxtb@ICTF/#1}{t}\cslet{bxtb@ICT/#1#2}{t}} +\do thelet:% 11 +\do thecha:% 12 +\do kanjic:% 16-19(upTeX) + +%--------------------------------------- kanji-encoding something + +%%<+> \bxInternalJaEncoding +\let\bxInternalJaEncoding=? +\ifbxHasAlUcsChar + \let\bxInternalJaEncoding=u +\else\ifbxinpdfTeX + \let\bxInternalJaEncoding=b +\else\ifbxinpTeX + \ifnum\jis"2121="8140 \let\bxInternalJaEncoding=s\else + \ifnum\jis"2121="A1A1 \let\bxInternalJaEncoding=e\else + \ifnum\jis"2121="3000 \let\bxInternalJaEncoding=u\fi\fi\fi +\fi\fi\fi + +%%<+> \bxInputJaEncoding +\let\bxInputJaEncoding=? +\ifbxHasAlUcsChar + \let\bxInputJaEncoding=u +\else\ifbxinpdfTeX + \let\bxInputJaEncoding=b +\else\ifbxtb@pxbase@ok + \@@input pxbsjc.def\relax + \def\bxtb@tmpb#1#2\@nil{% + \ifnum `#1=\jis"723F \let\bxInputJaEncoding=s\else + \ifnum `#1=\jis"693D \let\bxInputJaEncoding=e\else + \ifnum `#1=\jis"7379 \let\bxInputJaEncoding=u\fi\fi\fi} + \expandafter\bxtb@tmpb\bxtb@tmpa\@nil + \ifx e\bxInputJaEncoding + \@@input pxbsjc1.def\relax + \def\bxtb@tmpb#1#2\@nil{% + \ifnum `#1=\jis"723F \let\bxInputJaEncoding=a\fi} + \expandafter\bxtb@tmpb\bxtb@tmpa\@nil + \fi +\fi\fi\fi + +%%<+> \bxOutputJaEncoding +\let\bxOutputJaEncoding=? +% if input is 'auto', output should not be equal to it, +% but I don't know what to do then. +\let\bxOutputJaEncoding=\bxInputJaEncoding + +%% \bxtb@jaencname +\def\bxtb@jaencname#1#2{% + \ifx u#1#2\else + \ifx s#1sjis\else + \ifx e#1euc\else + \ifx a#1auto\else + \ifx b#1byte\else + (unknown)\fi\fi\fi\fi\fi} + +%%<*> \internaljaencodingname +\newcommand*\internaljaencodingname{} +\edef\internaljaencodingname{% + \bxtb@jaencname\bxInternalJaEncoding{unicode}} + +%%<*> \inputjaencodingname +\newcommand*\inputjaencodingname{} +\edef\inputjaencodingname{% + \bxtb@jaencname\bxInputJaEncoding{utf8}} + +%%<*> \outputjaencodingname +\newcommand*\outputjaencodingname{} +\edef\outputjaencodingname{% + \bxtb@jaencname\bxOutputJaEncoding{utf8}} + +%%<*> \infojenc +\newcommand*\infojenc{% + \typeout{% + Kanji encoding: + input=\inputjaencodingname; + output=\outputjaencodingname; + internal=\internaljaencodingname}% +} + +%--------------------------------------- all done +\endinput +%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.def b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.def new file mode 100644 index 00000000000..07dae477f10 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.def @@ -0,0 +1,1078 @@ +%% +%% This is file 'bxtoolbox.def'. +%% + +%% file declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{bxtoolbox.def}[2017/05/29 v1.1] +\providecommand*\bxtb@pkgname{BXtoolbox}% bundle name + +%% check intergrity +\edef\bxtb@tmpa{\@currname.\@currext}\def\bxtb@tmpb{bxtoolbox.def} +\ifx\bxtb@tmpa\bxtb@tmpb\else + \PackageError\bxtb@pkgname{Illegal load sequence}\@eha +\expandafter\endinput\fi\relax + +%% code guards +\edef\bxtb@restore@codes{% + \catcode33=\the\catcode33% + \catcode34=\the\catcode34% + \catcode39=\the\catcode39% + \catcode45=\the\catcode45% + \catcode46=\the\catcode46% + \catcode47=\the\catcode47% + \catcode58=\the\catcode58% + \catcode60=\the\catcode60% + \catcode62=\the\catcode62% + \catcode63=\the\catcode63% + \catcode96=\the\catcode96% +\relax} +\catcode33=12 % <!> +\catcode34=12 % <"> +\catcode39=12 % <'> +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\catcode58=12 % <:> +\catcode60=12 % <<> +\catcode62=12 % <>> +\catcode63=12 % <?> +\catcode96=12 % <`> +\AtEndOfPackage{% + \bxtb@restore@codes + \let\bxtb@restore@codes\@undefined} + +%--------------------------------------- 0. Prologue + +%% variables +\newif\ifbxOk % general-purpose switch +\let\bxRes\relax % result container + +%% unique tokens +\def\bxtb@uniq{\bxtb@uniq@} + +%% error messages +\def\bxtb@error{\PackageError\bxtb@pkgname} +\def\bxtb@warn{\PackageWarningNoLine\bxtb@pkgname} + +%--------------------------------------- 1. Engine-independent stuffs + +%% \bxtb@@bs +\let\bxtb@@bs\@backslashchar + +%%<+> \bxIfcsundefX{<csname>}{<T>}{<F>} +\newcommand*\bxIfcsundefX{} +\let\bxIfcsundefX\@ifundefined + +%%<+> \bxCsuseX{<csname>} +\newcommand*\bxCsuseX[1]{% + \@ifundefined{#1}{}{\csname#1\endcsname}} + +%% \bxtb@listmake@do +\def\bxtb@listmake@do{\let\do\bxtb@lm@do} +\def\bxtb@lm@do{\noexpand\do\noexpand} +\def\bxtb@csdo#1{\expandafter\do\csname#1\endcsname} + +%% \bxtb@letcs\CSA{<csnameB>} +%% \bxtb@cslet{<csnameA>}\CSB +%% \bxtb@csletcs{<csnameA>}{<csnameB>} +% Same as \letcs, \cslet, \csletcs in etoolbox. +% They are defined here since subsequent stuffs use them. +\def\bxtb@letcs#1#2{% + \expandafter\let\expandafter#1\csname #2\endcsname} +\def\bxtb@cslet#1#2{% + \expandafter\let\csname #1\endcsname#2} +\def\bxtb@csletcs#1#2{% + \expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname} + +%% \bxtb@ifprimitive\CS{<T>}{<F>} +% Core of \bxIfPrimitive. +\def\bxtb@ifprimitive#1{% + \edef\bxtb@tmpa{\string#1}\edef\bxtb@tmpb{\meaning#1}% + \ifx\bxtb@tmpa\bxtb@tmpb \expandafter\@firstoftwo + \else \expandafter\@secondoftwo \fi} + +%% \bxtb@ifstrempty{<str>}{<T>}{<F>} +% Core of \ifstrempty. +\def\bxtb@ifstrempty#1{% + \ifx\bxtb@empty@uniq#1\bxtb@empty@uniq + \expandafter\@firstoftwo + \else \expandafter\@secondoftwo \fi} +\def\bxtb@empty@uniq{\bxtb@empty@uniq@} + +%%<+> \ifbxineTeX (if-token) +%%<+> \bxIfineTeX{<T>}{<F>} +%%<+> \ifbxinpdfTeX / \ifbxinLuaTeX / \ifbxinOmega / \ifbxinAleph +%%<+> \ifbxinXeTeX / \ifbxinpTeX / \ifbxinupTeX / \ifbxinjTeX +%%<+> \bxIfinpdfTeX / \bxIfinLuaTeX / \bxIfinOmega / \bxIfinAleph +%%<+> \bxIfinXeTeX / \bxIfinpTeX / \bxIfinupTeX / \bxIfinjTeX +%% Engine check. +\def\bxtb@do#1#2{% + \bxtb@ifprimitive#2% + {\let\bxtb@tmpa\@firstoftwo}{\let\bxtb@tmpa\@secondoftwo}% + \bxtb@cslet{bxIfin#1}\bxtb@tmpa + \bxtb@csletcs{ifbxin#1}{if\bxtb@tmpa{true}{false}}} +\bxtb@do{eTeX}{\eTeXversion} +\bxtb@do{pdfTeX}{\pdftexversion} +\bxtb@do{LuaTeX}{\luatexversion} +\bxtb@do{Omega}{\OmegaVersion} +\bxtb@do{Aleph}{\AlephVersion} +\bxtb@do{XeTeX}{\XeTeXversion} +\bxtb@do{pTeX}{\kanjiskip} +\bxtb@do{upTeX}{\enablecjktoken} +\bxtb@do{jTeX}{\jintercharskip} + +%%<+> \bxPreamble\CSX[*]\CSY +% Prefix used for preamble-only commands. +% \CSX can be \def, \newcommand, \DeclareRobustCommand, etc. +\@onlypreamble\bxPreamble +\newcommand*\bxPreamble[2]{% + \ifx *#2\def\bxtb@args{{#1*}}% + \else \def\bxtb@args{#1#2}% + \fi \expandafter\bxtb@preamble@a\bxtb@args} +\@onlypreamble\bxtb@preamble@a +\def\bxtb@preamble@a#1#2{% + \@onlypreamble#2#1#2} + +%%<+> \bxConstBool +\newcommand*\bxConstIfToken[2]{% + \bxtb@cslet{if#1}{if#2}} + +%% \bxtb@skip@new@cmd...{<text>} +% Gobbles a following whole macro definition sentence. +\def\bxtb@skip@new@cmd#1#{\@gobble} + +%% \bxtb@name@cs\CS +\def\bxtb@name@cs{% + \expandafter\bxtb@name@cs@a\string\$\@gobble\@empty\@nil} +\def\bxtb@name@cs@a#1#2#3#4\@nil#5{% + \expandafter#3\string#5} + +%% \bxtb@let@name\CSX\CSY +\def\bxtb@let@name#1#2{% + \edef#1{\bxtb@name@cs#2}} + +%%<+> \bxIf{<test>}{<T>}{<F>} +%%<+> \bxIfcat{<test>}{<T>}{<F>} +%%<+> \bxIfx{<test>}{<T>}{<F>} +%%<+> \bxIfdim{<test>}{<T>}{<F>} +%%<+> \bxIfnum{<test>}{<T>}{<F>} +% Primitive if-tests rendered in LaTeX format. +\let\bxtb@bumper\noindent % primitive other than \relax +\bxPreamble\def\bxtb@defifmacro@noarg#1#2#3{% + \@gobble{\if}% if-match hack + \def#1{#2\expandafter\@firstoftwo + \else\expandafter\@secondoftwo\fi}} +\bxPreamble\def\bxtb@defifmacro#1#2#3{% + \@gobble{\if}% if-match hack + \def#1##1{#2##1\expandafter\@firstoftwo + \else\expandafter\@secondoftwo\fi}} +\bxPreamble\def\bxtb@defifmacro@val#1#2#3{% + \@gobble{\if}% if-match hack + \def#1##1{\expandafter\@gobble + #2##1\bxtb@bumper\expandafter\@firstoftwo + \else \bxtb@bumper\expandafter\@secondoftwo \fi}} +\bxtb@defifmacro\bxIf\if\fi +\bxtb@defifmacro\bxIfcat\ifcat\fi +\bxtb@defifmacro\bxIfx\ifx\fi +\bxtb@defifmacro@val\bxIfdim\ifdim\fi +\bxtb@defifmacro@val\bxIfnum\ifnum\fi + +%%<+> \bxIfInMovingArg{<T>}{<F>} +% Moving argument check. Note that it actually expands to <T> or +% <F> prepended with some unexpandable garbles with no effect. +% For that reason, this macro is not suitable for switching +% implementation. Instead it is intended for error check for +% use in moving arguments. +\long\def\bxIfInMovingArg#1#2{% + \let\bxtb@ifinmovarg@a\bxtb@ifinmovarg@a\bxtb@ifinmovarg@c{#1}% + #2\bxtb@ifinmovarg@end} +\def\bxtb@ifinmovarg@a#1{% + \bxtb@ifinmovarg@dummy\relax \bxtb@ifinmovarg@b} +\def\bxtb@ifinmovarg@b#1#2#3\bxtb@ifinmovarg@end{#2} +\def\bxtb@ifinmovarg@c#1#2\bxtb@ifinmovarg@end{#2} +\let\bxtb@ifinmovarg@end\@empty +\let\bxtb@ifinmovarg@dummy\relax + +%%<+> \bxMessageToken{<str>}{<text>} +% Executes <text> where #1 is replaced by control sequence \<str>. +% The meaning of \<str> is unchanged. +% (In <text> # must be doubled.) +\def\bxMessageToken#1{% + \begingroup + \xdef\bxtb@g@tmpa{\noexpand\bxtb@tmpa + \expandafter\noexpand\csname #1\endcsname}% + \endgroup + \afterassignment\bxtb@g@tmpa \long\def\bxtb@tmpa##1} + +%%<+> \bxCheckForMovingArg{<text>} +% When in moving arguments, it raises an error in the form of +% undefined conrol sequence; otherwise expands to <text>. +%%<+> \bxCheckForMovingArgForTest{\SOMETEST{<arg>}}{<T>}{<F>} +% When in moving arguments, it raises an error in the form of +% undefined conrol sequence and expands to <F>; otherwise +% it expands to \SOMETEST{<arg>}{<T>}{<F>}. +\bxMessageToken{ ERROR: Use in wrong place!}{% + \def\bxCheckForMovingArg{\bxIfInMovingArg{#1}}% + \def\bxCheckForMovingArgForTest{% + \bxIfInMovingArg{#1\@secondoftwo}}% +} + +%% \bxtb@ifnewdefok\CS{<T>}{<F>} +%% \bxtb@ifrenewdefok\CS{<T>}{<F>} +%% \bxtb@ifprovidedefok\CS{<T>}{<F>} +\def\bxtb@ifnewdefok#1{% + \newcommand#1{\bxtb@uniq}\bxtb@ifnewdefok@a#1} +\def\bxtb@ifrenewdefok#1{% <F> is never executed + \renewcommand#1{\bxtb@uniq}\let#1\@undefined \@firstoftwo} +\def\bxtb@ifprovidedefok#1{% + \providecommand#1{\bxtb@uniq}\bxtb@ifnewdefok@a#1} +\def\bxtb@ifnewdefok@a#1{% + \ifx#1\bxtb@ifdefok@probe + \let#1\@undefined \expandafter\@firstoftwo + \else \expandafter\@secondoftwo + \fi} +\long\def\bxtb@ifdefok@probe{\bxtb@uniq} + +%% \bxtb@detokenize{<text>} +% Resource consuming version of \detokenize ;) +%% \bxtb@stringify{<text>} +% Expands <text> and then detokenizes the result. +\def\bxtb@detokenize{% + \romannumeral-`a\bxtb@detok@pre@a\bxtb@detok@lop@a} +\def\bxtb@stringify{% + \romannumeral-`a\bxtb@detok@pre@a\bxtb@edetok@lop@a} +\def\bxtb@detok@pre@a#1#2{% + \expandafter\bxtb@detok@ppst@a + \csname\bxtb@nonce@pfx"#1#2\bxtb@detok@enda + {} \bxtb@detok@endb\endcsname} +\def\bxtb@detok@enda{\bxtb@detok@enda@} +\def\bxtb@detok@endb{\bxtb@detok@endb@} +\begingroup + \catcode`\(=12 \lccode`\(=`\{ \catcode`\)=12 \lccode`\)=`\} + \lowercase{\gdef\bxtb@detok@brc@a#1#2{(#1#2)}} +\endgroup +\def\bxtb@detok@lop@a#1 #2\bxtb@detok@endb{% + \bxtb@ifstrempty{#1}% + { \bxtb@detok@lop@a}{\bxtb@detok@lop@b#1 }% + #2\bxtb@detok@endb} +\def\bxtb@detok@lop@b#1#{% + \bxtb@ifstrempty{#1}% + {\bxtb@detok@brc@a\bxtb@detok@lop@a}{\bxtb@detok@lop@c#1}} +\def\bxtb@detok@lop@c#1{% + \bxIfx{#1\bxtb@detok@enda}{\bxtb@detok@pst@a}{% + \bxIfcat{\noexpand#1\relax}{\bxtb@format@cs#1}{\string#1}% + \bxtb@detok@lop@a}} +\def\bxtb@edetok@lop@a#1 #2\bxtb@detok@endb{% + \bxtb@ifstrempty{#1}% + { \bxtb@edetok@lop@a}{\bxtb@edetok@lop@b#1 }% + #2\bxtb@detok@endb} +\def\bxtb@edetok@lop@b#1#{% + \bxtb@ifstrempty{#1}% + {\bxtb@detok@brc@a\bxtb@edetok@lop@a}{\bxtb@edetok@lop@c#1}} +\def\bxtb@edetok@lop@c#1{% + \bxIfx{#1\bxtb@detok@enda}{\bxtb@detok@pst@a}% + {\bxtb@edetok@lop@d#1}} +\def\bxtb@edetok@lop@d#1{% + \bxtb@ifdefmacro#1{\expandafter\bxtb@edetok@lop@a#1}% + {\expandafter\bxtb@edetok@lop@e\romannumeral-`\a#1}} +\def\bxtb@edetok@lop@e#1{% + \bxIfcat{\noexpand#1\relax}{\bxtb@format@cs#1}{\string#1}% + \bxtb@edetok@lop@a} +\def\bxtb@detok@pst@a#1\bxtb@detok@endb{} +\def\bxtb@detok@ppst@a#1{% + \expandafter\bxtb@detok@ppst@b\string#1\@nil} +\def\bxtb@detok@ppst@b#1#2"#3\@nil{\space#3} + +%% \bxtb@format@cs\CS +% Detokenizes control sequence \CS with an optional space +% appended just in \write. +\def\bxtb@format@cs{% + \expandafter\bxtb@format@cs@a\string\$% + \bxtb@format@cs@c\bxtb@format@cs@b\@nil} +\def\bxtb@format@cs@a#1#2#3#4\@nil#5{% + \expandafter#3\string#5\@nil} +\def\bxtb@format@cs@b{\bxtb@format@cs@c\@empty} +\def\bxtb@format@cs@c#1#2#3\@nil{% + #1#2#3\ifcat_#3_\ifnum\catcode`#2=11 \space \fi\else\space\fi} + +%% \bxtb@return@true +\def\bxtb@return@true#1\bxtb@esac{% + \fi\@firstoftwo} +\def\bxtb@return@false#1\bxtb@esac{% + \fi\@secondoftwo} + + +%--------------------------------------- 2. Dummy if-token definitions. + +%% \bxtb@make@dummy@if@setter +\bxPreamble\def\bxtb@make@dummy@if@setter#1#2{% + \begingroup + \def\bxtb@bval{#1}% + \@for\bxtb@bname:=#2\do{\bxtb@make@dummy@if@setter@a}% + \endgroup} +\bxPreamble\def\bxtb@make@dummy@if@setter@a{% + \expandafter\ifx\csname if\bxtb@bname\endcsname\relax + \bxtb@make@dummy@if@setter@appto\bxtb@set@dummy@ifs{% + \let \expandafter\noexpand\csname if\bxtb@bname\endcsname + \expandafter\noexpand\csname if\bxtb@bval\endcsname}% + \bxtb@make@dummy@if@setter@appto\bxtb@unset@dummy@ifs{% + \let \expandafter\noexpand\csname if\bxtb@bname\endcsname + \noexpand\@undefined}% + \fi} +\bxPreamble\def\bxtb@make@dummy@if@setter@appto#1#2{% + \edef\bxtb@tmpx{#2}% + \expandafter\g@addto@macro\expandafter#1% + \expandafter{\bxtb@tmpx}} +\let\bxtb@set@dummy@ifs\@empty +\let\bxtb@unset@dummy@ifs\@empty +\bxtb@make@dummy@if@setter{false}{% + % e-TeX if-tokens + fontchar,defined,csname,incsname,% + % pdfTeX if-tokens + pdfprimitive,pdfabsdim,pdfabsnum,% + % LuaTeX if-tokens + absdim,absnum,primitive,% + % pTeX if-tokens + tdir} +\bxtb@make@dummy@if@setter{true}{% + % pTeX if-tokens + ydir} + +%%<+> \bxSetDummyIfs +%%<+> \bxUnsetDummyIfs +\newcommand*\bxSetDummyIfs{} +\let\bxSetDummyIfs\bxtb@set@dummy@ifs +\newcommand*\bxUnsetDummyIfs{} +\let\bxUnsetDummyIfs\bxtb@unset@dummy@ifs + +%% dummy-ifs are enabled in this file +\bxSetDummyIfs + +\bxPreamble\def\bxtb@defifmacro@engdep#1{% + \expandafter\bxtb@defifmacro@engdep@a + \csname bxIf#1\expandafter\endcsname + \csname if#1\expandafter\endcsname + \csname iftrue\expandafter\endcsname\csname iffalse\endcsname} +\bxPreamble\def\bxtb@defifmacro@engdep@a#1#2#3#4{% + % be careful that #2,#3,#4 are \if-tokens + \bxtb@defifmacro@noarg#1#2\relax \chardef\bxtb@tmpa\z@ + \ifx#2#3\chardef\bxtb@tmpa\@ne \fi + \ifx#2#4\chardef\bxtb@tmpa\tw@ \fi + \ifcase\bxtb@tmpa\relax + \or \let#1\@firstoftwo + \or \let#1\@secondoftwo + \fi} +\bxPreamble\def\bxtb@make@engdep@test#1{% + \@for\bxtb@bname:=#1\do{% + \bxtb@defifmacro@engdep\bxtb@bname}} +% this must be done in \bxSetDummyIfs effective +\bxtb@make@engdep@test{% + ydir,tdir% +} + +%--------------------------------------- 3. Macrodef prefix operations + +%% \bxtb@all@prefix +\def\bxtb@all@prefix{\do{protected}\do{long}\do{outer}} + +%% \bxtb@set@prefix{<name>} +%% \bxtb@unset@prefix{<name>} +%% \bxtb@unset@all@prefix{<name>} +\def\bxtb@set@prefix#1{\bxtb@cslet{bxtb@PFX/#1}{T}} +\def\bxtb@unset@prefix#1{\bxtb@cslet{bxtb@PFX/#1}{F}} +\def\do{\noexpand\bxtb@unset@prefix} +\edef\bxtb@unset@all@prefix{\bxtb@all@prefix} + +%% \bxtb@clear@prefix +\def\bxtb@clear@prefix{% + \def\bxtb@savepfx@dummy{}\let\bxtb@savepfx@dummy\relax} + +%% \bxtb@render@prefix +\def\do{\noexpand\bxtb@render@prefix@a} +\edef\bxtb@render@prefix{\bxtb@all@prefix} +\def\bxtb@render@prefix@a#1{% + \bxIf{\csname bxtb@PFX/#1\endcsname T}{\csname #1\endcsname}{}} + +%% \bxtb@save@prefix +\def\bxtb@save@prefix{% + \def\bxtb@savepfx@dummy{}% prefixes applied to this definition + \bxtb@unset@all@prefix + \begingroup \escapechar`\\ + \expandafter\bxtb@savepfx@prs@a\meaning\bxtb@savepfx@dummy\@nil + %\endgroup already done +} + +%% some internal stuffs +\begingroup \escapechar\m@ne +\xdef\bxtb@g@args{{\string\macro:}{\space}{\string\\}} +\endgroup +\def\bxtb@do#1#2#3{% + \def\bxtb@savepfx@prs@a##1#1##2\@nil{% + \endgroup + \let\bxtb@savepfx@dummy\relax + \bxIfcat{_##1_}{}{\bxtb@savepfx@prs@b##1\@nil}} + \def\bxtb@savepfx@prs@b##1##2#2##3\@nil{% + \bxtb@savepfx@prs@c##2#3#3} + \def\bxtb@savepfx@prs@c##1#3{% + \bxIfcat{_##1_}{}% + {\bxtb@set@prefix{##1}\bxtb@savepfx@prs@c}} + \def\bxtb@ifdefmacro##1{% + \expandafter\bxtb@ifdefmacro@a\meaning##1#1\@nil} + \def\bxtb@ifdefmacro@a##1#1##2\@nil##3##4{% + \bxIfcat{_##2_}{##4}{##3}} +} +\expandafter\bxtb@do\bxtb@g@args + +%--------------------------------------- 4. pdfTeX primitives + +%%<+> \ifbxPrimitive +% The primitive equivalent to pdfTeX's \ifpdfprimitive; if the +% primitive is not available, this is \let'd to \iffalse. +%%<+> \bxIfHasIfPrimitive{<T>}{<F>} +% Whether \ifbxPrimitive has a valid definition. +\bxtb@cslet{ifbxPrimitive}\@undefined +\expandafter\bxtb@ifprimitive\csname ifpdfprimitive\endcsname{%then + \let\bxIfHasIfPrimitive\@firstoftwo + \bxtb@csletcs{ifbxPrimitive}{ifpdfprimitive}% +}{%else + \expandafter\bxtb@ifprimitive\csname ifprimitive\endcsname{%then + \let\bxIfHasIfPrimitive\@firstoftwo + \bxtb@csletcs{ifbxPrimitive}{ifprimitive}% + }{%else + \let\bxIfHasIfPrimitive\@secondoftwo + \bxtb@csletcs{ifbxPrimitive}{iffalse}% +}} + +%%<+> \bxPrimitive +% The primitive equivalent to pdfTeX's \pdfprimitive; if the +% primitive is not available, this is defined to be empty. +\bxtb@ifprimitive\pdfprimitive{%then + \let\bxPrimitive\pdfprimitive +}{%else + \bxtb@ifprimitive\primitive{%then + \let\bxPrimitive\primitive + }{%else + \let\bxPrimitive\@empty +}} + +%%<+> \bxStrcmp +% The primitive equivalent to pdfTeX's \pdfstrcmp; if the +% primitive is not available, this is left undefined. +\let\bxStrcmp\@undefined +\bxtb@ifprimitive\pdfstrcmp{%then + \let\bxStrcmp\pdfstrcmp +}{%else + \bxtb@ifprimitive\strcmp{%then + \let\bxStrcmp\strcmp + }{%else +}} +\ifbxinLuaTeX %----<*LuaTeX> + \ifdefined\luatexluaescapestring + \unless\ifdefined\bxStrcmp + \directlua0{% + function bxtoolbox_strcmp(A, B) + if A == B then tex.write("0") + elseif A < B then tex.write("-1") + else tex.write("1") + end + end + } + \long\def\bxStrcmp#1#2{\directlua0{% + bxtoolbox_strcmp("\luatexluaescapestring{#1}", + "\luatexluaescapestring{#2}") + }} + \fi + \fi +\fi %----</LuaTeX> + +%--------------------------------------- 5. non etoolbox stuffs + +%%<+> \bxRobustdef\CS +%%<+> \bxRobustgdef\CS +%%<+> \bxRobustedef\CS +%%<+> \bxRobustxdef\CS +\ifbxineTeX %<*etex> +\def\bxRobustdef{\protected\def} +\def\bxRobustgdef{\protected\gdef} +\def\bxRobustedef{\protected\edef} +\def\bxRobustxdef{\protected\xdef} +\else %<*!etex> +\def\bxRobustdef{\bxtb@robustdef\def} +\def\bxRobustgdef{\bxtb@robustdef\gdef} +\def\bxRobustedef{\bxtb@robustdef\edef} +\def\bxRobustxdef{\bxtb@robustdef\xdef} +\def\bxtb@robustdef#1#2{% + \bxtb@save@prefix + \let#2\@undefined \DeclareRobustCommand*#2{}% + \bxtb@let@name\bxtb@tmpb#2% + \bxtb@render@prefix + \expandafter#1\csname \bxtb@tmpb\space \endcsname} +\fi %</etex> + +%% \bxtb@robustlet\CSA\CSB +\ifbxineTeX %<*etex> +\def\bxtb@robustlet#1#2{% + \protected\def#1{#2}} +\else %<*!etex> +\def\bxtb@robustlet#1{% + \expandafter\bxtb@robustlet@a + \csname\bxtb@name@cs#1\space\endcsname#1} +\def\bxtb@robustlet@a#1#2#3{% + \DeclareRobustCommand*#2{}\let#1#3} +\fi + +%%<+> \bxIfPdfOutput{<T>}{<F>} +%%<+> \bxIfPdfOutputNow{<T>}{<F>} +\newcommand*\bxIfPdfOutputNow{% + \ifx\pdfoutput\@undefined \bxtb@return@false \fi + \ifx\pdfoutput\relax \bxtb@return@false \fi + \ifnum\pdfoutput>\z@ \bxtb@return@true + \else \bxtb@return@false \fi + \bxtb@esac} +\newcommand*\bxIfPdfOutput{} +\bxIfPdfOutputNow +{\let\bxIfPdfOutput\@firstoftwo + \bxtb@letcs\ifbxPdfOutput{iftrue}}% +{\let\bxIfPdfOutput\@secondoftwo + \bxtb@letcs\ifbxPdfOutput{iffalse}}% + +%%<+> \bxIfPrimitive\CS +%%<+> \bxCSIfPrimitive{<csname>} +\newcommand*\bxIfPrimitive{} +\bxtb@robustlet\bxIfPrimitive\bxtb@ifprimitive +\def\bxtb@ifcsprimitive@a#1{% + \expandafter\bxIfPrimitive\csname #1\endcsname} +\ifbxineTeX %<*etex> +\def\bxIfCsPrimitive#1{% + \unless\ifcsname#1\endcsname \let\bxtb@tmpx\@secondoftwo + \else \def\bxtb@tmpx{\bxtb@ifcsprimitive@a{#1}}% + \fi \bxtb@tmpx} +\else %<*!etex> +\def\bxIfCsPrimitive#1{% + \begingroup\expandafter\endgroup + \expandafter\ifx\csname #1\endcsname\@undefined + \let\bxtb@tmpx\@secondoftwo + \else \def\bxtb@tmpx{\bxtb@ifcsprimitive@a{#1}}% + \fi \bxtb@tmpx} +\fi %</etex> +% use \ifbxPrimitive if available +\bxIfHasIfPrimitive{% +\bxtb@defifmacro\bxIfPrimitive\ifbxPrimitive\fi +}{} + +%%<+> \bxIfPrimitiveX\CS +%% TODO: for e-TeX, TeX +% use \ifpdfprimitive if available +\bxIfHasIfPrimitive\@tempswatrue\@tempswafalse +\if@tempswa %---- +\let\bxIfPrimitiveX\bxIfPrimitive +\else %---- +\def\bxIfPrimitiveX#1{% + \bxIfcat{\noexpand#1\relax}% + {\bxtb@ifdefmacro#1{\@secondoftwo}{\bxtb@ifprimitive@x@a#1}}% + {\@secondoftwo}} +\def\bxtb@ifprimitive@x@a#1{% + \expandafter\bxtb@ifprimitive@x@b\meaning#1\bxtb@cmp@endb#1} +\def\bxtb@ifprimitive@x@b#1\bxtb@cmp@endb#2{% + \expandafter\bxtb@ifprimitive@x@c\string#1\@bxtb@cmp@enda + #2\bxtb@cmp@endb} +\def\bxtb@do#1{% + \def\bxtb@ifprimitive@x@b##1\bxtb@cmp@endb##2{% + \expandafter\bxtb@ifprimitive@x@c\string##1\@bxtb@cmp@enda + ##2\bxtb@cmp@endb#1\@nil}} +\def\bxtb@ifprimitive@x@c#1 #2\@nil{% + \bxtb@ifstrempty{#2}{\bxtb@ifeq@pstr#1}% + {\@secondoftwo}} +\fi %---- + +%%<+> \bxIfExpToEqual{<text1>}{<text2>}{<T>}{<F>} +\newcommand*\bxIfExpToEqual{} +\bxRobustdef\bxIfExpToEqual#1#2{% + \bxCheckForMovingArgForTest{% + \bxtb@edef@detokenized\bxtb@tmpx{#1}% + \bxtb@edef@detokenized\bxtb@tmpy{#2}% + \bxIfx{\bxtb@tmpx\bxtb@tmpy}}} +% use \bxStrcmp if available +\ifx\bxStrcmp\@undefined\else +\def\bxIfExpToEqual#1#2{% + \bxIfnum{\bxStrcmp{#1}{#2}=\z@}} +\fi + +%%<+> \bxIfExpToEqualX{<text1>}{<text2>}{<T>}{<F>} +\def\bxIfExpToEqualX#1#2{% + \bxtb@ifeq@text#1\bxtb@cmp@enda#2\bxtb@cmp@endb} +% use \bxStrcmp if available +\ifx\bxStrcmp\@undefined\else +\let\bxIfExpToEqualX\bxIfExpToEqual +\fi + +%% \bxtb@ifstrequal@pdftex{<str1>}{<str2>}{<T>}{<F>} +% a version of \ifstrequal using \bxStrcmp +\ifx\bxStrcmp\@undefined\else +\def\bxtb@ifstrequal@pdftex#1#2{% + \bxIfnum{\bxStrcmp{\detokenize{#1}}{\detokenize{#2}}=\z@}} +\AtEndOfPackage{% override the definition in etoolbox + \let\bxIfstrequal\bxtb@ifstrequal@pdftex} +\fi + +%% \bxIfstrequalX{<str1>}{<str2>}{<T>}{<F>} +\newcommand*\bxIfstrequalX{} +\def\bxIfstrequalX#1#2{% + \bxtb@ifeq@str#1\bxtb@cmp@enda#2\bxtb@cmp@endb} +% use \bxStrcmp if available +\ifx\bxStrcmp\@undefined\else +\let\bxIfstrequalX\bxtb@ifstrequal@pdftex +\fi + +%% \bxtb@nonce@pfx +\def\bxtb@nonce@pfx{bxtb@?@\string\$} + +%%<+> \bxDetokenize{<text>} +\bxIfineTeX +{\let\bxDetokenize\detokenize} +{\let\bxDetokenize\bxtb@detokenize} +%%<+> \bxStringify{<text>} +\let\bxStringify\bxtb@stringify + +%% \bxtb@def@detokenized\CS{<text>} +%% \bxtb@edef@detokenized\CS{<text>} +\ifbxineTeX %<*etex> +\def\bxtb@def@detokenized#1#2{% + \edef#1{\detokenize{#2}}} +\def\bxtb@edef@detokenized#1#2{% + \edef\bxtb@args{\noexpand#1{#2}}% + \expandafter\bxtb@def@detokenized\bxtb@args} +\else %<*!etex> +\def\bxtb@def@detokenized{\bxtb@defdetok@a\def} +\def\bxtb@edef@detokenized{\bxtb@defdetok@a\edef} +\def\bxtb@defdetok@a#1#2#3{% + #1\bxtb@tmpa{#3}% + \expandafter\bxtb@defdetok@b\meaning\bxtb@tmpa\@nil#2} +\def\bxtb@defdetok@b#1>#2\@nil#3{\def#3{#2}} +\fi %</etex> + +%% \bxtb@ifeq@text +\def\bxtb@ifeq@text#1\bxtb@cmp@enda#2\bxtb@cmp@endb{% + \expandafter\expandafter\expandafter\bxtb@ifeqtx@a + \bxtb@stringify@ss{#2}\bxtb@cmp@endb#1\bxtb@cmp@enda} +\def\bxtb@ifeqtx@a#1\bxtb@cmp@endb#2\bxtb@cmp@enda{% + \expandafter\expandafter\expandafter\bxtb@ifeq@pstr + \bxtb@stringify@ss{#2}\bxtb@cmp@enda#1\bxtb@cmp@endb} + +%% \bxtb@ifeq@str#1#2 +\def\bxtb@ifeq@str#1\bxtb@cmp@enda#2\bxtb@cmp@endb{% + \expandafter\expandafter\expandafter\bxtb@ifeqstr@a + \bxtb@detokenize@ss{#2}\bxtb@cmp@endb#1\bxtb@cmp@enda} +\def\bxtb@ifeqstr@a#1\bxtb@cmp@endb#2\bxtb@cmp@enda{% + \expandafter\expandafter\expandafter\bxtb@ifeq@pstr + \bxtb@detokenize@ss{#2}\bxtb@cmp@enda#1\bxtb@cmp@endb} + +%% \bxtb@ifeq@pstr +\def\bxtb@ifeq@pstr#1\bxtb@cmp@enda#2\bxtb@cmp@endb{% + \bxtb@ifstrempty{#1}% + {\bxtb@ifstrempty{#2}}% + {\bxtb@ifstrempty{#2}{\@secondoftwo}% + {\bxtb@ifeqps@a#1\bxtb@cmp@enda#2\bxtb@cmp@endb}}} +\def\bxtb@ifeqps@a#1#2\bxtb@cmp@enda#3#4\bxtb@cmp@endb{% + \bxIfx{#1#3}% + {\bxtb@ifeq@pstr#2\bxtb@cmp@enda#4\bxtb@cmp@endb}% + {\@secondoftwo}} +\def\bxtb@cmp@enda{\bxtb@cmp@enda@} +\def\bxtb@cmp@endb{\bxtb@cmp@endb@} + +%% \bxtb@space@subst +\def\bxtb@space@subst#1 #2\bxtb@ss@endb{% + \bxtb@ifstrempty{#2}{\bxtb@spcsub@a#1\bxtb@ss@endb}% + {\bxtb@space@subst#1\space#2\bxtb@ss@endb}} +\def\bxtb@spcsub@a#1\bxtb@ss@enda#2\bxtb@ss@endb{\space#1} +\def\bxtb@ss@enda{\bxtb@ss@enda@} +\def\bxtb@ss@endb{\bxtb@ss@endb@} + +%% \bxtb@combine@ss +\def\bxtb@combine@ss#1#2{% + \expandafter\expandafter\expandafter\bxtb@space@subst + #1{#2}\bxtb@ss@enda{} \bxtb@ss@endb} +\def\bxtb@detokenize@ss{% + \romannumeral-`\a\bxtb@combine@ss\bxDetokenize} +\def\bxtb@stringify@ss{% + \romannumeral-`\a\bxtb@combine@ss\bxStringify} + +%%<+> \bxCsNoexpand{<csname>} +\newcommand*\bxCsNoexpand[1]{% + \expandafter\noexpand\csname#1\endcsname} + +%--------------------------------------- 6. Import from etoolbox + +%% \bxtb@import{\CSA \CSB ...} +% [e-TeX] Aliases each of macros to a new name with 'bx' prefixed. +% [non-e-TeX] Adds the prefixed name to the function check list. +\bxPreamble\def\bxtb@import#1{% + \bxtb@listmake@do + \@tfor\bxtb@tmpa:=#1\do{\expandafter\bxtb@importcmd\bxtb@tmpa}} +\bxPreamble\def\bxtb@importcmd#1{% + \begingroup + \expandafter\bxtb@importcmd@a\string#1\@nil + \endgroup} +\bxPreamble\def\bxtb@importcmd@a#1#2#3\@nil{% + \@tempcnta`#2 \@tempcntb\@tempcnta + \ifnum 96<\@tempcntb \ifnum 123>\@tempcntb + \advance\@tempcntb-32 \fi\fi + \uccode\@tempcnta\@tempcntb + \uppercase{\edef\bxtb@tmpa{#2}}% + \expandafter\bxtb@importcmd@b\csname bx\bxtb@tmpa#3% + \expandafter\endcsname\csname #2#3\endcsname} + +%% \bxtb@provide{\CSA \CSB ...} +% [e-TeX] Does nothing. +% [non-e-TeX] Adds the name to the function check list. +\bxPreamble\def\bxtb@provide#1{% + \bxtb@listmake@do + \@tfor\bxtb@tmpa:=#1\do{\expandafter\bxtb@providecmd\bxtb@tmpa}} + +\ifbxineTeX %<*etex> +%% Load etoolbox. +\RequirePackage{etoolbox}\relax +%% +\bxPreamble\def\bxtb@importcmd@b#1#2{\global\let#1#2} +\bxPreamble\def\bxtb@providecmd#1{} + +\else %<*!etex> +%% +\bxPreamble\let\bxtb@provided\@empty +\bxPreamble\def\bxtb@importcmd@b#1#2{% + \xdef\bxtb@provided{\bxtb@provided\do#1}} +\bxPreamble\def\bxtb@providecmd#1{% + \xdef\bxtb@provided{\bxtb@provided\do#1}} + +\fi %</etex> + +\bxtb@import{% +%%==== Here is a list of commands imported to bx* namespace. +%% For such commands, bxtoolbox provides compatible but not equivalent +%% commands when e-TeX extension is not available, under the same +%% 'bx'-prefixed name. + \newrobustcmd \renewrobustcmd \providerobustcmd %2.1 + \robustify %2.2 + \csuse \csshow %3.1.1 + \ifcsdef \ifcsundef %3.6.1 +} +\bxtb@provide{% +%% For the following commands, bxtoolbox provides equivalent commands +%% for non-e-TeX environment under the same name as in etoolbox. + \AfterPreamble \AtEndPreamble \AfterEndPreamble %2.5 + \AfterEndDocument + \csdef \csgdef \csedef \csxdef %3.1.1 + \cslet \letcs \csletcs \undef \csundef + \appto \gappto \eappto \xappto %3.3.1 + \csappto \csgappto \cseappto \csxappto + \preto \gpreto \epreto \xpreto %3.3.2 + \cspreto \csgpreto \csepreto \csxpreto + \newbool \providebool \booltrue \boolfalse %3.5.1 + \setbool \ifbool \notbool + \newtoggle \providetoggle \toggletrue \togglefalse %3.5.2 + \settoggle \iftoggle \nottoggle + \ifdef \ifundef %3.6.1 + \ifstrequal \ifstrempty %3.6.2 +} + +\ifbxineTeX %<*etex> +%% When the engine is eTeX, stop reading here. +\bxUnsetDummyIfs +\expandafter\endinput +\fi %</etex> +%--------------------------------------- 7. etoolbox compatible functions + +%% error messages +\def\bxtb@err@ukbool#1{\bxtb@error + {\bxtb@@bs if#1 undefined}\@eha} +\def\bxtb@err@ukbval#1{\bxtb@error + {Invalid boolean value '#1'}\@eha} +\def\bxtb@err@aetgl#1{\bxtb@error + {Toggle '#1' already defined}\@eha} +\def\bxtb@err@uktgl#1{\bxtb@error + {Toggle '#1' undefined}\@eha} +\def\bxtb@err@nomcr#1{\bxtb@error + {\string#1 is not a macro}\@eha} + +%%<+> \cslet +%%<+> \letcs +%%<+> \csletcs +\bxtb@robustlet\cslet\bxtb@cslet +\bxtb@robustlet\letcs\bxtb@letcs +\bxtb@robustlet\csletcs\bxtb@csletcs + +%%<+> \bxNewrobustcmd +%%<+> \bxRenewrobustcmd +%%<+> \bxProviderobustcmd +\newcommand\bxNewrobustcmd{} +\DeclareRobustCommand*\bxNewrobustcmd{% + \bxtb@dclrobustcmd@a\bxtb@ifnewdefok} +\def\bxtb@dclrobustcmd@a#1{% + \@ifstar{\bxtb@dclrobustcmd@b#1{*}}{\bxtb@dclrobustcmd@b#1{}}} +\def\bxtb@dclrobustcmd@b#1#2#3{% + #1#3{\DeclareRobustCommand#2#3}{\bxtb@skip@new@cmd}} +\bxNewrobustcmd*\bxRenewrobustcmd{% + \bxtb@dclrobustcmd@a\bxtb@ifrenewdefok} +\bxNewrobustcmd*\bxProviderobustcmd{% + \bxtb@dclrobustcmd@a\bxtb@ifprovidedefok} + +%%<+> \bxRobustify +\bxNewrobustcmd*\bxRobustify[1]{% + \ifundef{#1}{\bxtb@err@nomcr#1} + {\bxtb@ifdefmacro{#1}% + {\begingroup + \expandafter\bxtb@robustify@a + \csname\bxtb@name@cs#1\space\endcsname#1}% + {\bxtb@err@nomcr#1}}} +\def\bxtb@robustify@a#1#2{% + \global\let\bxtb@rbf@do\@empty + \let\bxtb@tmpa#2\let#2\@undefined + \let\bxtb@tmpb#1\let#1\@undefined + \DeclareRobustCommand*#2{}% + \ifx#2\bxtb@tmpa + \bxtb@warn{\string#2 is already robust}% + \else\ifx\bxtb@tmpb\relax + \global\let\bxtb@rbf@tmpa#2% + \gdef\bxtb@rbf@do{\let#1#2\let#2\bxtb@rbf@tmpa}% + \else \bxtb@error{Failed to robustify \string#1}\@ehc + \fi\fi + \endgroup \bxtb@rbf@do} + +%%<+> \csdef +%%<+> \csedef +%%<+> \csgdef +%%<+> \csxdef +\bxNewrobustcmd*\csdef[1]{\expandafter\def\csname #1\endcsname} +\bxNewrobustcmd*\csedef[1]{\expandafter\edef\csname #1\endcsname} +\bxNewrobustcmd*\csgdef[1]{\expandafter\gdef\csname #1\endcsname} +\bxNewrobustcmd*\csxdef[1]{\expandafter\xdef\csname #1\endcsname} + +%%<+> \undef +%%<+> \csundef +\bxNewrobustcmd*\undef[1]{\let#1\@undefined} +\bxNewrobustcmd*\csundef[1]{% + \expandafter\let\csname #1\endcsname\@undefined} + +%%<+> \ifdef\CS{<T>}{<F>} +%%<+> \ifundef\CS{<T>}{<F>} +%%<+> \bxIfcsdef{<csname>}{<T>}{<F>} +%%<+> \bxIfcsundef{<csname>}{<T>}{<F>} +\newcommand*\ifdef[1]{% + \ifx#1\@undefined \expandafter\@secondoftwo + \else \expandafter\@firstoftwo + \fi} +\newcommand*\ifundef[1]{% + \ifx#1\@undefined \expandafter\@firstoftwo + \else \expandafter\bxtb@ifundef@a\expandafter#1% + \fi} +\def\bxtb@ifundef@a#1{% + \ifx#1\relax \expandafter\@firstoftwo + \else \expandafter\@secondoftwo + \fi} +\newcommand*\bxIfcsdef[1]{% + \bxCheckForMovingArgForTest{% + \begingroup\expandafter\endgroup + \expandafter\ifx\csname #1\endcsname\@undefined + \expandafter\@secondoftwo + \else \expandafter\@firstoftwo + \fi}} +\newcommand*\bxIfcsundef[1]{% + \bxCheckForMovingArgForTest{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname #1\endcsname\relax + \expandafter\@firstoftwo + \else \expandafter\@secondoftwo + \fi}} + +%%<+> \bxCsuse +\bxNewrobustcmd*\bxCsuse[1]{% + \bxIfcsdef{#1}{\csname #1\endcsname}{}} + +%%<+> \bxCsshow +\bxNewrobustcmd*\bxCsshow[1]{% + \bxIfcsdef{#1}{\expandafter\show\csname #1\endcsname}{}} + +%%<+> \appto +%%<+> \gappto +%%<+> \eappto +%%<+> \xappto +\bxNewrobustcmd*\appto{\bxtb@appto\@empty} +\bxNewrobustcmd*\gappto{\bxtb@appto\global} +\bxNewrobustcmd*\eappto{\bxtb@eappto\@empty} +\bxNewrobustcmd*\xappto{\bxtb@eappto\global} +\bxNewrobustcmd*\csappto[1]{\expandafter\appto\csname#1\endcsname} +\bxNewrobustcmd*\csgappto[1]{\expandafter\gappto\csname#1\endcsname} +\bxNewrobustcmd*\cseappto[1]{\expandafter\eappto\csname#1\endcsname} +\bxNewrobustcmd*\csxappto[1]{\expandafter\xappto\csname#1\endcsname} +\def\bxtb@eappto#1#2#3{% + \edef\bxtb@args{\noexpand#1\noexpand#2{#3}}% + \expandafter\bxtb@appto\bxtb@args} +\def\bxtb@appto#1#2#3{% + \begingroup + \ifx#2\@undefined \let#2\@empty \fi + \toks@\expandafter{#2#3}\xdef\bxtb@g@tmpa{\the\toks@}% + \endgroup #1\let#2\bxtb@g@tmpa} + +%%<+> \preto +%%<+> \gpreto +%%<+> \epreto +%%<+> \xpreto +\bxNewrobustcmd*\preto{\bxtb@preto\@empty} +\bxNewrobustcmd*\gpreto{\bxtb@preto\global} +\bxNewrobustcmd*\epreto{\bxtb@epreto\@empty} +\bxNewrobustcmd*\xpreto{\bxtb@epreto\global} +\bxNewrobustcmd*\cspreto[1]{\expandafter\preto\csname#1\endcsname} +\bxNewrobustcmd*\csgpreto[1]{\expandafter\gpreto\csname#1\endcsname} +\bxNewrobustcmd*\csepreto[1]{\expandafter\epreto\csname#1\endcsname} +\bxNewrobustcmd*\csxpreto[1]{\expandafter\xpreto\csname#1\endcsname} +\toksdef\bxtb@toksa=2 +\def\bxtb@epreto#1#2#3{% + \edef\bxtb@args{\noexpand#1\noexpand#2{#3}}% + \expandafter\bxtb@preto\bxtb@args} +\def\bxtb@preto#1#2#3{% + \begingroup + \ifx#2\@undefined \let#2\@empty \fi + \toks@\expandafter{#2}\bxtb@toksa{#3}% + \xdef\bxtb@g@tmpa{\the\bxtb@toksa\the\toks@}% + \endgroup #1\let#2\bxtb@g@tmpa} + +%%<+> \newbool +%%<+> \providebool +\bxNewrobustcmd*\newbool[1]{% + \expandafter\bxtb@newbool@a\csname if#1\endcsname} +\def\bxtb@newbool@a#1{\@ifdefinable#1{\newif#1}} +\bxNewrobustcmd*\providebool[1]{% + \@ifundefined{if#1}% + {\expandafter\newif\csname if#1\endcsname}{}} + +%%<+> \booltrue +%%<+> \boolfalse +%%<+> \setbool +% NB: Here \bxIfcsundef cannot be used because otherwise the use +% with \global would fail. +\bxNewrobustcmd*\booltrue[1]{% + \bxIfcsundefX{if#1}{\bxtb@clear@prefix\bxtb@err@ukbool{#1}}% + {\csname #1true\endcsname}} +\bxNewrobustcmd*\boolfalse[1]{% + \bxIfcsundefX{if#1}{\bxtb@clear@prefix\bxtb@err@ukbool{#1}}% + {\csname #1false\endcsname}} +\bxNewrobustcmd*\setbool[2]{% + \bxIfcsundefX{if#1}{\bxtb@clear@prefix\bxtb@err@ukbool{#1}}% + {\bxIfcsundefX{#1#2}{\bxtb@clear@prefix\bxtb@err@ukbval{#2}}% + {\csname #1#2\endcsname}}} + +%%<+> \ifbool +%%<+> \notbool +\@gobble{\if\if}% if-match hack +\newcommand*\ifbool[1]{% + \bxIfcsundefX{if#1}{\bxtb@err@ukbool{#1}\@gobbletwo}% + {\csname if#1\endcsname\expandafter\@firstoftwo + \else \expandafter\@secondoftwo + \fi}} +\newcommand*\notbool[1]{% + \bxIfcsundefX{if#1}{\bxtb@err@ukbool{#1}\@gobbletwo}% + {\csname if#1\endcsname\expandafter\@secondoftwo + \else \expandafter\@firstoftwo + \fi}} + +%%<+> \newtoggle +%%<+> \providetoggle +\bxNewrobustcmd*\newtoggle[1]{% + \bxIfcsdef{bxtb@TG/#1}{\bxtb@err@aetgl{#1}}% + {\cslet{bxtb@TG/#1}\bxtb@tgl@@false}} +\bxNewrobustcmd*\providetoggle[1]{% + \bxIfcsdef{bxtb@TG/#1}{}{\cslet{bxtb@TG/#1}\bxtb@tgl@@false}} +\let\bxtb@tgl@@true\@firstoftwo +\let\bxtb@tgl@@false\@secondoftwo + +%%<+> \toggletrue +%%<+> \togglefalse +%%<+> \settoggle +% NB: Here \bxIfcsdef cannot be used because otherwise the use +% with \global would fail. +\bxNewrobustcmd*\toggletrue[1]{% + \bxIfcsundefX{bxtb@TG/#1}{\bxtb@clear@prefix\bxtb@err@uktgl{#1}}% + {\cslet{bxtb@TG/#1}\bxtb@tgl@@true}} +\bxNewrobustcmd*\togglefalse[1]{% + \bxIfcsundefX{bxtb@TG/#1}{\bxtb@clear@prefix\bxtb@err@uktgl{#1}}% + {\cslet{bxtb@TG/#1}\bxtb@tgl@@false}} +\bxNewrobustcmd*\settoggle[2]{% + \bxIfcsundefX{bxtb@TG/#1}{\bxtb@clear@prefix\bxtb@err@uktgl{#1}}% + {\bxIfcsundefX{bxtb@tgl@@#2}{\bxtb@clear@prefix\bxtb@err@ukbval{#2}}% + {\csletcs{bxtb@TG/#1}{bxtb@tgl@@#2}}}} + +%%<+> \iftoggle +%%<+> \nottoggle +\newcommand*\iftoggle[1]{% + \bxIfcsundefX{bxtb@TG/#1}{\bxtb@err@uktgl{#1}\@gobbletwo}% + {\csname bxtb@TG/#1\endcsname}} +\newcommand*\nottoggle[1]{% + \bxIfcsundefX{bxtb@TG/#1}{\bxtb@err@uktgl{#1}\@gobbletwo}% + {\csname bxtb@TG/#1\endcsname\@secondoftwo\@firstoftwo}} + +%%<+> \ifstrequal{<str1>}{<str2>}{<T>}{<F>} +\newcommand*\ifstrequal{} +\bxRobustdef\ifstrequal#1#2{% + \bxCheckForMovingArgForTest{% + \bxtb@def@detokenized\bxtb@tmpx{#1}% + \bxtb@def@detokenized\bxtb@tmpy{#2}% + \bxIfx{\bxtb@tmpx\bxtb@tmpy}}} + +%%<+> \ifstrempty{<str>}{<T>}{<F>} +\newcommand*\ifstrempty{} +\let\ifstrempty\bxtb@ifstrempty + +%% internal stuffs needed for hook commands +\bxPreamble\def\bxtb@prepare@bdhook#1#2{% + \bxNewrobustcmd*#1{\gappto#2}% + \newcommand*#2{}} +\def\bxtb@dispatch@bdhook#1#2{% + \let#1\@firstofone #2% + \bxRobustdef#1{\@notprerr\@gobble}\undef#2} + +%%<+> \AtEndPreamble +%%<+> \AfterPreamble +%%<+> \AfterEndPreamble +%%<+> \AfterEndDocument +\bxtb@prepare@bdhook\AtEndPreamble\@endpreamblehook +\bxtb@prepare@bdhook\AfterEndPreamble\@afterendpreamblehook +\bxtb@prepare@bdhook\AfterEndDocument\@afterenddocumenthook +\bxNewrobustcmd*\AfterPreamble{\AtBeginDocument} +\AtEndPreamble{\let\AfterPreamble\@firstofone} +\AfterEndPreamble{\undef\bxtb@dispatch@bdhook} +% +\preto\document{\endgroup + \bxtb@dispatch@bdhook\AtEndPreamble\@endpreamblehook + \begingroup} +\appto\document{% + \bxtb@dispatch@bdhook\AfterEndPreamble\@afterendpreamblehook + \ignorespaces} +% patch to \enddocument +\bxPreamble\def\bxtb@patch@enddocument{% + \expandafter\bxtb@patch@ed@a\enddocument\deadcycles\bxtb@end} +\bxPreamble\def\bxtb@patch@ed@a#1\deadcycles#2\bxtb@end{% + \bxtb@ifstrempty{#2}{\bxtb@patch@ed@fail}% + {\def\bxtb@tmpa{#1}\bxtb@patch@ed@b#2\bxtb@end}} +\bxPreamble\def\bxtb@patch@ed@b#1\deadcycles#2\bxtb@end{% + \bxtb@ifstrempty{#2}{\bxtb@patch@ed@c{#1}}% + {\bxtb@patch@ed@fail}} +\bxPreamble\def\bxtb@patch@ed@c#1{% + \appto\bxtb@tmpa{\let\AfterEndDocument\@firstofone + \@afterenddocumenthook + \deadcycles#1}% + \let\bxtb@org@enddocument\enddocument + \let\enddocument\bxtb@tmpa} +\bxPreamble\def\bxtb@patch@ed@fail{% + \bxtb@warn{\string\AfterEndDocument\space is set disabled}% + \bxRobustdef\AfterEndDocument##1{\bxtb@error + {\string\AfterEndDocument\space is now disabled}\@eha}} +\bxtb@patch@enddocument + +%--------------------------------------- 8. Epilogue +\def\do#1{% + \ifx#1\@undefined \bxtb@warn{\string#1 not yet implemented}\fi} +\bxtb@provided +\bxUnsetDummyIfs +\endinput +%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.sty b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.sty new file mode 100644 index 00000000000..4f1ee3b8319 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bxbase/bxtoolbox.sty @@ -0,0 +1,27 @@ +%% +%% This is file 'bxtoolbox.sty'. +%% +%% Copyright (c) 2017 Takayuki YATO (aka. "ZR") +%% GitHub: https://github.com/zr-tex8r +%% Twitter: @zr_tex8r +%% +%% This package is distributed under the MIT License. +%% + +%% file declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bxtoolbox}[2017/05/29 v1.1 BX developers' toolbox] +\def\bxtb@pkgname{bxtoolbox} + +%--------------------------------------- main + +%% load submodules +\providecommand*\bxRequireDefinition[1]{% + \def\bx@@def{def}\@onefilewithoptions{#1}[][]\bx@@def} +\bxRequireDefinition{bxtoolbox} +\bxRequireDefinition{bxtoolbox-ext} +\bxRequireDefinition{bxtoolbox-ja} + +%--------------------------------------- all done +\endinput +%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxucs.sty b/Master/texmf-dist/tex/latex/bxbase/bxucs.sty deleted file mode 100644 index 39d42824f0e..00000000000 --- a/Master/texmf-dist/tex/latex/bxbase/bxucs.sty +++ /dev/null @@ -1,109 +0,0 @@ -% -% bxucs.sty -% - -%%%% package declaration -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{bxucs}[2008/03/28 v0.2 BX Unicode output] - -%%%% preparation -\RequirePackage{bxbase} - -%%%% error messages -\def\bxus@pkgname{bxucs} -\def\bxus@error{\PackageError\bxus@pkgname} -\def\bxus@err@inf#1{\bxus@error - {extra characters after number}% - {I ignore such characters}} -\def\bxus@err@nousf{\bxus@error - {Unicode subfont encoding not declared\MessageBreak - for family '\f@family'}\@ehc} - -%%%% declare encoding 'USF' -% There must be at least one valid font shape in USF encoding and is set -% in \DeclareFontSubstitution properly; otherwise an error will occur at -% the beginning of document. Here we use the value of 'error font' as -% dummy default font of USF encoding. -\DeclareFontEncoding{USF}{}{} -\bgroup \escapechar\m@ne \error@fontshape - \DeclareFontFamily{USF}{\f@family}{} - \global\expandafter\let - \csname USF/\f@family/\f@series/\f@shape\expandafter\endcsname - \csname \f@encoding/\f@family/\f@series/\f@shape\endcsname - \xdef\bx@nxt{\noexpand\DeclareFontSubstitution - {USF}{\f@family}{\f@series}{\f@shape}} -\egroup \bx@nxt - -%%%% \USFDeclareFontShape{<family>}{<list>} -% <list> is a range list of available Unicode-row-numbers. -\def\USFDeclareFontShape#1#2{% - \edef\bx@nxt{\uppercase{\def\noexpand\bxus@dfs@range{#2}}}% - \edef\bxus@dfs@fam{#1}\bx@nxt - \ifx\bxus@dfs@range\@empty \def\bxus@dfs@range{00-FF}\fi - \afterassignment\bxus@decl@fontshape\def\bxus@dfs@body##1} -\def\bxus@decl@fontshape{% - \DeclareFontFamily{USF}{\bxus@dfs@fam}{\relax}% make last arg non-empty - {\let\bxus@do\bxus@dfs@do\bxus@hexrange\bxus@dfs@range}} -\def\bxus@dfs@do{% - \bxToHexTwo\@tempcnta \bxToLower\bxHex\edef\guz{\bxRes}% - \global\expandafter\let - \csname bxus@U/\bxus@dfs@fam/\bxRes\endcsname=t% - \DeclareFontFamily{USF}{\bxus@dfs@fam=U\bxRes}{}% - \bxDebug{font family \bxus@dfs@fam=U\bxRes\space loaded}% - \edef\USFShape{% - \noexpand\DeclareFontShape{USF}{\bxus@dfs@fam=U\bxRes}}% - \bxus@dfs@body\bxRes} - -%%%% \bx@Ux@ucs -\def\bx@Ux@ucs{% code value is given in \bxUcv - \bxus@loadfontdef - \ifnum\bxUcv<\p@% \p@ equals 65536 - \bxToHexFour\bxUcv \expandafter\bxus@uxh@a\bxHex\@nil - \else \expandafter\bx@UI \fi} - -%%%% \bx@Uxh@ucs -\def\bx@Uxh@ucs#1{% - \bxus@loadfontdef\edef\bxHex{#1}% - \expandafter\bxus@uxh@a\bxHex\@nil} -\def\bxus@uxh@a#1#2#3#4\@nil{% - \bxDebug{char "\bxHex}% - \lowercase{\bxus@uxh@b{#1#2}}{#3#4}} -\def\bxus@uxh@b#1#2{% - \bgroup - \expandafter\ifx\csname bxus@U/\f@family/#1\endcsname\relax\else - \fontencoding{USF}\fontfamily{\f@family=U#1}\selectfont - \@tempcnta="#2\relax\bxus@chkchr - \ifbxOk \char\@tempcnta \aftergroup\@gobble \fi - \fi - \egroup \bxus@uxh@x} % this \bxus@uxh@x may be gobbled -\def\bxus@uxh@x{% - \bxDebug{fallback}\bx@UIh\bxHex} - -%%%% \bxus@chkchr -\def\bxus@chkchr{% - \iffontchar\font\@tempcnta \bxOktrue \else \bxOkfalse \fi} -\ifnum\bxEngineTypeY=\z@ -\def\bxus@chkchr{\bxOktrue} -\fi - -%%%% \bxus@loadfontdef -\def\bxus@loadfontdef{% - \expandafter\ifx\csname USF+\f@family\endcsname\relax - \begingroup \let\typeout\@font@info \escapechar\m@ne - \def\f@encoding{USF}\try@load@fontshape - \endgroup\fi - \expandafter\ifx\csname USF+\f@family\endcsname\@empty - \bxus@err@nousf \expandafter\bxus@skiptonil\fi} -\def\bxus@skiptonil#1\@nil{} - -%%%% \bxus@hexrange{<range-list>} -\def\bxus@hexrange#1{% - \@for\bxus@u:=#1\do{\expandafter\bxus@hexrange@a\bxus@u--\@nil}} -\def\bxus@hexrange@a#1-#2-#3\@nil{% - \if-#2-\@tempcnta"#1\relax\bxus@do - \else\@tempcnta"#1\@tempcntb"#2\relax\expandafter\bxus@hexrange@b\fi} -\def\bxus@hexrange@b{% - \@whilenum\@tempcnta<\@tempcntb\do{\bxus@do\advance\@tempcnta\@ne}% - \bxus@do} - -%% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxutf8.def b/Master/texmf-dist/tex/latex/bxbase/bxutf8.def index 1422552e095..9fd21684250 100644 --- a/Master/texmf-dist/tex/latex/bxbase/bxutf8.def +++ b/Master/texmf-dist/tex/latex/bxbase/bxutf8.def @@ -1,34 +1,58 @@ +%% +%% This is file 'bxutf8.def'. +%% % -% bxutf8.def -% -%%%% package declarations -\ProvidesFile{bxutf8.def}[2010/05/05 v0.5 BX UTF-8 input encoding] +%% file declaration +\ProvidesFile{bxutf8.def}[2017/05/29 v1.1 BX UTF-8 input encoding] % % Note: All definitions in this file should be local. +% This file should not spill any spaces or \par. % -%%%% preparation -% Here spaces are set back to valid. So great care must be taken +%% code guards +% Here spaces are set back to effective. So great care must be taken % so spaces should not be spilt out (in horizontal mode). \catcode32=10\relax -\expandafter\edef\csname bx@b@resetcatcodes\endcsname{% " . : @ - \catcode34=\the\catcode34\catcode46=\the\catcode46% - \catcode58=\the\catcode39\catcode64=\the\catcode64\relax}% -\catcode34=12 \catcode46=12 \catcode58=12 \catcode64=11 % +\edef\bxus@i@restore@codes{% + \catcode33=\the\catcode33% + \catcode34=\the\catcode34% + \catcode39=\the\catcode39% + \catcode45=\the\catcode45% + \catcode46=\the\catcode46% + \catcode47=\the\catcode47% + \catcode58=\the\catcode58% + \catcode63=\the\catcode63% + \catcode96=\the\catcode96% +\relax} +\catcode33=12 % <!> +\catcode34=12 % <"> +\catcode39=12 % <'> +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\catcode58=12 % <:> +\catcode63=12 % <?> +\catcode96=12 % <`> +\g@addto@macro\bxus@i@restore@codes{% + \let\bxus@i@restore@codes\@undefined}% +% +%--------------------------------------- dynamic part +% % abort when this is first loaded after \begin{document} \def\bxus@i@error{\PackageError{inputenc}}% \ifx\@nodocument\relax \ifx\bxus@bxutf@loaded\@undefined - \bxus@i@error{cannot load `bxutf8' after \string\begin{document}}% - \@eha \bx@b@resetcatcodes\endinput\fi\fi + \bxus@i@error + {cannot load `bxutf8' after \string\begin{document}}\@eha + \bxus@i@restore@codes\endinput\fi\fi % -%%%% load 'utf8' encoding +%% load 'utf8' encoding \InputIfFileExists{utf8.def}{}% - {\bxus@i@error{input encoding `utf8' unavailable}% - \@eha \bx@b@resetcatcodes\endinput}% -\makeatletter + {\bxus@i@error{input encoding `utf8' unavailable}\@eha + \bxus@i@restore@codes\endinput}% +\makeatletter % is this needed?? %\@inpenc@test % This is done in utf8.def % -%%%% attach the hook +%% attach the hook \def\UTFviii@two@octets#1#2{\expandafter\bxus@choice \csname u8:#1\string#2\endcsname#1#2.@}% \def\UTFviii@three@octets#1#2#3{\expandafter\bxus@choice @@ -36,33 +60,21 @@ \def\UTFviii@four@octets#1#2#3#4{\expandafter\bxus@choice@four \csname u8:#1\string#2\string#3\string#4\endcsname#1#2#3#4@}% % -%%%% attach the hook (old version) -% * This hook was found to fail in pTeX. -% Here #1 is a control word of form \u8:<UTF-8_bytes>. If it is -% defined in standard way of utf8.def, then it is dispatched; -% otherwise it is passed to \bxus@preproc. -%\def\UTFviii@defined#1{% -% \ifx#1\relax \bxus@preproc#1% -% \else\expandafter#1\fi}% -%%%% \bxus@preproc\CS -%\def\bxus@preproc#1{% -% \expandafter\bxus@preproc@a\string#1..\@nil}% -%\def\bxus@preproc@a#1:#2#3#4#5#6\@nil{% -% \if.#5\bxus@proc#2#3#4\else\bxus@err@uknbc\fi}% -% % When this file is reloaded, the 'static' part will be skipped. \ifx\bxus@bxutf@loaded\@undefined\else - \bx@b@resetcatcodes\endinput \fi + \bxus@i@restore@codes\endinput \fi \let\bxus@bxutf@loaded=t% % -%%---------- Beginning of static part +%--------------------------------------- static part % -%%%% error messages -\def\bxus@err@uknbc{\bxus@i@error{Unknown non-BMP character found}% +%% error messages +\def\bxus@err@uknbc{\bxus@i@error + {Unknown non-BMP character found}% {bxutf8 cannot handle non-BMP characters.}}% -\def\bxus@err@nodrv{\bxus@i@error{Unicode driver not found}\@ehb}% +\def\bxus@err@nodrv{\bxus@i@error + {Unicode driver not found}\@ehb}% % -%%%% make tables +%% make tables for 'nybble conversion' \def\bxus@fornbl{% \bxus@fornbl@a00001102203310411512613720821922A23B30C31D32E33FXXX}% \def\bxus@fornbl@a#1#2#3{% @@ -78,26 +90,26 @@ \lowercase{\expandafter\gdef\csname bxus@@!\endcsname{#2}}}}% \bxus@fornbl \@namedef{bxus@@.}{}% % -%%%% \bxcs@choice -%% Called in the form -%% \bxus@choice[\u8:??]??.@ (2-byte) or -%% \bxus@choice[\u8:???]???@ (3-byte) -%% where ?? is a (TF-8 byte string and [\u8:...] denotes a single -%% control word. This macro expands to the control word if it is -%% defined; otherwise expands to \bxus@proc. +%% \bxcs@choice +% Called in the form +% \bxus@choice[\u8:??]??.@ (2-byte) or +% \bxus@choice[\u8:???]???@ (3-byte) +% where ?? is a (TF-8 byte string and [\u8:...] denotes a single +% control word. This macro expands to the control word if it is +% defined; otherwise expands to \bxus@proc. \def\bxus@choice#1#2@{% \ifx#1\relax \bxus@proc#2% \else\expandafter#1\fi}% % -%%%% \bxus@choice@four +%% \bxus@choice@four \def\bxus@choice@four#1#2@{% \ifx#1\relax \bxus@prociv#2% \else\expandafter#1\fi}% % -%%%% \bxus@proc -%% When ??? is the UTF-8 string of U+XXXX (padded to length 3 with -%% a dot), then \bxus@proc@a??? fully expands to \bxUHex{XXXX}. -%% (\bxUHex should be robust.) +%% \bxus@proc +% When ??? is the UTF-8 string of U+XXXX (padded to length 3 with +% a dot), then \bxus@proc@a??? fully expands to \bxUHex{XXXX}. +% (\bxUHex should be robust.) \def\bxus@proc#1#2#3{% \expandafter\bxus@proc@b\csname bxus@@\string#1\expandafter\endcsname \csname bxus@@\string#2\expandafter\endcsname @@ -123,6 +135,8 @@ \def\bxus@proc@g#1\@nil#2\@nil{% \bxUHex{#2#1}}% % +%% \bxus@prociv +% The variant of \bxus@proc that is adapted to 4-octet sequences. \def\bxus@prociv#1#2#3#4{% \expandafter\bxus@prociv@a\csname bxus@@\string#1\expandafter\endcsname \csname bxus@@\string#2\expandafter\endcsname @@ -130,39 +144,39 @@ \csname bxus@@\string#4\endcsname}% \def\bxus@prociv@a#1#2#3#4{% \expandafter\expandafter\expandafter\bxus@prociv@b - \expandafter#3#4@#1#2} + \expandafter#3#4@#1#2}% \def\bxus@prociv@b#1@#2#3{% \expandafter\expandafter\expandafter\bxus@prociv@c - \expandafter#2#3#1@@} + \expandafter#2#3#1@@}% \def\bxus@prociv@c#1#2#3#4{% \expandafter\bxus@prociv@d\csname bxus@*#1#2\expandafter\endcsname - \csname bxus@*#3#4\endcsname} + \csname bxus@*#3#4\endcsname}% \def\bxus@prociv@d#1#2{% \expandafter\expandafter\expandafter\bxus@prociv@e - \expandafter#1#2} -\def\bxus@prociv@e#1#2#3@#4@{\bxus@prociv@f#3@#4#1#2@} + \expandafter#1#2}% +\def\bxus@prociv@e#1#2#3@#4@{\bxus@prociv@f#3@#4#1#2@}% \def\bxus@prociv@f#1#2#3#4{% \expandafter\bxus@prociv@g\csname bxus@*#1#2\expandafter\endcsname - \csname bxus@*#3#4\endcsname} + \csname bxus@*#3#4\endcsname}% \def\bxus@prociv@g#1#2{% \expandafter\expandafter\expandafter\bxus@prociv@h - \expandafter#1#2} -\def\bxus@prociv@h#1#2#3@#4@{\bxus@prociv@i#3@#4#1#2@} + \expandafter#1#2}% +\def\bxus@prociv@h#1#2#3@#4@{\bxus@prociv@i#3@#4#1#2@}% \def\bxus@prociv@i#1#2#3#4{% \expandafter\bxus@prociv@j\csname bxus@*#1#2\expandafter\endcsname - \csname bxus@*#3#4\endcsname} + \csname bxus@*#3#4\endcsname}% \def\bxus@prociv@j#1#2{% \expandafter\expandafter\expandafter\bxus@prociv@k - \expandafter#1#2} -\def\bxus@prociv@k#1#2@#3@{\bxUHex{#3#1#2}} - - - - -%%%% default (useless) Unicode driver -\providecommand*\bxUHex[1]{?\protect\bxus@err@nodrv}% -% -%%%% all done -\bx@b@resetcatcodes + \expandafter#1#2}% +\def\bxus@prociv@k#1#2@#3@{\bxUHex{#3#1#2}}% +% +% +%% default (useless) Unicode driver +% Note: this \bxUHex definition is used for check. +\providecommand*\bxUHex{\bxUHexDummyBxutf}% +\newcommand*\bxUHexDummyBxutf[1]{?\protect\bxus@err@nodrv}% +% +%--------------------------------------- all done +\bxus@i@restore@codes \endinput %% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/bxutf8x.def b/Master/texmf-dist/tex/latex/bxbase/bxutf8x.def index a703d5bfe94..972f392fd94 100644 --- a/Master/texmf-dist/tex/latex/bxbase/bxutf8x.def +++ b/Master/texmf-dist/tex/latex/bxbase/bxutf8x.def @@ -1,40 +1,54 @@ +%% +%% This is file 'bxutf8x.def'. +%% % -% bxutf8x.def -% -%%%% package declarations -\ProvidesFile{bxutf8x.def}[2008/04/06 v0.3 - BX UTF-8 input encoding (ucs ver.)] +%% file declaration +\ProvidesFile{bxutf8x.def}[2017/05/29 v1.1 BX extended utf8x input] % % Note: All definitions in this file should be local. +% This file should not spill any spaces or \par. % -%%%% preparation +%% code guards \catcode32=10\relax -\expandafter\edef\csname bx@b@resetcatcodes\endcsname{% " . : @ - \catcode34=\the\catcode34\catcode46=\the\catcode46% - \catcode58=\the\catcode39\catcode64=\the\catcode64\relax}% -\catcode34=12 \catcode46=12 \catcode58=12 \catcode64=11 % +\expandafter\edef\csname bxus@i@restore@codes\endcsname{% + \catcode34=\the\catcode34% <"> + \catcode46=\the\catcode46% <.> + \catcode58=\the\catcode58% <:> + \catcode64=\the\catcode64% <@> +\relax}% +\catcode34=12 % +\catcode46=12 % +\catcode58=12 % +\catcode64=11 % +\g@addto@macro\bxus@i@restore@codes{% + \let\bxus@i@restore@codes\@undefined}% +% +%--------------------------------------- dynamic part +% \def\bxus@i@error{\PackageError{inputenc}}% \ifx\@nodocument\relax \ifx\bxus@bxutfx@loaded\@undefined - \bxus@i@error{cannot load `bxutf8x' after \string\begin{document}}% - \@eha \bx@b@resetcatcodes\endinput\fi\fi + \bxus@i@error + {cannot load `bxutf8x' after \string\begin{document}}\@eha + \bxus@i@restore@codes\endinput\fi\fi % -%%%% load 'utf8x' encoding +%% load 'utf8x' encoding \InputIfFileExists{utf8x.def}{}% {\PackageError{inputenc}{input encoding `utf8x' unavailable}% {You must install `unicode' package to use it.}% - \bx@b@resetcatcodes\endinput}% + \bxus@i@restore@codes\endinput}% %\@inpenc@test % This is done in utf8.def % % When this file is reloaded, the 'static' part will be skipped. \ifx\bxus@bxutfx@loaded\@undefined\else - \bx@b@resetcatcodes \endinput \fi + \bxus@i@restore@codes \endinput \fi \let\bxus@bxutfx@loaded=t% % -%%---------- Beginning of static part +%--------------------------------------- Static part % -%%%% error messages -\def\bxus@err@nodrv{\bxus@i@error{Unicode driver not found}\@ehb}% +%% error messages +\def\bxus@err@nodrv{\bxus@i@error + {Unicode driver not found}\@ehb}% % %%%% \bxus@uc@char@notloaded % Hooked version of \uc@char@notloaded @@ -58,23 +72,25 @@ \def\bxus@uc@notloaderr#1#2#3{% \bxUInt{#1}}% \bxUInt should be robust % -%%%% attach the hook +%% attach the hook % Note that ucs.sty could be loaded after utf8x.def. \AtBeginDocument{% \let\uc@notloaderr\bxus@uc@notloaderr \let\uc@char@notloaded\bxus@uc@char@notloaded}% % -%%%% force ucs 'fasterrors' option switched on +%% force ucs 'fasterrors' option switched on % Heavy 'uninames' decoding process is of no use in presence of the hook, % and it causes unexpected result in use of pTeX. \AtBeginDocument{% \let\UnicodeOptionfasterrorsfalse\UnicodeOptionfasterrorstrue \UnicodeOptionfasterrorstrue}% % -%%%% default (useless) Unicode driver -\providecommand*\bxUInt[1]{?\protect\bxus@err@nodrv}% +%% default (useless) Unicode driver +% Note: this \bxUHex definition is used for check. +\providecommand*\bxUInt{\bxUIntDummyBxutfx}% +\newcommand*\bxUIntDummyBxutfx[1]{?\protect\bxus@err@nodrv}% % -%%%% all done -\bx@b@resetcatcodes +%--------------------------------------- all done +\bxus@i@restore@codes \endinput %% EOF diff --git a/Master/texmf-dist/tex/latex/bxbase/zxbase.sty b/Master/texmf-dist/tex/latex/bxbase/zxbase.sty index be7e5189fcf..4d5b2baef31 100644 --- a/Master/texmf-dist/tex/latex/bxbase/zxbase.sty +++ b/Master/texmf-dist/tex/latex/bxbase/zxbase.sty @@ -1,21 +1,27 @@ -% -% zxbase.sty -% -%%%% package declaration +%% +%% This is file 'zxbase.sty'. +%% +%% Copyright (c) 2017 Takayuki YATO (aka. "ZR") +%% GitHub: https://github.com/zr-tex8r +%% Twitter: @zr_tex8r +%% +%% This package is distributed under the MIT License. +%% + +%% package declaration \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{zxbase}[2009/11/16] +\ProvidesPackage{zxbase}[2017/05/29 v1.1] \RequirePackage{ifxetex} \RequireXeTeX -%%%% preparations +%% preparations \RequirePackage{bxbase} \def\zx@pkgname{zxbase} -\def\zx@error{\PackageError\zx@pkgname} -\def\zx@warn{\PackageWarningNoLine\zx@pkgname} -%%------ generic family detection +%--------------------------------------- generic family detection -%%%% constants \zxSpecFamily, \zxRMFamily, etc. +%%<+> \zxSpecFamily / \zxRMFamily / \zxSFFamily / \zxTTFamily +% The constants signifying each generic family. % These values can be considered as fixed, so you can say i.e. % "\ifnum\zxGFFlag<\zxSFFamily <non-sans> \else <sans> \fi" \chardef\zxSpecFamily=0 @@ -23,7 +29,7 @@ \chardef\zxSFFamily=2 \chardef\zxTTFamily=3 -%%%% \zx@set@genfamflag +%% \zx@set@genfamflag % A patch to be inserted to \selectfont. This makes \selectfont % set a right \zx..Family constant to \zxGFFlag. \def\zx@set@genfamflag{% @@ -40,7 +46,7 @@ \zx@set@gff@get\zx@genfam#1% \ifx\zx@genfam\zx@curfam \let\zxGFFlag#2\fi} -%%%% \zxBDHookGenFamFlag +%%<+> \zxBDHookGenFamFlag \def\zxBDHookGenFamFlag{\zx@bdhook@genfamflag@do} \@onlypreamble\zx@bdhook@genfamflag@do \def\zx@bdhook@genfamflag@do{% @@ -51,8 +57,11 @@ \expandafter\def\expandafter#1\expandafter{% \expandafter\zx@set@genfamflag#1}} -%%------ Forging pTeX direction primitives +%--------------------------------------- forge pTeX primitives +% It is not totally safe, but is required so as to make +% the 'ajmacros' package work. +%%<+> \zxBDHookForgepTeXDir \def\zxBDHookForgepTeXDir{\zx@bdhook@forgeptexdir@do} \@onlypreamble\zx@bdhook@forgeptexdir@do \def\zx@bdhook@forgeptexdir@do{% @@ -65,14 +74,20 @@ \expandafter\let\csname if#1\expandafter\endcsname \csname if#2\endcsname \fi} -%%------ Forcing to read pLaTeX packages +%--------------------------------------- load pLaTeX packages +%%<+> switch 'zxPPInUTFEight' \newif\ifzxPPInUTFEight + +%% variables \newif\ifzx@jisenc -\def\zx@err@ukenc#1{\zx@error{File '#1' is in unknown encoding}% -{The file must be encoded in ISO-2022-JP or UTF-8.}} -%%%% \zxRequirepLaTeXPackage +%% errors +\def\zx@err@ukenc#1{\PackageError\zx@pkgname + {File '#1' is in unknown encoding}% + {The file must be encoded in ISO-2022-JP or UTF-8.}} + +%%<+> \zxRequirepLaTeXPackage{<package>} \@onlypreamble\zxRequirepLaTeXPackage \def\zxRequirepLaTeXPackage#1{% \ifzxPPInUTFEight \zx@jisencfalse @@ -82,17 +97,17 @@ \fi \let\NeedsTeXFormat\zx@mute@NeedsTeXFormat \ifzx@jisenc \XeTeXdefaultencoding ISO-2022-JP\relax \fi - \RequirePackage{#1}% + \RequirePackage{#1}\relax \ifzx@jisenc \XeTeXdefaultencoding auto\relax \fi \let\NeedsTeXFormat\zx@org@NeedsTeXFormat } -%%%% \zx@mute@NeedsTeXFormat +%% \zx@mute@NeedsTeXFormat \def\zx@mute@NeedsTeXFormat#1{\@ifnextchar[{\zx@mute@ntf@a}{\relax}} \def\zx@mute@ntf@a[#1]{\relax} \let\zx@org@NeedsTeXFormat\NeedsTeXFormat -%%%% \zx@checkjisorutfeight{<file>} +%% \zx@checkjisorutfeight{<file>} % Decides whether <file> is encoded in JIS or UTF-8 and sets to \zx@joru. % 0:binary; 1:JIS; 2:UTF-8; 3:US-ASCII \def\zx@checkjisorutfeight#1{% @@ -127,25 +142,8 @@ %%<*> \platexpackagesinunicode \@onlypreamble\platexpackagesinunicode -\let\platexpackagesinunicode\zxPPInUTFEight - -%%------ trashed stuff - -%\def\zxRemoveFSSuffix#1{% -% \edef\zx@tmpx{#1}\bxOkfalse -% \let\bxRes\@empty \let\zx@chunk\@gobble -% \expandafter\zx@rem@fssfx@a\zx@tmpx(@\@nil} -%\def\zx@rem@fssfx@a#1(#2#3\@nil{% -% \ifx @#2\edef\bxRes{\bxRes\zx@chunk\@empty}% -% \def\zx@nxt{\zx@rem@fssfx@b#1@)@\@nil}% -% \else \edef\bxRes{\bxRes\zx@chunk(}\def\zx@chunk{#1}% -% \def\zx@nxt{\zx@rem@fssfx@a#2#3\@nil}% -% \fi \zx@nxt} -%\def\zx@rem@fssfx@b#1)@#2\@nil{% -% \ifx\bxRes\@empty\else -% \ifx @#2@\else \bxAssign\@tempcnta0#1\relax \fi \fi -% \ifbxOk\else \let\bxRes\zx@tmpx \fi} - -%%------ all done +\newcommand*\platexpackagesinunicode{\zxPPInUTFEighttrue} + +%--------------------------------------- all done \endinput %% EOF |