summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/bxorigcapt
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-04-18 03:02:01 +0000
committerNorbert Preining <norbert@preining.info>2022-04-18 03:02:01 +0000
commita7538780c749168835167a8d30aa65779c89407a (patch)
tree1c2830860017d02e2b51a7f1b7e7279ac743b53c /macros/latex/contrib/bxorigcapt
parente247b78b2fce9bdb26193826aca0a62ae26c8a8b (diff)
CTAN sync 202204180302
Diffstat (limited to 'macros/latex/contrib/bxorigcapt')
-rw-r--r--macros/latex/contrib/bxorigcapt/README.md56
-rw-r--r--macros/latex/contrib/bxorigcapt/bxorigcapt.pdfbin0 -> 256321 bytes
-rw-r--r--macros/latex/contrib/bxorigcapt/bxorigcapt.sty154
-rw-r--r--macros/latex/contrib/bxorigcapt/bxorigcapt.tex112
4 files changed, 179 insertions, 143 deletions
diff --git a/macros/latex/contrib/bxorigcapt/README.md b/macros/latex/contrib/bxorigcapt/README.md
index 577af79fa9..a17c825fad 100644
--- a/macros/latex/contrib/bxorigcapt/README.md
+++ b/macros/latex/contrib/bxorigcapt/README.md
@@ -12,9 +12,10 @@ Starting from version 0.3, this package also supports Polyglossia.
### System requirement
* TeX format: LaTeX.
- * TeX engine: Anything.
+ * TeX engine: Any engine with e-TeX extension.
* Dependent packages:
- babel or polyglossia
+ - etoolbox v2.1+
### Installation
@@ -24,59 +25,22 @@ Starting from version 0.3, this package also supports Polyglossia.
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[<option>,...]{bxorigcapt}
-
-Available options are:
-
- - a Babel language name: Specifies the target language. The default
- target language is the main language of Babel.
- - `warn`: Issues a warning (instead of an info) if Babel is never
- loaded in the preamble.
-
-### Usage
-
-Once this package is loaded, the caption names provided by the document
-class (actually the ones that are effective when this package is loaded)
-will be used as the caption names for the target language (which is
-specified by the package option).
-
-This package has no public commands.
+See the manual bxorigcapt.pdf for detail.
Revision History
----------------
+ * Version 1.0 〈2022/04/10〉
+ - Now e-TeX and etoolbox are required.
+ - Add option `main`.
+ * Version 0.4a 〈2022/04/08〉
+ - Add option `nowarn`.
+ - Bug fix.
* Version 0.4 〈2022/03/12〉
- Adjustment for new version of Babel.
- Add option `warn`.
diff --git a/macros/latex/contrib/bxorigcapt/bxorigcapt.pdf b/macros/latex/contrib/bxorigcapt/bxorigcapt.pdf
new file mode 100644
index 0000000000..8206ebbd69
--- /dev/null
+++ b/macros/latex/contrib/bxorigcapt/bxorigcapt.pdf
Binary files differ
diff --git a/macros/latex/contrib/bxorigcapt/bxorigcapt.sty b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
index 14faeccb3a..7baf67ec5a 100644
--- a/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
+++ b/macros/latex/contrib/bxorigcapt/bxorigcapt.sty
@@ -10,9 +10,9 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bxorigcapt}[2022/03/12 v0.4]
+\ProvidesPackage{bxorigcapt}[2022/04/10 v1.0]
\def\bxoc@pkgname{bxorigcapt}
-\providecommand*\bxDebug[1]{}
+\providecommand\bxDebug[1]{}
%% code guard
\edef\bxoc@restore@codes{%
@@ -42,10 +42,17 @@
\let\bxoc@warn@or@info\PackageInfo
%% handle options
-% 'warn'
+% 'warn'/'nowarn'
\DeclareOption{warn}{%
\let\bxoc@warn@or@info\PackageWarning
}
+\DeclareOption{nowarn}{%
+ \let\bxoc@warn@or@info\PackageInfo
+}
+% 'main'
+\DeclareOption{main}{%
+ \let\bxoc@target@lang\relax
+}
% language options
\DeclareOption*{%
\edef\bxoc@target@lang{\CurrentOption}%
@@ -57,45 +64,15 @@
%--------------------------------------- environment
-%% switch 'bxoc@etoolbox@available'
-\newif\ifbxoc@etoolbox@available
-%% switch 'bxoc@polyglossia@available'
-\newif\ifbxoc@polyglossia@available
-\begingroup
- \def\bxoc@next#1{%
- \edef\bxoc@tmpa{\string#1}\edef\bxoc@tmpb{\meaning#1}%
- \ifx\bxoc@tmpa\bxoc@tmpb \@tempswatrue \fi
- }
- %% set 'bxoc@etoolbox@available'
- \@tempswafalse
- \bxoc@next\eTeXversion
- \if@tempswa
- \IfFileExists{etoolbox.sty}{}{\@tempswafalse}
- \fi
- \if@tempswa
- \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
+%% packages
+\RequirePackage{etoolbox}[2011/01/03]% v2.1
+\ifx\numdef\@undefined % etoolbox is aborted
+ \PackageWarningNoLine
+ {Package loading is aborted}
+\expandafter\endinput\fi\relax
%--------------------------------------- general
-%% packages
-\ifbxoc@etoolbox@available
- \RequirePackage{etoolbox}\relax
-\fi
-
%% \bxoc@name@list
% The list of caption names.
\@onlypreamble\bxoc@name@list
@@ -116,7 +93,8 @@
%%<+> \bxorigcaptDeprecateCommand{<csname>,...}
\@onlypreamble\bxorigcaptDeprecateCommand
\newcommand*\bxorigcaptDeprecateCommand[1]{%
- \edef\bxoc@deprecated@ldf@list{\bxoc@deprecated@ldf@list,#1}}
+ \eappto\bxoc@deprecated@ldf@list{,#1}%
+}
%--------------------------------------- hook
@@ -133,7 +111,8 @@
{Both Babel and Polyglossia are loaded!\MessageBreak
Such usage is not supported}%
{All the function of \bxoc@pkgname\space
- is invalidated.\MessageBreak\@ehc}%
+ is invalidated.\MessageBreak
+ \@ehc}%
% annihilate
\let\bxoc@babel@hook\relax
\let\bxoc@check@conflict\relax
@@ -157,36 +136,21 @@
\@onlypreamble\bxoc@babel@hook
\let\bxoc@babel@hook\@empty
\bxoc@if@babel@or@polyglossia@loaded{%
- \ifbxoc@etoolbox@available
- \AtEndPreamble{%
+ \AtEndPreamble{%
+ \bxoc@check@conflict
+ \bxoc@babel@hook
+ }%
+}{%else
+ \AtEndPreamble{%
+ \bxoc@if@babel@or@polyglossia@loaded{%
\bxoc@check@conflict
\bxoc@babel@hook
+ }{%else
+ \bxoc@warn@or@info\bxoc@pkgname
+ {Neither Polyglossia nor Babel is\MessageBreak
+ loaded, reported}%
}%
- \else
- \AtEndOfPackage{\bxoc@babel@hook}%
- \fi
-}{%else
- \ifbxoc@etoolbox@available
- \AtEndPreamble{%
- \bxoc@if@babel@or@polyglossia@loaded{%
- \bxoc@check@conflict
- \bxoc@babel@hook
- }{%else
- \bxoc@warn@or@info\bxoc@pkgname
- {Neither Polyglossia nor Babel is\MessageBreak
- loaded, reported}%
- }%
- }%
- \else
- \AtBeginDocument{%
- \@ifpackageloaded{babel}{%
- \bxoc@babel@hook
- }{%else
- \bxoc@warn@or@info\bxoc@pkgname
- {Babel is not loaded,\MessageBreak reported}%
- }%
- }%
- \fi
+ }%
}
%--------------------------------------- deprecated ldf stuffs
@@ -196,11 +160,11 @@
\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
+ \ifx\bxoc@tmpa\@empty\else
+ \ifcsdef{\bxoc@tmpa}{%
\bxDebug{Smashed \@backslashchar\bxoc@tmpa}%
- \global\expandafter\let\csname\bxoc@tmpa\endcsname\@empty
- \fi
+ \global\cslet{\bxoc@tmpa}\@empty
+ }{}%
\fi
}%
\endgroup
@@ -209,7 +173,7 @@
\@onlypreamble\bxoc@clear@deprecated@ldf@a
\def\bxoc@clear@deprecated@ldf@a{%
\global\let\bxoc@clear@deprecated@ldf@a\relax
- \gdef\bxorigcaptDeprecateCommand##1{%
+ \gdef\bxorigcaptDeprecateCommand##1{% modified
\edef\bxoc@deprecated@ldf@list{##1}%
\bxoc@clear@deprecated@ldf}}
\g@addto@macro\bxoc@babel@hook{\bxoc@clear@deprecated@ldf}
@@ -229,13 +193,13 @@
\@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}%
+ \let\expandonce{\csname bxoc@@\bxoc@tmpa name\endcsname}%
+ \expandonce{\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}%
+ \let\expandonce{\csname\bxoc@tmpa name\endcsname}%
+ \expandonce{\csname bxoc@@\bxoc@tmpa name\endcsname}}%
}\bxoc@next
}
\endgroup
@@ -258,31 +222,27 @@
\PackageError\bxoc@pkgname
{The main language is not set}%
{\@ehc}%
- \def\bxoc@target@lang{?bxoc}
- \@namedef{date\bxoc@target@lang}{}%
+ \def\bxoc@target@lang{?bxoc}%
+ \cslet{date\bxoc@target@lang}\@empty
\fi
\fi
\bxDebug{target language = \bxoc@target@lang}%
- \expandafter\ifx\csname date\bxoc@target@lang\endcsname\relax
+ \ifcsundef{date\bxoc@target@lang}{%
\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}%
- \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
+ {\@ehc}%
+ \cslet{date\bxoc@target@lang}\@empty
+ }{}%
+ \ifcsundef{captions\bxoc@target@lang}{%
+ \cslet{captions\bxoc@target@lang}\@empty
+ }{}%
+ \csappto{date\bxoc@target@lang}{\bxoc@restore@date}%
+ \csappto{captions\bxoc@target@lang}{\bxoc@restore@captions}%
+ % 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}%
+ }%
}
%% Saves the current captions
diff --git a/macros/latex/contrib/bxorigcapt/bxorigcapt.tex b/macros/latex/contrib/bxorigcapt/bxorigcapt.tex
new file mode 100644
index 0000000000..83dffe4c8a
--- /dev/null
+++ b/macros/latex/contrib/bxorigcapt/bxorigcapt.tex
@@ -0,0 +1,112 @@
+\documentclass[a4paper]{article}
+\usepackage[scale=0.75]{geometry}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern,textcomp}
+\usepackage{color}
+\definecolor{myblue}{rgb}{0,0,0.75}
+\definecolor{mygreen}{rgb}{0,0.45,0}
+\usepackage[colorlinks]{hyperref}
+\hypersetup{linkcolor=myblue,urlcolor=mygreen,
+ pdftitle={The bxorigcapt package},
+ pdfauthor={Takayuki YATO}}
+\usepackage{bxtexlogo}
+\bxtexlogoimport{*}
+\usepackage{shortvrb}
+\MakeShortVerb{\|}
+\newcommand{\PkgVersion}{1.0}
+\newcommand{\PkgDate}{2022/04/10}
+\newcommand{\Pkg}[1]{\textsf{#1}}
+\newcommand{\Meta}[1]{$\langle$#1$\rangle$}
+\newcommand{\Note}{\par\noindent\emph{Note.}}
+\newcommand{\Means}{:\quad}
+%-----------------------------------------------------------
+\begin{document}
+\title{The \Pkg{bxorigcapt} package}
+\author{Takayuki YATO\quad (aka.~``ZR'')}
+\date{v\PkgVersion\quad[\PkgDate]}
+\maketitle
+%\tableofcontents
+\begin{abstract}
+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.
+\end{abstract}
+
+%===========================================================
+\section{Introduction}
+\label{sec: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:
+\begin{quote}
+|\newcommand\contentsname{Tabelo de Enhavo}|
+\end{quote}
+
+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.
+\begin{quote}
+|\usepackage[ngerman,esperanto]{babel}|
+\end{quote}
+
+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 \emph{for that language}
+should be the ones provided by the class.
+The \Pkg{bxorigcapt} package realizes this natural 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.
+
+
+%===========================================================
+\section{Package Loading}
+\label{sec:Package-Loading}
+
+\begin{quote}
+|\usepackage[|\Meta{option}|,...]{bxorigcapt}|
+\end{quote}
+
+Available options are:
+\begin{itemize}
+\item |main| (default)\Means
+ Sets the main language of Babel to the default target language.
+\item \emph{a Babel language name}\Means
+ Specifies the target language.
+\item |warn|\Means
+ Issues a warning (instead of an info)
+ if Babel is never loaded in the preamble.
+\item |nowarn| (default)\Means
+ Negation of |warn|.
+\end{itemize}
+
+
+%===========================================================
+\section{Usage}
+\label{sec:Usage}
+
+Once this package is loaded,
+the caption names provided by the document class
+(actually the ones that are effective when this package is loaded)
+will be used as the caption names for the target language
+(which is specified by the package option).
+
+This package has no public commands.
+
+
+%===========================================================
+\end{document}