From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/bxorigcapt/LICENSE | 21 ++ macros/latex/contrib/bxorigcapt/README.md | 85 ++++++++ macros/latex/contrib/bxorigcapt/bxorigcapt.sty | 268 +++++++++++++++++++++++++ 3 files changed, 374 insertions(+) create mode 100644 macros/latex/contrib/bxorigcapt/LICENSE create mode 100644 macros/latex/contrib/bxorigcapt/README.md create mode 100644 macros/latex/contrib/bxorigcapt/bxorigcapt.sty (limited to 'macros/latex/contrib/bxorigcapt') diff --git a/macros/latex/contrib/bxorigcapt/LICENSE b/macros/latex/contrib/bxorigcapt/LICENSE new file mode 100644 index 0000000000..3c57f37df6 --- /dev/null +++ b/macros/latex/contrib/bxorigcapt/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2017-2018 Takayuki YATO (aka. "ZR") + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/macros/latex/contrib/bxorigcapt/README.md b/macros/latex/contrib/bxorigcapt/README.md new file mode 100644 index 0000000000..2f2e9275db --- /dev/null +++ b/macros/latex/contrib/bxorigcapt/README.md @@ -0,0 +1,85 @@ +BXorigcapt Package +================== + +LaTeX: To retain the original caption names when using Babel + +This package forces the caption names (`\chaptername`, `\today`, etc) +declared by the document class in use to be used as the caption names +for a specific language introduced by the Babel package. + +Starting from version 0.3, this package also supports Polyglossia. + +### System requirement + + * TeX format: LaTeX. + * TeX engine: Anything. + * Dependent packages: + - babel or polyglossia + +### Installation + + - `*.sty` → $TEXMF/tex/latex/BXorigcapt + +### License + +This package is distributed under the MIT License. + +The bxorigcapt Package +---------------------- + +### Introduction + +Suppose you have designed a document class tailored for the Esperanto +language. The class has the following definition of caption names and you +like it: + + \newcommand\contentsname{Tabelo de Enhavo} + +If a document is written solely in Esperanto, then there is no need to +employ the Babel package. (Yes, the document class should select the +hyphenation rule for the language.) However, when you want to create +document that contains Esperanto and German, then you have to utilize +Babel, to have correct hyphenations for both languages. + + \usepackage[ngerman,esperanto]{babel} + +But unfortunately, this changes `\contentsname` from “Tabelo de Enhavo” +(what you have chosen) to “Enhavo” (what is declared in the language +definition file of Babel), which is unfavorable. + +In fact, when using a document class for a specific language, the most +suitable caption names *for that language* should be the ones provided by +the class. The bxorigcapt package realizes this natual request, that is, +it enables you to make the caption names declared in the current document +class treated as the caption names for a specific language. + +### Package Loading + + \usepackage[]{bxorigcapt} + +The package option specifies a Babel language, and requires that the +caption names provided by the document class (actually the ones that are +effective when this package is loaded) should be used as the caption names +for that language. + +The option can be omitted; in that case, the main language of Babel will +be assumed. + +### Usage + +For present, this package has no public commands. All the settings are +done through the package option. + +Revision History +---------------- + + * Version 0.3 〈2018/09/05〉 + - Add support for Polyglossia. + * Version 0.2a 〈2017/05/03〉 + - Minor fix. + * Version 0.2 〈2016/04/01〉 + - The first public version. + +-------------------- +Takayuki YATO (aka. "ZR") +https://github.com/zr-tex8r diff --git a/macros/latex/contrib/bxorigcapt/bxorigcapt.sty b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty new file mode 100644 index 0000000000..631741791d --- /dev/null +++ b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty @@ -0,0 +1,268 @@ +%% +%% This is file 'bxorigcapt.sty'. +%% +%% Copyright (c) 2017-2018 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{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} + +%--------------------------------------- options + +%% \bxoc@target@lang +\let\bxoc@target@lang\relax + +%% language options +\DeclareOption*{% + \edef\bxoc@target@lang{\CurrentOption}% +} +% 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 +\def\bxoc@name@list{% + abstract,also,appendix,author,bib,cc,chapter,contents,% + encl,figure,glossary,headto,index,listfigure,listtable,% + page,part,preface,proof,ps,ref,seealso,see,subject,table,% + prepart,postpart,prechapter,postchapter,presection,postsection% +} + +%% \bxoc@deprecated@ldf@list +% The list of the names of deprecated commands. +\@onlypreamble\bxoc@deprecated@ldf@list +\def\bxoc@deprecated@ldf@list{} + +%--------------------------------------- public commands + +%%<+> \bxorigcaptDeprecateCommand{,...} +\@onlypreamble\bxorigcaptDeprecateCommand +\newcommand*\bxorigcaptDeprecateCommand[1]{% + \edef\bxoc@deprecated@ldf@list{\bxoc@deprecated@ldf@list,#1}} + +%--------------------------------------- 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 +\bxoc@if@babel@or@polyglossia@loaded{% + \ifbxoc@polyglossia@available + \AtEndPreamble{% + \bxoc@check@conflict + \bxoc@babel@hook + }% + \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 + +%% \bxoc@clear@deprecated@ldf +\@onlypreamble\bxoc@clear@deprecated@ldf +\def\bxoc@clear@deprecated@ldf{% + \begingroup + \@for\bxoc@tmpa:=\bxoc@deprecated@ldf@list\do{% + \ifx\@bxoc@tmpa\@empty\else + \expandafter\ifx\csname \bxoc@tmpa\endcsname\relax\else + \bxDebug{Smashed \@backslashchar\bxoc@tmpa}% + \global\expandafter\let\csname\bxoc@tmpa\endcsname\@empty + \fi + \fi + }% + \endgroup + \bxoc@clear@deprecated@ldf@a +} +\@onlypreamble\bxoc@clear@deprecated@ldf@a +\def\bxoc@clear@deprecated@ldf@a{% + \global\let\bxoc@clear@deprecated@ldf@a\relax + \gdef\bxorigcaptDeprecateCommand##1{% + \edef\bxoc@deprecated@ldf@list{##1}% + \bxoc@clear@deprecated@ldf}} +\g@addto@macro\bxoc@babel@hook{\bxoc@clear@deprecated@ldf} + +%--------------------------------------- save and restore + +%% variables +\let\bxoc@@today\relax +% \[bxoc@@name] + +%% \bxoc@save@captions +%% \bxoc@restore@captions +\@onlypreamble\bxoc@save@captions +\let\bxoc@save@captions\@empty +\let\bxoc@restore@captions\@empty +\begingroup + \@for\bxoc@tmpa:=\bxoc@name@list\do{% + \edef\bxoc@next{% + \noexpand\g@addto@macro\noexpand\bxoc@save@captions{% + \let\expandafter\noexpand\csname bxoc@@\bxoc@tmpa name\endcsname + \expandafter\noexpand\csname\bxoc@tmpa name\endcsname}% + }\bxoc@next + \edef\bxoc@next{% + \noexpand\g@addto@macro\noexpand\bxoc@restore@captions{% + \let\expandafter\noexpand\csname \bxoc@tmpa name\endcsname + \expandafter\noexpand\csname bxoc@@\bxoc@tmpa name\endcsname}% + }\bxoc@next + } +\endgroup + +%% \bxoc@restore@date +\def\bxoc@restore@date{% + \let\today\bxoc@@today +} + +%% \bxoc@enable@restore +\@onlypreamble\bxoc@enable@restore +\def\bxoc@enable@restore{% + \ifx\bxoc@target@lang\relax + \@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 + \PackageError\bxoc@pkgname + {Language '\bxoc@target@lang' not defined}% + \@ehc + \@namedef{date\bxoc@target@lang}{}% + \fi + \expandafter\ifx\csname captions\bxoc@target@lang\endcsname\relax + \@namedef{captions\bxoc@target@lang}{}% + \fi + \expandafter\g@addto@macro\csname date\bxoc@target@lang\endcsname{% + \bxoc@restore@date}% + \expandafter\g@addto@macro\csname captions\bxoc@target@lang\endcsname{% + \bxoc@restore@captions}% +} + +%% Saves the current captions +\bxoc@save@captions +\let\bxoc@@today\today +\g@addto@macro\bxoc@babel@hook{\bxoc@enable@restore} + +%--------------------------------------- done +\endinput +%% EOF -- cgit v1.2.3