diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-06 20:46:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-06 20:46:58 +0000 |
commit | 15d1db0618b158e41f253e9d8af74981f10d0dd3 (patch) | |
tree | 4f89e5ce11da2200e66d268491a3ed303b37f213 /Master/texmf-dist/tex | |
parent | 08af94e2a63f24404c74314179a09c18d9e47850 (diff) |
bxorigcapt (6sep18)
git-svn-id: svn://tug.org/texlive/trunk@48606 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/bxorigcapt/bxorigcapt.sty | 121 |
1 files changed, 108 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/latex/bxorigcapt/bxorigcapt.sty b/Master/texmf-dist/tex/latex/bxorigcapt/bxorigcapt.sty index 6de4b9386ef..631741791dc 100644 --- a/Master/texmf-dist/tex/latex/bxorigcapt/bxorigcapt.sty +++ b/Master/texmf-dist/tex/latex/bxorigcapt/bxorigcapt.sty @@ -1,7 +1,7 @@ %% %% This is file 'bxorigcapt.sty'. -%% -%% Copyright (c) 2017 Takayuki YATO (aka. "ZR") +%% +%% Copyright (c) 2017-2018 Takayuki YATO (aka. "ZR") %% GitHub: https://github.com/zr-tex8r %% Twitter: @zr_tex8r %% @@ -10,21 +10,25 @@ %% package declaration \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{bxorigcapt}[2017/05/03 v0.2a] +\ProvidesPackage{bxorigcapt}[2018/09/05 v0.2a] \def\bxoc@pkgname{bxorigcapt} \providecommand*\bxDebug[1]{} %% code guard \edef\bxoc@restore@codes{% +\catcode33=\the\catcode33% \catcode39=\the\catcode39% \catcode46=\the\catcode46% \catcode47=\the\catcode47% \catcode58=\the\catcode58% +\catcode63=\the\catcode63% \relax} +\catcode33=12 % <!> \catcode39=12 % <'> \catcode46=12 % <.> \catcode47=12 % </> \catcode58=12 % <:> +\catcode63=12 % <?> \AtEndOfPackage{% \bxoc@restore@codes \let\bxoc@restore@codes\relax} @@ -41,8 +45,37 @@ % dispatch \ProcessOptions* +%--------------------------------------- environment + +%% switch 'bxoc@polyglossia@available' +\newif\ifbxoc@polyglossia@available +\begingroup + \@tempswafalse + % engine check + \def\bxoc@next#1{% + \edef\bxoc@tmpa{\string#1}\edef\bxoc@tmpb{\meaning#1}% + \ifx\bxoc@tmpa\bxoc@tmpb \@tempswatrue \fi + } + \bxoc@next\XeTeXversion + \bxoc@next\luatexversion + % file check + \if@tempswa + \IfFileExists{polyglossia.sty}{}{\@tempswafalse} + \IfFileExists{etoolbox.sty}{}{\@tempswafalse} + \fi + \if@tempswa + \bxDebug{Polyglossia might be loaded} + \global\bxoc@polyglossia@availabletrue + \fi +\endgroup + %--------------------------------------- general +%% packages +\ifbxoc@polyglossia@available + \RequirePackage{etoolbox}\relax +\fi + %% \bxoc@name@list % The list of caption names. \@onlypreamble\bxoc@name@list @@ -67,22 +100,73 @@ %--------------------------------------- hook +%% \bxoc@check@conflict +% Check if both babel and polyglossia are loaded, and then +% annihilate all the function of this package. +\@onlypreamble\bxoc@check@conflict +\def\bxoc@check@conflict{% + \@ifpackageloaded{polyglossia}{% + %NB. polyglossia marks babel as loaded. + \@ifpackageloaded{babel}{% + \ifx\bbl@afterelse\@undefined\else % Babel is REALLY loaded + \PackageError\bxoc@pkgname + {Both Babel and Polyglossia are loaded!\MessageBreak + Such usage is not supported}% + {All the function of \bxoc@pkgname\space + is invalidated.\MessageBreak\@ehc}% + % annihilate + \let\bxoc@babel@hook\relax + \let\bxoc@check@conflict\relax + \fi + }{}% + }{}% +} + +%% \bxoc@if@babel@or@polyglossia@loaded +\@onlypreamble\bxoc@if@babel@or@polyglossia@loaded +\def\bxoc@if@babel@or@polyglossia@loaded{% + \let\bxoc@next\@secondoftwo + \@ifpackageloaded{babel}{\let\bxoc@next\@firstoftwo}{}% + \@ifpackageloaded{polyglossia}{\let\bxoc@next\@firstoftwo}{}% + \bxoc@next +} + %% \bxoc@babel@hook % Note that \bxoc@babel@hook must be invoked between the loading % of babel and the dispatch of babel's begin-document hook. \@onlypreamble\bxoc@babel@hook \let\bxoc@babel@hook\@empty -\@ifpackageloaded{babel}{% - \AtEndOfPackage{\bxoc@babel@hook}% -}{%else - \AtBeginDocument{% - \@ifpackageloaded{babel}{% +\bxoc@if@babel@or@polyglossia@loaded{% + \ifbxoc@polyglossia@available + \AtEndPreamble{% + \bxoc@check@conflict \bxoc@babel@hook - }{%else - \PackageWarning\bxoc@pkgname - {Babel is not loaded,}% }% - }% + \else + \AtEndOfPackage{\bxoc@babel@hook}% + \fi +}{%else + \ifbxoc@polyglossia@available + \AtEndPreamble{% + \bxoc@if@babel@or@polyglossia@loaded{% + \bxoc@check@conflict + \bxoc@babel@hook + }{%else + \PackageWarning\bxoc@pkgname + {Neither Polyglossia nor Babel is\MessageBreak + loaded,}% + }% + }% + \else + \AtBeginDocument{% + \@ifpackageloaded{babel}{% + \bxoc@babel@hook + }{%else + \PackageWarning\bxoc@pkgname + {Babel is not loaded,}% + }% + }% + \fi } %--------------------------------------- deprecated ldf stuffs @@ -145,7 +229,18 @@ \@onlypreamble\bxoc@enable@restore \def\bxoc@enable@restore{% \ifx\bxoc@target@lang\relax - \let\bxoc@target@lang\bbl@main@language + \@ifpackageloaded{polyglossia}{% + \let\bxoc@target@lang\xpg@main@language + }{%else + \let\bxoc@target@lang\bbl@main@language + }% + \ifx\bxoc@target@lang\@undefined + \PackageError\bxoc@pkgname + {The main language is not set}% + {\@ehc}% + \def\bxoc@target@lang{?bxoc} + \@namedef{date\bxoc@target@lang}{}% + \fi \fi \bxDebug{target=\bxoc@target@lang}% \expandafter\ifx\csname date\bxoc@target@lang\endcsname\relax |