diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/bxbase/bxbase.def')
-rw-r--r-- | Master/texmf-dist/tex/latex/bxbase/bxbase.def | 750 |
1 files changed, 316 insertions, 434 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 |