summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/bxorigcapt/bxorigcapt.sty')
-rw-r--r--macros/latex/contrib/bxorigcapt/bxorigcapt.sty65
1 files changed, 46 insertions, 19 deletions
diff --git a/macros/latex/contrib/bxorigcapt/bxorigcapt.sty b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
index 631741791d..14faeccb3a 100644
--- a/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
+++ b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
@@ -1,7 +1,7 @@
%%
%% This is file 'bxorigcapt.sty'.
%%
-%% Copyright (c) 2017-2018 Takayuki YATO (aka. "ZR")
+%% Copyright (c) 2016-2022 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
@@ -10,7 +10,7 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bxorigcapt}[2018/09/05 v0.2a]
+\ProvidesPackage{bxorigcapt}[2022/03/12 v0.4]
\def\bxoc@pkgname{bxorigcapt}
\providecommand*\bxDebug[1]{}
@@ -38,41 +38,61 @@
%% \bxoc@target@lang
\let\bxoc@target@lang\relax
-%% language options
+%% \bxoc@warn@or@info
+\let\bxoc@warn@or@info\PackageInfo
+
+%% handle options
+% 'warn'
+\DeclareOption{warn}{%
+ \let\bxoc@warn@or@info\PackageWarning
+}
+% language options
\DeclareOption*{%
\edef\bxoc@target@lang{\CurrentOption}%
}
% dispatch
\ProcessOptions*
+\bxDebug{target language = %
+ \ifx\bxoc@target@lang\relax (main)\else \bxoc@target@lang\fi}
%--------------------------------------- environment
+%% switch 'bxoc@etoolbox@available'
+\newif\ifbxoc@etoolbox@available
%% 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
+ %% set 'bxoc@etoolbox@available'
+ \@tempswafalse
+ \bxoc@next\eTeXversion
\if@tempswa
- \IfFileExists{polyglossia.sty}{}{\@tempswafalse}
\IfFileExists{etoolbox.sty}{}{\@tempswafalse}
\fi
\if@tempswa
- \bxDebug{Polyglossia might be loaded}
- \global\bxoc@polyglossia@availabletrue
+ \bxDebug{etoolbox is available}
+ \global\bxoc@etoolbox@availabletrue
+ %% set 'bxoc@polyglossia@available'
+ \@tempswafalse
+ \bxoc@next\XeTeXversion
+ \bxoc@next\luatexversion
+ \if@tempswa
+ \IfFileExists{polyglossia.sty}{}{\@tempswafalse}
+ \fi
+ \if@tempswa
+ \bxDebug{Polyglossia is available}
+ \global\bxoc@polyglossia@availabletrue
+ \fi
\fi
\endgroup
%--------------------------------------- general
%% packages
-\ifbxoc@polyglossia@available
+\ifbxoc@etoolbox@available
\RequirePackage{etoolbox}\relax
\fi
@@ -137,7 +157,7 @@
\@onlypreamble\bxoc@babel@hook
\let\bxoc@babel@hook\@empty
\bxoc@if@babel@or@polyglossia@loaded{%
- \ifbxoc@polyglossia@available
+ \ifbxoc@etoolbox@available
\AtEndPreamble{%
\bxoc@check@conflict
\bxoc@babel@hook
@@ -146,15 +166,15 @@
\AtEndOfPackage{\bxoc@babel@hook}%
\fi
}{%else
- \ifbxoc@polyglossia@available
+ \ifbxoc@etoolbox@available
\AtEndPreamble{%
\bxoc@if@babel@or@polyglossia@loaded{%
\bxoc@check@conflict
\bxoc@babel@hook
}{%else
- \PackageWarning\bxoc@pkgname
+ \bxoc@warn@or@info\bxoc@pkgname
{Neither Polyglossia nor Babel is\MessageBreak
- loaded,}%
+ loaded, reported}%
}%
}%
\else
@@ -162,8 +182,8 @@
\@ifpackageloaded{babel}{%
\bxoc@babel@hook
}{%else
- \PackageWarning\bxoc@pkgname
- {Babel is not loaded,}%
+ \bxoc@warn@or@info\bxoc@pkgname
+ {Babel is not loaded,\MessageBreak reported}%
}%
}%
\fi
@@ -242,7 +262,7 @@
\@namedef{date\bxoc@target@lang}{}%
\fi
\fi
- \bxDebug{target=\bxoc@target@lang}%
+ \bxDebug{target language = \bxoc@target@lang}%
\expandafter\ifx\csname date\bxoc@target@lang\endcsname\relax
\PackageError\bxoc@pkgname
{Language '\bxoc@target@lang' not defined}%
@@ -256,6 +276,13 @@
\bxoc@restore@date}%
\expandafter\g@addto@macro\csname captions\bxoc@target@lang\endcsname{%
\bxoc@restore@captions}%
+ \ifbxoc@etoolbox@available
+ % do not do 'ensure'!
+ \ifcsundef{bbl@e@\bxoc@target@lang}{}{%else
+ \bxDebug{ensure for \bxoc@target@lang\space invalidated}%
+ \csundef{bbl@e@\bxoc@target@lang}%
+ }%
+ \fi
}
%% Saves the current captions