From 1d4a2d0e142220d907b1ce6d432b049dc433560e Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 20 Feb 2022 21:12:00 +0000
Subject: caption (20feb22)

git-svn-id: svn://tug.org/texlive/trunk@62097 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/source/latex/caption/bicaption.dtx  | 1206 ++++++++++++++------
 1 file changed, 828 insertions(+), 378 deletions(-)

(limited to 'Master/texmf-dist/source/latex/caption/bicaption.dtx')

diff --git a/Master/texmf-dist/source/latex/caption/bicaption.dtx b/Master/texmf-dist/source/latex/caption/bicaption.dtx
index 5bba05cb2ff..fba7724ff39 100644
--- a/Master/texmf-dist/source/latex/caption/bicaption.dtx
+++ b/Master/texmf-dist/source/latex/caption/bicaption.dtx
@@ -2,7 +2,7 @@
 % 
 % This is file `bicaption.dtx'.
 % 
-% Copyright (C) 2010-2020 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
+% Copyright (C) 2010-2021 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
 % 
 % --------------------------------------------------------------------------
 % 
@@ -27,17 +27,16 @@
 %   caption.sty, caption-light.sty, caption2.sty, caption3.sty,
 %   caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
 %   caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
-%   caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty,
-% and the user manuals
-%   caption-deu.tex, caption-eng.tex, caption-rus.tex.
+%   caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty.
 % 
 % \fi
-% \CheckSum{457}
+%
+% \CheckSum{626}
 %
 % \iffalse
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesFile{bicaption.drv}[2020/10/25 v1.3 Adds a bilingual caption feature to the caption package]
+\ProvidesFile{bicaption.drv}[2022/01/07 v1.5 Adds a bilingual caption feature to the caption package]
 \hbadness=9999 \newcount\hbadness \hfuzz=74pt % Make TeX shut up.
 %\errorcontextlines=3
 %
@@ -54,7 +53,8 @@
 %
 \usepackage[T1]{fontenc}
 \usepackage[german,english]{babel}
-\usepackage{selinput}\SelectInputMappings{adieresis={ä},germandbls={ß}}
+%\usepackage{selinput}\SelectInputMappings{adieresis={ä},germandbls={ß}}
+\usepackage[utf8]{inputenc}
 %
 \usepackage[bottom]{footmisc}
 %
@@ -85,8 +85,11 @@
 \newenvironment{background}{\par\bigskip\csname background*\endcsname}{\csname endbackground*\endcsname}
 \newenvironment{background*}{\small\MARGINSYM{\Mountain}\ignorespaces}{\par}
 %
+\makeatletter
 \newcommand*\MARGINSYM[1]{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{#1}}}}
-\newcommand*\NEW[2]{\MARGINSYM{\vskip2pt\footnotesize#1\\#2}}
+\newcommand*\NEW[1]{\@ifstar{\@NEW{#1}{\vskip2pt}}{\@NEW{#1}{}}}
+\newcommand*\@NEW[3]{\MARGINSYM{#2\footnotesize#1\\#3}}
+\makeatother
 %
 \newenvironment{Options}[1]%
   {\list{}{\renewcommand\makelabel[1]{\texttt{##1}\hfil}%
@@ -135,7 +138,6 @@
 % \section{Loading the package}
 % \label{sec:loading}
 %
-% \DescribeMacro{\usepackage}
 % This package will be loaded by
 % \begin{quote}
 %   |\usepackage|\oarg{options}|{bicaption}|\quad.
@@ -160,7 +162,7 @@
 % \section{Setting options}
 % \label{sec:options}
 %
-% \DescribeMacro{\captionsetup}
+% \DescribeMacro\captionsetup
 % The command
 % \begin{quote}
 %   |\captionsetup[bi]|\marg{options}
@@ -266,14 +268,14 @@
 %   will swap the primary and secondary language,
 %   making the first language the second one and vice versa. (The default is |false|.)
 %
-%   \NEWfeature{v1.3}
 %   \item[bi-separator=]
 %   \begin{quote}|\captionsetup{bi-separator=|\meta{name}|}|\end{quote}
+%   \NEWfeature{v1.3}
 %   will select a separator between first and second bilingual caption.
 %   You could choose one of the following: `none' (which is the default one
 %   and could also be addressed as `default'), `smallskip', `medskip',
 %   `largeskip', or a self-defined one using
-%   \DescribeMacro{\DeclareBiCaptionSeparator}
+%   \DescribeMacro{\DeclareBiCaption-\\Separator}
 %   \begin{quote}|\DeclareBiCaptionSeparator|\marg{name}\marg{code}\end{quote}
 %   Examples:
 %   \begin{quote}
@@ -321,9 +323,430 @@
 % \cs{captionbox}.)
 % \endgroup
 %
-% \bigskip
+% \pagebreak[3]
+% \section{Customising lists}
+% \label{sec:lists}
+%
+% \DescribeMacro{list=}
+% As default both caption texts will be insert into the List of Figures resp. List of Tables.
+% To suppress the second entry just pass the option |list=off| to the \package{bicaption}
+% package, e.g.:
+% \begin{quote}
+%   |\usepackage[lang=english,|\ldots|,list=off]{bicaption}|
+% \end{quote}
+%
+% \pagebreak[3]
+% \DescribeMacro{listtype+=}
+% Another option is separating the lists. For that purpose the option
+% \begin{quote}
+%   |listtype+=|\meta{list type extension}
+% \end{quote}
+% can be used to tell the \package{bicaption} package to use a different list
+% for the second caption text.
+% The given value will be appended to the current environment type;
+% for example with |listtype+=X| the list entries will be put into the list
+% responsible for the types
+% |figureX| ($=$ |figure| $+$ |X|), |tableX| ($=$ |table| $+$ |X|) etc.
+%
+% Such a \meta{list type} can be defined using |\Declare|\-|Floating|\-|Environment|
+% offered by the \package{newfloat} package, but some document classes
+% or other packages offer macros for defining new floating environment types
+% (and their corresponding lists) as well.
+%
+% A sample document:
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   ||\\
+%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
+%   |\usepackage[english,ngerman]{babel}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english", and list type "figureEng" resp. "tableEng"|\\
+%   |\usepackage[lang=english,listtype+=Eng]{bicaption}|\\
+%   ||\\
+%   |\usepackage{newfloat}|\\
+%   |% Define type "figureEng" and \listoffigureEng|\\
+%   |\DeclareFloatingEnvironment[fileext=lof2]{figureEng}|\\
+%   |                   [Figure][List of Figures]|\\
+%   |% Define type "tableEng" and \listoftableEng|\\
+%   |\DeclareFloatingEnvironment[fileext=lot2]{tableEng}|\\
+%   |                   [Table][List of Tables]|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\listoffigures    % typeset "Abbildungsverzeichnis"|\\
+%   |\listoffigureEng  % typeset "List of Figures"|\\
+%   ||\\
+%   |\begin{figure}|\\
+%   |  \centering|\\
+%   |  A placeholder for an image or whatever|\\
+%   |  \bicaption{Deutscher Text}{English text}|\\
+%   |\end{figure}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \pagebreak[3]
+% A different approach is using one list for both languages, but with different formatting.
+% Since the \package{caption} package does not offer options and commands for
+% customising the format of the lists, one need an additional package for this purpose,
+% for example the \package{titletoc} package:
+%
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   ||\\
+%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
+%   |\usepackage[english,ngerman]{babel}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english", and list type "figure2" resp. "table2"|\\
+%   |\usepackage[lang=english,listtype+=2]{bicaption}|\\
+%   ||\\
+%   |% We load the titletoc package for customizing lists|\\
+%   |% Note: Loading titletoc should be done prior|\\
+%   |% defining additional floating environments with|\\
+%   |% \DeclareFloatingEnvironment|\\
+%   |\usepackage{titletoc}|\\
+%   ||\\
+%   |\usepackage{newfloat}|\\
+%   |% Define the new floating environment type "figure2"|\\
+%   |% Use the same file extension as for "figure" (.lof) here|\\
+%   |\DeclareFloatingEnvironment[fileext=lof]{figure2}|\\
+%   |% Define the new floating environment type "table2"|\\
+%   |% Use the same file extension as for "table" (.lot) here|\\
+%   |\DeclareFloatingEnvironment[fileext=lot]{table2}|\\
+%   ||\\
+%   |% We use the titletoc package for customizing "figure2"|\\
+%   |% which is appropriate for the second language captions|\\
+%  \iffalse
+%   |\contentsuse{figure2}{lof}|\\
+%  \fi
+%   |\titlecontents{figure2}[3.8em]|\\
+%   |  {} % no above code|\\
+%   |  {} % empty numbered entry format|\\
+%   |  {} % empty numberless entry format|\\
+%   |  {} % empty filler page format|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\renewcommand\listfigurename|\\
+%   |  {Abbildungsverzeichnis / List of Figures}|\\
+%   |\listoffigures|\\
+%   ||\\
+%   |\begin{figure}|\\
+%   |  \centering|\\
+%   |  A placeholder for an image or whatever|\\
+%   |  \bicaption{Deutscher Text}{English text}|\\
+%   |\end{figure}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \section{Language Selection}
+% \label{sec:babel}
+%
+% For language selection \thispackage\ uses two macros internally:
+%
+% \medskip
+%
+% \DescribeMacro\captionmainlanguage
+% |\caption|\-|main|\-|lan|\-|guage| contains the main language, for example
+% `french' or `german'.
+% If not set manually, \thispackage\ will try to obtain this setting from
+% the \package{babel} or \package{polyglossia} package after the preamble of
+% the document, i.e.~at |\begin{doc|\-|u|\-|ment}|.
+%
+% So if you are using either \package{babel} or \package{polyglossia}, and want to inherit
+% the main language setting from it, then simply forget about the
+% |\caption|\-|main|\-|lan|\-|guage| stuff and skip the rest of the section.
+%
+% \pagebreak[3]
+% Otherwise one can define |\caption|\-|main|\-|lan|\-|guage| manually, e.g.:
+% \begin{quote}
+%   |\newcommand\captionmainlanguage{french}|\\
+%   |\usepackage[lang=english]{bicaption}|
+% \end{quote}
+%
+% \pagebreak[3]
+% Note: Prior to \version{1.5} |\caption|\-|main|\-|language| needed to be defined
+% \emph{before} loading \thispackage. Since \version{1.5} is could be defined either
+% before or after loading \thispackage.
+%
+% \medskip
+%
+% \DescribeMacro\selectcaptionlanguage
+% \NEWfeature*{v1.1}
+% |\select|\-|caption|\-|lan|\-|guage| will be used internally  to select the language:
+% \begin{quote}
+%   |\selectcaptionlanguage|\marg{font-or-list-entry}\marg{language}
+% \end{quote}
+% For setting the language of the caption \meta{font-or-list-entry} will be |\@first|\-|of|\-|two|,
+% for setting the language of the list entry \meta{font-or-list-entry} will be
+% |\@second|\-|of|\-|two|.~\footnote{\cs{@firstoftwo} and \cs{@secondoftwo} are defined
+% in the \LaTeX\ kernel and simply pick either the 1st or 2nd argument.}
+% It defaults to |\select@lan|\-|guage| (caption) resp.~|\select|\-|lan|\-|guage| (list entry)
+% offered by the \package{babel} and \package{polyglossia} package:
+% \begin{quote}
+%   |\providecommand*\selectcaptionlanguage[2]{%|\\
+%   |  #1{\select@language}{\selectlanguage}{#2}}|
+% \end{quote}
+% If you need to alter this, just either define |\select|\-|caption|\-|lan|\-|guage| prior
+% loading \thispackage, or redefine it afterwards.
+%
+% \pagebreak[3]
+% Example document using \package{babel}:
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   ||\\
+%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
+%   |\usepackage[english,ngerman]{babel}|\\
+%   ||\\
+%   |% Add custom translations to babel|\\
+%   |\addto\captionsgerman{%|\\
+%   |% \renewcommand\whatevername{Wasauchimmer}%|\\
+%   |% |\ldots\\
+%   |}|\\
+%   |\addto\captionsenglish{%|\\
+%   |% \renewcommand\whatevername{Whatever}%|\\
+%   |% |\ldots\\
+%   |}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english"|\\
+%   |\usepackage[lang=english]{bicaption}|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\begin{figure}|\\
+%   |  \centering|\\
+%   |  A placeholder for an image or whatever|\\
+%   |  \bicaption{Deutscher Text}{English text}|\\
+%   |\end{figure}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \pagebreak[3]
+% The same example document but using a custom implementation of
+% |\caption|\-|main|\-|language| and |\select|\-|caption|\-|language|
+% instead of \package{babel}:
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english"|\\
+%   |\usepackage[lang=english]{bicaption}|\\
+%   ||\\
+%   |% Set "german" as main bi-caption language|\\
+%   |\newcommand\captionmainlanguage{german}|\\
+%   ||\\
+%   |% Declare an own language switching mechanism|\\
+%   |% for bi-captions (instead of using babel)|\\
+%   |\renewcommand\selectcaptionlanguage[2]{%|\\
+%   |  \csname captions#2\endcsname}|\\
+%   |\newcommand\captionsgerman{%|\\
+%   |  \renewcommand\figurename{Abbildung}%|\\
+%   |  \renewcommand\tablename{Tabelle}%|\\
+%   |% \renewcommand\whatevername{Wasauchimmer}%|\\
+%   |% |\ldots\\
+%   |}|\\
+%   |\newcommand\captionsenglish{%|\\
+%   |  \renewcommand\figurename{Figure}%|\\
+%   |  \renewcommand\tablename{Table}%|\\
+%   |% \renewcommand\whatevername{Whatever}%|\\
+%   |% |\ldots\\
+%   |}|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\begin{figure}|\\
+%   |  \centering|\\
+%   |  A placeholder for an image or whatever|\\
+%   |  \bicaption{Deutscher Text}{English text}|\\
+%   |\end{figure}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \pagebreak[3]
+% \NEWfeature{v1.5}
+% Since \version{1.5} a warning is issued if the main language could neither be
+% detected automatically nor was it set explicitly by the user.
+% If you really don't want to set languages for bi-captions but are annoyed by
+% the warning you could trick the \package{bicaption} by defining a custom
+% dummy language-selection mechanism, e.g.:
+% \begin{quote}
+%   |\newcommand\captionmainlanguage{dummy}|\\
+%   |\renewcommand\selectcaptionlanguage[2]{}|\\
+% \end{quote}
+%
+% \medskip
+%
+% \DescribeMacro{\DeclareCaption-\\LangOption}
+% \NEWfeature*{v1.2}
+% For internal implementation reasons the selection of language will be done delayed,
+% i.e.~not done immediately at |lang=|\meta{language}. So if you do
+% \begin{quote}
+%   |\captionsetup[bi-second]{lang=ngerman,labelsep=quad}|
+% \end{quote}
+% the language |ngerman| will only be stored internally, and the label separator will
+% be set to |quad| afterwards. Some time later, right before the caption is actually
+% typeset, the language will be set to |ngerman|.
+%
+% Usually this is no problem, but think of options which will be overwritten by the
+% language selection, or options which act on the language currently set, for example
+% \begin{quote}
+%   |\captionsetup[bi-second]{lang=ngerman,name=Bild}|\quad.
+% \end{quote}
+% |lang=ngerman| changes the environment name to ``Abbildung'', and |name=Bild|
+% changes the environment name to ``Bild''. One would expect that the name is
+% finally ``Bild'', but because of the delayed nature of |lang=ngerman| it will
+% be ``Abbildung'' instead, at least if we don't take action about this.
+%
+% For that reason the command
+% \begin{quote}
+%   |\DeclareCaptionLangOption|\marg{caption option name}
+% \end{quote}
+% is offered. Options handled this way will be applied twice if used after the |lang=|
+% option, when the option is actually used, and right after the language is selected.
+%
+% \begin{quote}
+%   |\DeclareCaptionLangOption{name}|
+% \end{quote}
+% will be done by \thispackage\ automatically, since the environment name will usually
+% be overwritten by a language selection. So actually
+% \begin{quote}
+%   |\captionsetup[bi-second]{lang=ngerman,name=Bild}|
+% \end{quote}
+% will give the expected result, i.e. the environment name is typeset as ``Bild''.
+%
+% \section{Required packages}
+% \label{sec:caption}
+%
+% \NEWfeature{v1.4}
+% Starting with version $1.4$ the \package{bicaption} package requires at least version $3.2$
+% of the \package{caption} package and loads it automatically.
+% (Older versions of the \package{bicaption} package have required exactly the version of the
+% \package{caption} package which was released with it.)
+%
+% \pagebreak[3]
+% If you need to use a specific version of the \package{caption} package you need to load it
+% \emph{before} the \package{bicaption} package, e.g.:
+% \begin{quote}
+%   |\usepackage[| \ldots |]{caption}[=v3.5]|\\
+%   |\usepackage[| \ldots |]{bicaption}|
+% \end{quote}
+%
+% \pagebreak[3]
+% Note that there are limitations if an older version of the \package{caption} package
+% is used:
+% \begin{itemize}
+%   \item Full support of list entries of the \env{lstlisting} environment
+%         (offered by the \package{listings} package) needs at least \package{caption} \version{3.6}.
+% \end{itemize}
+%
+% \section{Supported packages}
+% \label{sec:packages}
 %
-% If the \package{subcaption} package is loaded, these commands are available
+% The \package{bicaption} package was adapted to the following packages which deals with captions, too:
+% \package{listings}~\cite{listings}, \package{longtable}~\cite{longtable}, and \package{subcaption}~\cite{subcaption}.
+%
+% \subsection{Support of the listings package}
+% \label{sec:listings}
+%
+% \NEWfeature{v1.5}
+% If the \package{listings} package~\cite{listings} is loaded, the \package{listings} options \opt{caption1}
+% and \opt{caption2} are available additionally, where option \opt{caption1} specifies the
+% caption of the first language and \opt{caption2} of the second one.
+%
+% Example document, using distinctive lists for each language:
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   |\usepackage{graphicx}|\\
+%   ||\\
+%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
+%   |\usepackage[english,ngerman]{babel}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english", and list type "figureEng" resp. "tableEng"|\\
+%   |\usepackage[lang=english,listtype+=Eng,font=it]{bicaption}|\\
+%   |\captionsetup{slc=off} % do not center short captions|\\
+%   ||\\
+%   |\usepackage{listings}|\\
+%   ||\\
+%   |% Set German names|\\
+%   |\addto\captionsgerman{%|\\
+%   |  \renewcommand\lstlistingname{Quelltext}%|\\
+%   |  \renewcommand\lstlistlistingname{Quelltextverzeichnis}%|\\
+%   |}|\\
+%   |\AtBeginDocument{\captionsgerman}% or load listings before babel|\\
+%   ||\\
+%   |% Set English names|\\
+%   |\addto\captionsenglish{%|\\
+%   |  \renewcommand\lstlistingname{Listing}%|\\
+%   |  \renewcommand\lstlistlistingname{List of Listings}%|\\
+%   |}|\\
+%   ||\\
+%   |\usepackage{newfloat}|\\
+%   |% Define the new floating environment type "lstlistingEng"|\\
+%   |% (just to get an extra list for English listing captions)|\\
+%   |\DeclareFloatingEnvironment[fileext=lol2]{lstlistingEng}|\\
+%   |                           [Listing][List of Listings]|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\lstlistoflistings    % German|\\
+%   |\listoflstlistingEng  % English|\\
+%   ||\\
+%   |\clearpage|\\
+%   ||\\
+%   |\begin{lstlisting}|\\
+%   |      [language=C,|\\
+%   |       caption1=Deutscher Titel,|\\
+%   |       caption2=English Title]|\\
+%   |  int main()|\\
+%   |  {|\\
+%   |      printf( "Hello world!\n" );|\\
+%   |      return 0;|\\
+%   |  }|\\
+%   |\end{lstlisting}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \subsection{Support of the longtable package}
+% \label{sec:longtable}
+%
+% If the \package{longtable} package~\cite{longtable} is loaded, |\bicaption| is available
+% in the \env{longtable} environment as well, e.g.:
+% \begin{quote}
+%   |\documentclass[a4paper]{article}|\\
+%   ||\\
+%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
+%   |\usepackage[english,ngerman]{babel}|\\
+%   ||\\
+%   |% Load the bicaption package with 2nd language set to|\\
+%   |% "english"|\\
+%   |\usepackage[lang=english]{bicaption}|\\
+%   ||\\
+%   |\usepackage{longtable}|\\
+%   ||\\
+%   |\begin{document}|\\
+%   ||\\
+%   |\begin{longtable}{ll}|\\
+%   |  \bicaption{Deutscher Titel}{English Title}\\|\\
+%   |  A & B \\|\\
+%   |  C & D \\|\\
+%   |  |\ldots\\
+%   |\end{longtable}|\\
+%   ||\\
+%   |\end{document}|
+% \end{quote}
+%
+% \subsection{Support of the subcaption package}
+% \label{sec:subcaption}
+%
+% If the \package{subcaption} package~\cite{subcaption} is loaded, these commands are available
 % additionally:
 %
 % \smallskip
@@ -355,8 +778,7 @@
 % \endgroup
 %
 % \pagebreak[3]
-% \section{A sample document}
-% \label{sec:example}
+% \subsubsection{A sample document}
 %
 % \begin{quote}
 %   |\documentclass[english,ngerman]{article}|\\
@@ -424,7 +846,7 @@
 %   |    {Short English heading}|\\
 %   |\end{figure}|\\
 %   ||\\
-%   |\captionsetup{bi-slc=0}|\\
+%   |\captionsetup{bi-slc=off}|\\
 %   ||\\
 %   |\begin{figure}[!htb]|\\
 %   |  \centering|\\
@@ -441,7 +863,7 @@
 %   |    {Short English heading}|\\
 %   |\end{figure}|\\
 %   ||\\
-%   |\captionsetup{slc=0}|\\
+%   |\captionsetup{slc=off}|\\
 %   ||\\
 %   |\begin{figure}[!htb]|\\
 %   |  \centering|\\
@@ -471,7 +893,8 @@
 % \bigskip
 % \fi
 %
-% \begin{figure}[!htb]
+% \begin{minipage}{\linewidth}
+%   \setcaptiontype{figure}
 %   \centering
 %   \bisubcaptionbox
 %     {Teilabbildung A\label{fig:test:A}}
@@ -482,12 +905,14 @@
 %     {Subfigure long title B}[0.4\textwidth]{IMAGE}%
 %   \bicaption{Deutscher Titel}{English Title}
 %   \label{fig:test}
-% \end{figure}
+% \end{minipage}
 %
 % \iffalse
+% \bigskip
 % \captionsetup{bi-lang=2nd}
 %
-% \begin{figure}[!htb]
+% \begin{minipage}{\linewidth}
+%   \setcaptiontype{figure}
 %   \centering
 %   \bisubcaptionbox
 %     {Teilabbildung A\label{fig:test2:A}}
@@ -498,276 +923,98 @@
 %     {Subfigure long title B}[0.4\textwidth]{IMAGE}%
 %   \bicaption{Deutscher Titel}{English Title}
 %   \label{fig:test2}
-% \end{figure}
+% \end{minipage}
 % \fi
 %
-% \captionsetup{bi-lang=both}
-%
-% \begin{figure}[!htb]
-%   \centering
-%   \bisubcaptionbox[A]
-%     {Und eine gaaaanz lange Caption: Teilabbildung A}
-%     {Subfigure A}[0.4\textwidth]{IMAGE}%
-%   \qquad
-%   \bisubcaptionbox[B]
-%     {Teilabbildung B}
-%     {Subfigure B}[0.4\textwidth]{IMAGE}%
-%   \bicaption[Abbildungsverzeichnistitel]
-%     {Und eine noch viel viel viel
-%      längere deutsche Beschriftung: Deutscher Titel}
-%     {Short English heading}
-% \end{figure}
-%
-% \captionsetup{bi-slc=0}
-%
-% \begin{figure}[!htb]
-%   \centering
-%   \bisubcaptionbox[A]
-%     {Und eine gaaaanz lange Caption: Teilabbildung A}
-%     {Subfigure A}[0.4\textwidth]{IMAGE}%
-%   \qquad
-%   \bisubcaptionbox[B]
-%     {Teilabbildung B}
-%     {Subfigure B}[0.4\textwidth]{IMAGE}%
-%   \bicaption[Abbildungsverzeichnistitel]
-%     {Und eine noch viel viel viel
-%      längere deutsche Beschriftung: Deutscher Titel}
-%     {Short English heading}
-% \end{figure}
-%
-% \captionsetup{slc=0}
-%
-% \begin{figure}[!htb]
-%   \centering
-%   \bisubcaptionbox[A]
-%     {Und eine gaaaanz lange Caption: Teilabbildung A}
-%     {Subfigure A}[0.4\textwidth]{IMAGE}%
-%   \qquad
-%   \bisubcaptionbox[B]
-%     {Teilabbildung B}
-%     {Subfigure B}[0.4\textwidth]{IMAGE}%
-%   \bicaption[Abbildungsverzeichnistitel]
-%     {Und eine noch viel viel viel
-%      längere deutsche Beschriftung: Deutscher Titel}
-%     {Short English heading}
-% \end{figure}
-%
-% \pagebreak[3]
-% \section{Customising lists}
-% \label{sec:lists}
-%
-% \DescribeMacro{list=}
-% As default both caption texts will be insert into the List of Figures resp. List of Tables.
-% To suppress the second entry just pass the option |list=off| to the \package{bicaption}
-% package, e.g.:
-% \begin{quote}
-%   |\usepackage[lang=english,|\ldots|,list=off]{bicaption}|
-% \end{quote}
-%
-% \pagebreak[3]
-% \DescribeMacro{listtype+=}
-% Another option is separating the lists. For that purpose the option
-% \begin{quote}
-%   |listtype+=|\meta{list type extension}
-% \end{quote}
-% can be used to tell the \package{bicaption} package to use a different list
-% for the second caption text.
-% The given value will be appended to the current environment type;
-% for example with |listtype+=X| the list entries will be put into the list
-% responsible for the types
-% |figureX| ($=$ |figure| $+$ |X|), |tableX| ($=$ |table| $+$ |X|) etc.
-%
-% Such a \meta{list type} can be defined using |\Declare|\-|Floating|\-|Environment|
-% offered by the \package{newfloat} package, but some document classes
-% or other packages offer macros for defining new floating environment types
-% (and their corresponding lists) as well.
-%
-% A sample document:
-% \begin{quote}
-%   |\documentclass[a4paper]{article}|\\
-%   ||\\
-%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
-%   |\usepackage[english,ngerman]{babel}|\\
-%   ||\\
-%   |% Load the bicaption package with 2nd language set to|\\
-%   |% "english", and list type "figureEng" resp. "tableEng"|\\
-%   |\usepackage[lang=english,listtype+=Eng]{bicaption}|\\
-%   ||\\
-%   |\usepackage{newfloat}|\\
-%   |% Define the new floating environment type "figureEng"|\\
-%   |\DeclareFloatingEnvironment[fileext=lof2]{figureEng}|\\
-%   |                   [Figure][List of Figures]|\\
-%   |% Define the new floating environment type "tableEng"|\\
-%   |\DeclareFloatingEnvironment[fileext=lot2]{tableEng}|\\
-%   |                   [Table][List of Tables]|\\
-%   ||\\
-%   |\begin{document}|\\
-%   |\listoffigures      % typeset "Abbildungsverzeichnis"|\\
-%   |\listoffigureEnges  % typeset "List of Figures"|\\
-%   ||\\
-%   |\begin{figure}|\\
-%   |  \centering|\\
-%   |  A placeholder for an image or whatever|\\
-%   |  \bicaption{Deutscher Text}{English text}|\\
-%   |\end{figure}|\\
-%   ||\\
-%   |\end{document}|
-% \end{quote}
-%
-% \pagebreak[3]
-% A different approach is using one list for both languages, but with different formatting.
-% Since the \package{caption} package does not offer options and commands for
-% customising the format of the lists, one need an additional package for this purpose,
-% for example the \package{titletoc} package:
-%
-% \begin{quote}
-%   |\documentclass[a4paper]{article}|\\
-%   ||\\
-%   |% Use "ngerman" as 1st language, "english" as 2nd one|\\
-%   |\usepackage[english,ngerman]{babel}|\\
-%   ||\\
-%   |% Load the bicaption package with 2nd language set to|\\
-%   |% "english", and list type "figure2" resp. "table2"|\\
-%   |\usepackage[lang=english,listtype+=2]{bicaption}|\\
-%   ||\\
-%   |% We load the titletoc package for customizing lists|\\
-%   |% Note: Loading titletoc should be done prior|\\
-%   |% defining additional floating environments with|\\
-%   |% \DeclareFloatingEnvironment|\\
-%   |\usepackage{titletoc}|\\
-%   ||\\
-%   |\usepackage{newfloat}|\\
-%   |% Define the new floating environment type "figure2"|\\
-%   |% Use the same file extension as for "figure" (.lof) here|\\
-%   |\DeclareFloatingEnvironment[fileext=lof]{figure2}|\\
-%   |% Define the new floating environment type "table2"|\\
-%   |% Use the same file extension as for "table" (.lot) here|\\
-%   |\DeclareFloatingEnvironment[fileext=lot]{table2}|\\
-%   ||\\
-%   |% We use the titletoc package for customizing "figure2"|\\
-%   |% which is appropriate for the second language captions|\\
-%  \iffalse
-%   |\contentsuse{figure2}{lof}|\\
-%  \fi
-%   |\titlecontents{figure2}[3.8em]|\\
-%   |  {} % no above code|\\
-%   |  {} % empty numbered entry format|\\
-%   |  {} % empty numberless entry format|\\
-%   |  {} % empty filler page format|\\
-%   ||\\
-%   |\begin{document}|\\
-%   |\renewcommand\listfigurename|\\
-%   |  {Abbildungsverzeichnis / List of Figures}|\\
-%   |\listoffigures|\\
-%   ||\\
-%   |\begin{figure}|\\
-%   |  \centering|\\
-%   |  A placeholder for an image or whatever|\\
-%   |  \bicaption{Deutscher Text}{English text}|\\
-%   |\end{figure}|\\
-%   ||\\
-%   |\end{document}|
-% \end{quote}
-%
-% \section{Language Selection}
-% \label{sec:babel}
-%
-% For language selection \thispackage\ uses two macros internally:
-%
-% \medskip
-%
-% \DescribeMacro\captionmainlanguage
-% |\caption|\-|main|\-|lan|\-|guage| contains the main language, e.g. |english| or |german|.
-% If not set prior to loading \thispackage, \thispackage\ will try to obtain this setting from
-% the \package{babel} or \package{polyglossia} package.
-%
-% So if you are using either \package{babel} or \package{polyglossia}, and want to adopt
-% the main language setting from it, then just load \thispackage\ \emph{after} it,
-% and simply forget about the |\caption|\-|main|\-|lan|\-|guage| stuff.
-%
-% Otherwise one can either define |\caption|\-|main|\-|lan|\-|guage| prior to
-% loading \thispackage, e.g.:
-% \begin{quote}
-%   |\newcommand\captionmainlanguage{french}|\\
-%   |\usepackage|\oarg{options}|{bicaption}|
-% \end{quote}
-% Or one can specify the main language via |\caption|\-|setup| after loading \thispackage, e.g.:
-% \begin{quote}
-%   |\usepackage|\oarg{options}|{bicaption}|\\
-%   |\captionsetup[bi-first]{lang=french}|
-% \end{quote}
-% When not using the \package{babel} or \package{polyglossia} package both approaches
-% will have exactly the same effect.
-% But when using the \package{babel} or \package{polyglossia} package, and one want to
-% specify the main caption language manually, the first approach is preferable since
-% defining |\caption|\-|main|\-|lan|\-|guage| will suppress the automatic detection mechanism.
-%
-% \medskip
-%
-% \DescribeMacro\selectcaptionlanguage
-% \NEWfeature{v1.1}
-% |\select|\-|caption|\-|lan|\-|guage| will be used internally  to select the language:
-% \begin{quote}
-%   |\selectcaptionlanguage|\marg{font-or-list-entry}\marg{language}
-% \end{quote}
-% For setting the language of the caption \meta{font-or-list-entry} will be |\@first|\-|of|\-|two|,
-% for setting the language of the list entry \meta{font-or-list-entry} will be
-% |\@second|\-|of|\-|two|.~\footnote{\cs{@firstoftwo} and \cs{@secondoftwo} are defined
-% in the \LaTeX\ kernel and simply pick either the 1st or 2nd argument.}
-% It defaults to |\select@lan|\-|guage| (caption) resp.~|\select|\-|lan|\-|guage| (list entry)
-% offered by the \package{babel} and \package{polyglossia} package:
-% \begin{quote}
-%   |\providecommand*\selectcaptionlanguage[2]{%|\\
-%   |  #1{\select@language}{\selectlanguage}{#2}}|
-% \end{quote}
-% If you need to alter this, just either define |\select|\-|caption|\-|lan|\-|guage| prior
-% loading \thispackage, or redefine it afterwards.
+% \bigskip
+% \captionsetup{bi-lang=both}
 %
-% \medskip
+% \begin{minipage}{\linewidth}
+%   \setcaptiontype{figure}
+%   \centering
+%   \bisubcaptionbox[A]
+%     {Und eine gaaaanz lange Caption: Teilabbildung A}
+%     {Subfigure A}[0.4\textwidth]{IMAGE}%
+%   \qquad
+%   \bisubcaptionbox[B]
+%     {Teilabbildung B}
+%     {Subfigure B}[0.4\textwidth]{IMAGE}%
+%   \bicaption[Abbildungsverzeichnistitel]
+%     {Und eine noch viel viel viel
+%      längere deutsche Beschriftung: Deutscher Titel}
+%     {Short English heading}
+% \end{minipage}
 %
-% \DescribeMacro\DeclareCaptionLangOption
-% \NEWfeature{v1.2}
-% For internal implementation reasons the selection of language will be done delayed,
-% i.e.~not done immediately at |lang=|\meta{language}. So if you do
-% \begin{quote}
-%   |\captionsetup[bi-second]{lang=ngerman,labelsep=quad}|
-% \end{quote}
-% the language |ngerman| will only be stored internally, and the label separator will
-% be set to |quad| afterwards. Some time later, right before the caption is actually
-% typeset, the language will be set to |ngerman|.
+% \bigskip
+% \captionsetup{bi-slc=off}
 %
-% Usually this is no problem, but think of options which will be overwritten by the
-% language selection, or options which act on the language currently set, for example
-% \begin{quote}
-%   |\captionsetup[bi-second]{lang=ngerman,name=Bild}|\quad.
-% \end{quote}
-% |lang=ngerman| changes the environment name to ``Abbildung'', and |name=Bild|
-% changes the environment name to ``Bild''. One would expect that the name is
-% finally ``Bild'', but because of the delayed nature of |lang=ngerman| it will
-% be ``Abbildung'' instead, at least if we don't take action about this.
+% \begin{minipage}{\linewidth}
+%   \setcaptiontype{figure}
+%   \centering
+%   \bisubcaptionbox[A]
+%     {Und eine gaaaanz lange Caption: Teilabbildung A}
+%     {Subfigure A}[0.4\textwidth]{IMAGE}%
+%   \qquad
+%   \bisubcaptionbox[B]
+%     {Teilabbildung B}
+%     {Subfigure B}[0.4\textwidth]{IMAGE}%
+%   \bicaption[Abbildungsverzeichnistitel]
+%     {Und eine noch viel viel viel
+%      längere deutsche Beschriftung: Deutscher Titel}
+%     {Short English heading}
+% \end{minipage}
 %
-% For that reason the command
-% \begin{quote}
-%   |\DeclareCaptionLangOption|\marg{caption option name}
-% \end{quote}
-% is offered. Options handled this way will be applied twice if used after the |lang=|
-% option, when the option is actually used, and right after the language is selected.
+% \bigskip
+% \captionsetup{slc=off}
 %
-% \begin{quote}
-%   |\DeclareCaptionLangOption{name}|
-% \end{quote}
-% will be done by \thispackage\ automatically, since the environment name will usually
-% be overwritten by a language selection. So actually
-% \begin{quote}
-%   |\captionsetup[bi-second]{lang=ngerman,name=Bild}|
-% \end{quote}
-% will give the expected result, i.e. the environment name is typeset as ``Bild''.
+% \begin{minipage}{\linewidth}
+%   \setcaptiontype{figure}
+%   \centering
+%   \bisubcaptionbox[A]
+%     {Und eine gaaaanz lange Caption: Teilabbildung A}
+%     {Subfigure A}[0.4\textwidth]{IMAGE}%
+%   \qquad
+%   \bisubcaptionbox[B]
+%     {Teilabbildung B}
+%     {Subfigure B}[0.4\textwidth]{IMAGE}%
+%   \bicaption[Abbildungsverzeichnistitel]
+%     {Und eine noch viel viel viel
+%      längere deutsche Beschriftung: Deutscher Titel}
+%     {Short English heading}
+% \end{minipage}
 %
 % \iffalse
 % --------------------------------------------------------------------------- %
 % \fi
 %
 % \StopEventually{%^^A
+% \begin{thebibliography}{99}
+%
+%   \bibitem{caption}
+%   Axel Sommerfeldt:\\
+%   \href{http://www.ctan.org/pkg/caption}%
+%        {\emph{Customizing captions of floating environments}},\\
+%   2022/01/07
+%
+%   \bibitem{listings}
+%   Carsten Heinz \& Brooks Moses:\\
+%   \href{http://www.ctan.org/pkg/listings}%
+%        {\emph{The Listings Package}},\\
+%   2007/02/22
+%
+%   \bibitem{longtable}
+%   David Carlisle:\\
+%   \href{http://www.ctan.org/pkg/longtable}%
+%        {\emph{The longtable package}},\\
+%   2004/02/01
+%
+%   \bibitem{subcaption}
+%   Axel Sommerfeldt:\\
+%   \href{http://www.ctan.org/pkg/subcaption}%
+%        {\emph{The subcaption package}},\\
+%   2022/01/07
+%
+% \end{thebibliography}
 % }
 %
 % \iffalse
@@ -796,6 +1043,7 @@
 % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
 % \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
 % \DoNotIndex{\ifx,\ignorespaces,\itshape}
+% \DoNotIndex{\kernel@ifnextchar}
 % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
 % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
 % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
@@ -840,18 +1088,38 @@
 %
 % \clearpage
 % \section{The implementation}
+%
 % \iffalse
 %<*package>
 % \fi
 %
 % \subsection{Identification}
 %
+% We need at least \LaTeX2e\ version 1994/12/01.
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{bicaption}[2020/10/25 v1.3 Bilingual Captions (AR)]
 %    \end{macrocode}
+%
+% Bypass the release declarations in case the \LaTeX\ kernel doesn’t know how to deal with them
+% (as suggested by \url{https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf}).
+%    \begin{macrocode}
+\providecommand\DeclareRelease[3]{}
+\providecommand\DeclareCurrentRelease[2]{}
+%    \end{macrocode}
+%
+% Declare all supported releases.
+%    \begin{macrocode}
+\DeclareCurrentRelease{v1}{2011/07/13}
+%    \end{macrocode}
+%
+% Identify the current version of the package.
 %    \begin{macrocode}
-\RequirePackage{caption}[2020/08/23] % needs v3.5 or newer
+\ProvidesPackage{bicaption}[2021/05/02 v1.5b Bilingual Captions (AR)]
+%    \end{macrocode}
+%
+% Since we base on the \package{caption} package we load it here.
+%    \begin{macrocode}
+\RequirePackage{caption}[2011/11/10] % we need at least v3.2e
 %    \end{macrocode}
 %
 % \bigskip
@@ -892,7 +1160,7 @@
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand*\bicaption@wh{%
-  See the bicaption package documentation for explanation.}
+  See the `bicaption' package documentation for explanation.}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -900,37 +1168,13 @@
 %  |\bicaption@Error|\marg{message}
 %    \begin{macrocode}
 \newcommand*\bicaption@Error[1]{%
-  \PackageError{bicaption}{#1}\bicaption@eh}
-%\let\bicaption@KV@err\bicaption@Error
+  \PackageError{bicaption}{#1}{\caption@@eh{bicaption}}}
 %    \end{macrocode}
 %    \begin{macrocode}
-\newcommand*\bicaption@eh{%
+\providecommand*\caption@@eh[1]{%
   If you do not understand this error, please take a closer look\MessageBreak
-  at the documentation of the `bicaption' package.\MessageBreak\@ehc}
-%    \end{macrocode}
-% \end{macro}
-%
-% \pagebreak[3]
-% \subsection{Compatibility check}
-%
-% \begin{macro}{\bicaption@CheckCompatibility}
-% \changes{v1.0}{2011/09/01}{Compatibility error added}
-% \changes{v1.2a}{2020/08/01}{Error text adapted to \package{caption} package~\version{4.0}}
-%    \begin{macrocode}
-\newcommand*\bicaption@CheckCompatibility{%
-%    \end{macrocode}
-%    \begin{macrocode}
-  \caption@ifcompatibility{%
-    \bicaption@Error
-      {This package does not work with\MessageBreak
-       caption option `compatibility=v1'}%
-    \endinput}{}}
-%    \end{macrocode}
-%    \begin{macrocode}
-\bicaption@CheckCompatibility
-\caption@AtBeginDocument{%
-  \bicaption@CheckCompatibility
-  \let\bicaption@CheckCompatibility\@undefined}
+  at the documentation of the `#1' package, especially the\MessageBreak
+  section about errors.\MessageBreak\@ehc}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -976,6 +1220,12 @@
 \DeclareCaptionOption{bi-separator}[1]{%
   \caption@set{biseparator}{#1}}
 %    \end{macrocode}
+%    \begin{macrocode}
+\providecommand*\caption@set[2]{%
+  \@ifundefined{caption@#1@#2}%
+    {\caption@Error{Undefined #1 `#2'}}%
+    {\expandafter\let\csname caption@#1\expandafter\endcsname\csname caption@#1@#2\endcsname}}
+%    \end{macrocode}
 %
 % \begin{macro}{\DeclareBiCaptionSeparator}
 % \changes{v1.3}{2020/10/25}{This macro added}
@@ -985,6 +1235,10 @@
   \caption@decl{biseparator}{#1}{#2}}
 \@onlypreamble\DeclareBiCaptionSeparator
 %    \end{macrocode}
+%    \begin{macrocode}
+\providecommand*\caption@decl[2]{%
+  \global\long\expandafter\def\csname caption@#1@#2\endcsname}
+%    \end{macrocode}
 % \end{macro}
 %
 % There are four pre-defined separators, called `none',
@@ -998,7 +1252,9 @@
 %
 % The default separator usually maps to `none'.
 %    \begin{macrocode}
-\SetCaptionDefault{biseparator}{none}
+\caption@ifundefined\SetCaptionDefault
+  {\def\caption@biseparator@default{\caption@biseparator@none}}
+  {\SetCaptionDefault{biseparator}{none}}
 %    \end{macrocode}
 %
 % The option |lang=|\meta{language} will setup the language of the caption.
@@ -1013,8 +1269,9 @@
   \caption@ifundefined\bicaption@language
     \bicaption@language@setupkeys
     \relax
-  \def\bicaption@language{#1}%
-  \let\bicaption@language@setoptions\@empty}
+  \edef\bicaption@language{#1}%
+  \let\bicaption@language@setoptions\@empty
+  \global\let\bicaption@language@value\bicaption@language}
 %    \end{macrocode}
 % Map |language=| to |lang=|.
 %    \begin{macrocode}
@@ -1107,29 +1364,51 @@
 %    \end{macrocode}
 %
 % Set the language for the first caption.
+% (Since \version{1.5a} we do this |\At|\-|Begin|\-|Document| so
+% |\caption|\-|main|\-|language| could be defined \emph{after} loading the
+% \package{bicaption} package resp.~\package{babel} or \package{polyglossia}
+% could be loaded \emph{after} the \package{bicaption} package.)
 %    \begin{macrocode}
-\ifcsname captionmainlanguage\endcsname
-  \bicaption@InfoNoLine{%
-    main language is set to \captionmainlanguage}
-\else\ifcsname bbl@main@language\endcsname
-  \bicaption@InfoNoLine{%
-    babel found, main language is \bbl@main@language}
-  \let\captionmainlanguage\bbl@main@language
-\else\ifcsname xpg@main@language\endcsname
-  \bicaption@InfoNoLine{%
-    polyglossia found, main language is \xpg@main@language}
-  \let\captionmainlanguage\xpg@main@language
-\else
-  \bicaption@InfoNoLine{main language is not set}
-\fi\fi\fi
-%    \end{macrocode}
-%    \begin{macrocode}
-\ifcsname captionmainlanguage\endcsname
-  \edef\@tempa{%
-    \noexpand\captionsetup[bi-first]{lang=\captionmainlanguage}}
-  \@tempa
-\fi
+\AtBeginDocument{%
+  \ifcsname captionmainlanguage\endcsname
+    \bicaption@InfoNoLine{%
+      Main language is set to \captionmainlanguage}%
+  \else
+    \bicaption@setmainlanguage
+  \fi
+%    \end{macrocode}
+%    \begin{macrocode}
+  \ifcsname captionmainlanguage\endcsname
+    \captionsetup[bi-first]{lang=\captionmainlanguage}%
+  \else
+    \ifcsname bicaption@language@value\endcsname % option "lang=" was used
+      \expandafter\bicaption@Warning
+    \else
+      \expandafter\bicaption@Info
+    \fi
+      {Main language is not set}%
+  \fi}
+%    \end{macrocode}
+%
+% \begin{macro}{\bicaption@setmainlanguage}
+% \changes{v1.5a}{2011/08/31}{This macro added as encapsulation of setting \cs{captionmainlanguage}}
+% |\bicaption@setmainlanguage| is used to define
+% |\caption|\-|main|\-|language| if not already done.
+%    \begin{macrocode}
+\newcommand*\bicaption@setmainlanguage{%
+  \ifcsname bbl@main@language\endcsname
+    \bicaption@InfoNoLine{%
+      babel found, main language is \bbl@main@language}%
+    \let\captionmainlanguage\bbl@main@language
+  \else\ifcsname xpg@main@language\endcsname
+    \bicaption@InfoNoLine{%
+      polyglossia found, main language is \xpg@main@language}%
+    \let\captionmainlanguage\xpg@main@language
+  \fi\fi}
+\@onlypreamble\bicaption@setmainlanguage
 %    \end{macrocode}
+% \end{macro}
+%
 % We use |\caption@Process|\-|Options| here to add the options to the `|bi-second|' option
 % list instead of executing them immediately.
 %    \begin{macrocode}
@@ -1208,9 +1487,15 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@@make}
+% \changes{v1.4}{2020/12/25}{Fallback code of \cs{caption@@make@} added}
 % We redefine |\caption@@make| (of the \package{caption} package kernel)
 % so |\bi|\-|caption@@make| will be used for bilingual captions instead.
 %    \begin{macrocode}
+\caption@ifundefined\caption@@make@
+  {\let\caption@@make@\caption@@make}
+  {}
+%    \end{macrocode}
+%    \begin{macrocode}
 \renewcommand\caption@@make[2]{%
   \caption@ifundefined\bicaption@text
     {\begingroup
@@ -1221,13 +1506,15 @@
      \global\let\bicaption@text\@undefined}%
 %    \end{macrocode}
 %    \begin{macrocode}
-  \caption@@make@epilogue}
+  \@nameuse{caption@@make@epilogue}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\bicaption@@make}
 % \changes{v1.1}{2015/09/16}{\cs{bicaption@label} replaced by \cs{caption@thelabel}}
 % \changes{v1.3}{2020/10/25}{Usage of \cs{caption@biseparator} added}
+% \changes{v1.4}{2020/12/25}{Definitions of \cs{bicaption@slc} and \cs{caption@setsinglelinecheck} added (fallback)}
+% \changes{v1.4a}{2020/12/26}{Clearance of \cs{caption@thelabel} replaced by \cs{bicaption@clrlabel}}
 % |\bicaption@@make|\marg{text \#2}\marg{label}\marg{text \#1}\par
 % Typeset both captions using the original version of \cs{caption@@make}.
 %    \begin{macrocode}
@@ -1241,8 +1528,8 @@
 %    \begin{macrocode}
   \ifnum\bicaption@lang=0\relax
     \bicaption@ifslc
-      {\caption@slc{#2}{#3}{}{\caption@setsinglelinecheck0}%
-       \caption@slc{#2}{#1}{}{\caption@setsinglelinecheck0}}%
+      {\bicaption@slc{#2}{#3}{}{\caption@setsinglelinecheck0}%
+       \bicaption@slc{#2}{#1}{}{\caption@setsinglelinecheck0}}%
       {}%
   \fi
 %    \end{macrocode}
@@ -1251,7 +1538,6 @@
 %    \begin{macrocode}
   \ifnum\bicaption@lang=2\relax
     \caption@thelabel
-    \global\let\caption@thelabel\relax
     \let\bicaption@tempa\relax
   \else
     \begingroup
@@ -1271,11 +1557,22 @@
       \caption@@make@{#2}{#1}%
     \endgroup
   \fi
-}
+%    \end{macrocode}
+%    \begin{macrocode}
+  \global\bicaption@clrlabel}
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand*\bicaption@separator{\par}
 %    \end{macrocode}
+%    \begin{macrocode}
+\caption@ifundefined\caption@@slc
+  {\newcommand\bicaption@slc{\caption@slc}}
+  {\newcommand\bicaption@slc[2]{\caption@@slc{#1}{#2}{\captionwidth}}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\providecommand*\caption@setsinglelinecheck{%
+  \caption@set@bool\caption@ifslc}
+%    \end{macrocode}
 % \end{macro}
 %
 % \pagebreak[3]
@@ -1317,6 +1614,7 @@
 % \begin{macro}{\@bicaption}
 % \changes{v1.0}{2011/08/31}{Optional parameter \meta{list entry \#2} added}
 % \changes{v1.1}{2015/09/16}{\cs{bicaption@getlabel} replaced by \cs{caption@getlabel}}
+% \changes{v1.4}{2020/12/25}{Usage of \cs{caption@getlabel} replaced by \cs{bicaption@getlabel}}
 % |\@bicaption|\marg{cmd}*\oarg{entry \#1}\marg{text \#1}\oarg{entry \#2}\marg{text \#2}\ldots
 %    \begin{macrocode}
 \newcommand*\@bicaption[1]{%
@@ -1336,7 +1634,7 @@
 %    \end{macrocode}
 %    \begin{macrocode}
 \long\def\@@@@bicaption#1#2[#3]#4{%
-  \caption@getlabel{#2}%
+  \bicaption@getlabel{#2}%
   \bicaption@ifswap
     {\bicaption@setup{#1}{#2}%
      \bicaption@cmd[{#3}]{#4}}%
@@ -1348,63 +1646,109 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\LT@bicaption}
-% \changes{v1.1}{2016/01/31}{Adaption to \package{longtable} package added}
-% Same as |\@bicaption| but for |longtable| (offered by the \package{longtable} package).
-% |\bicaption@LTsetup| will be executed later on, inside |\LT@makecaption| offered by the \package{caption} package.
+% \begin{macro}{\bicaption@getlabel}
+% \changes{v1.0}{2011/09/03}{\cs{label} can have optional arguments now}
+% \changes{v1.4}{2020/12/25}{This macro re-added}
+%   |\bicaption@getlabel|\marg{text}\\
+%   gets the label command out of the given caption text and stores it to |\caption@the|\-|label|.
+%   It uses |\caption@get|\-|label| for this purpose which interface unfortunately has changed over time.
+%   (Changing the interface was a bad idea in the first place but now it is as it is).
 %    \begin{macrocode}
-\newcommand\LT@bicaption{%
-  \noalign\bgroup
-    \@ifstar
-      {\gdef\bicaption@cmd{\LT@c@ption\@gobble}%
-       \LT@@bicaption}%
-      {\gdef\bicaption@cmd{\LT@c@ption\@firstofone}%
-       \caption@dblarg\LT@@@bicaption}}
-\newcommand\LT@@bicaption[1]{%
-  \LT@@@@bicaption{}{#1}[]}
+\@ifundefined{caption@getlabel}{%
 %    \end{macrocode}
 %    \begin{macrocode}
-\long\def\LT@@@bicaption[#1]#2{%
-  \caption@dblarg{\LT@@@@bicaption{#1}{#2}}}
+  \newcommand\bicaption@getlabel[1]{%  caption3 < v1.7
+    \bicaption@@getlabel#1\label{}\@nil}
 %    \end{macrocode}
 %    \begin{macrocode}
-\long\def\LT@@@@bicaption#1#2[#3]#4{%
-  \gdef\bicaption@LTsetup{%
-    \caption@getlabel{#2}%
-    \bicaption@LT@setup}%
-  \gdef\bicaption@LT@setup{%
-    \bicaption@ifswap
-      {\bicaption@setup{#1}{#2}}%
-      {\bicaption@setup{#3}{#4}}}%
-  \bicaption@ifswap
-    {\egroup\bicaption@cmd[{#3}]{#4}}%
-    {\egroup\bicaption@cmd[{#1}]{#2}}}
+  \long\def\bicaption@@getlabel#1\label#2#3\@nil{%
+    \def\@tempa{#2}%
+    \ifx\@tempa\@empty
+      \let\caption@thelabel\relax
+    \else
+      \def\@tempb{*}%
+      \ifx\@tempa\@tempb
+        \def\caption@thelabel{\label*}%
+        \bicaption@@@getlabel#3\@nil
+      \else
+        \def\caption@thelabel{\label}%
+        \bicaption@@@getlabel{#2}#3\@nil
+      \fi
+    \fi}
 %    \end{macrocode}
 %    \begin{macrocode}
-\let\bicaption@LTsetup\relax
-\let\bicaption@LT@setup\relax
+  \long\def\bicaption@@@getlabel#1#2\@nil{%
+    \def\@tempa{#1}%
+    \def\@tempb{[}%
+    \ifx\@tempa\@tempb
+      \bicaption@@@@getlabel#1#2\@nil
+    \else
+      \l@addto@macro\caption@thelabel{{#1}}%
+    \fi}
+%    \end{macrocode}
+%    \begin{macrocode}
+  \long\def\bicaption@@@@getlabel[#1]#2\@nil{%
+    \l@addto@macro\caption@thelabel{[{#1}]}%
+    \bicaption@@@getlabel#2\@nil}
+%    \end{macrocode}
+%    \begin{macrocode}
+}{\@ifundefined{caption@@@@getlabel}{%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \newcommand\bicaption@getlabel[1]{%  caption3 >= v1.7
+    \caption@getlabel#1\label{}\@nil}
+%    \end{macrocode}
+%    \begin{macrocode}
+}{%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \newcommand*\bicaption@getlabel{%    caption3 >= v2.0
+    \caption@getlabel}
+%    \end{macrocode}
+%    \begin{macrocode}
+}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\caption@LT@setup}
-% \changes{v1.1}{2016/01/31}{Adaption to \package{longtable} package added}
-% Execute the stuff defined by \cs{LT@bicaption} to prepare the typesetting
-% of the \package{longtable} bilingual caption.
+% \begin{macro}{\bicaption@clrlabel}
+% \changes{v1.4a}{2020/12/26}{This macro added}
+%   |\bicaption@clrlabel|\\
+%   resets |\caption@the|\-|label| to |\relax|.
+%    \begin{macrocode}
+\@ifundefined{caption@clrlabel}{%
+%    \end{macrocode}
 %    \begin{macrocode}
-\g@addto@macro\caption@LT@setup{%
-  \bicaption@LTsetup
-  \global\let\bicaption@LTsetup\relax}
+  \newcommand*\bicaption@clrlabel{\let\caption@thelabel\relax} %  caption3 < v2.3
+%    \end{macrocode}
+%    \begin{macrocode}
+}{%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \newcommand*\bicaption@clrlabel{\caption@clrlabel}           %  caption3 >= v2.3
+%    \end{macrocode}
+%    \begin{macrocode}
+}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\bicaption@setup}
-% |\bicaption@setup|\marg{list-entry}\marg{text}\par
-% Initiates the bilingual caption typesetting by storing the extra texts into
+% |\bicaption@setup|\marg{list-entry}\marg{text}\\
+% initiates the bilingual caption typesetting by storing the extra texts into
 % |\bi|\-|caption@l|\-|entry| and |\bi|\-|caption@text|.
 %    \begin{macrocode}
 \newcommand\bicaption@setup[2]{%
   \def\bicaption@lentry{#1}%
-  \def\bicaption@text{\ignorespaces#2}}
+  \def\bicaption@text{\ignorespaces #2}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bicaption@clear}
+% |\bicaption@clear|\\
+% clears the stuff stored by |\bicaption@setup|.
+%    \begin{macrocode}
+\newcommand*\bicaption@clear{%
+  \let\bicaption@lentry\@undefined
+  \let\bicaption@text\@undefined}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1437,11 +1781,117 @@
 %
 % \changes{v1.1}{2013/05/02}{Definition of \cs{bicaption@listof} removed}
 %
+% \subsection{Support of the listings package}
+% \changes{v1.5}{2021/01/04}{Support of the \package{listings} package added}
+%
+%    \begin{macrocode}
+\caption@IfPackageLoaded{listings}[2004/02/13 v1.2]{%
+%    \end{macrocode}
+%
+% If the \package{listings} package is loaded, we define the new options `caption1' and `caption2'.
+%    \begin{macrocode}
+  \lst@Key{caption1}\relax{%
+    \lstKV@OptArg[{#1}]{#1}{%
+      \bicaption@ifswap
+        {\bicaption@setup{##1}{##2}}%
+        {\def\lst@@caption{##1}\def\lst@caption{##2}}}%
+    \let\lst@title\@empty}%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \lst@Key{caption2}\relax{%
+    \lstKV@OptArg[{#1}]{#1}{%
+      \bicaption@ifswap
+        {\def\lst@@caption{##1}\def\lst@caption{##2}}%
+        {\bicaption@setup{##1}{##2}}}%
+    \let\lst@title\@empty}%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \lst@AddToHookExe{TextStyle}{%
+    \bicaption@clear}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+}{}
+%    \end{macrocode}
+%
+% \subsection{Support of the longtable package}
+%
+% \begin{macro}{\LT@bicaption}
+% \changes{v1.1}{2016/01/31}{Adaption to \package{longtable} package added}
+% Same as |\@bicaption| but for |longtable| (offered by the \package{longtable} package).
+% |\bi|\-|caption@LT|\-|setup| will be executed later on, inside |\LT@make|\-|caption|
+% offered by the \package{caption} package.
+%    \begin{macrocode}
+\newcommand\LT@bicaption{%
+  \noalign\bgroup
+    \@ifstar
+      {\gdef\bicaption@cmd{\LT@c@ption\@gobble}%
+       \LT@@bicaption}%
+      {\gdef\bicaption@cmd{\LT@c@ption\@firstofone}%
+       \caption@dblarg\LT@@@bicaption}}
+\newcommand\LT@@bicaption[1]{%
+  \LT@@@@bicaption{}{#1}[]}
+%    \end{macrocode}
+%    \begin{macrocode}
+\long\def\LT@@@bicaption[#1]#2{%
+  \caption@dblarg{\LT@@@@bicaption{#1}{#2}}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\long\def\LT@@@@bicaption#1#2[#3]#4{%
+  \gdef\bicaption@LTsetup{%
+    \bicaption@getlabel{#2}%
+    \bicaption@LT@setup}%
+  \gdef\bicaption@LT@setup{%
+    \bicaption@ifswap
+      {\bicaption@setup{#1}{#2}}%
+      {\bicaption@setup{#3}{#4}}}%
+  \bicaption@ifswap
+    {\egroup\bicaption@cmd[{#3}]{#4}}%
+    {\egroup\bicaption@cmd[{#1}]{#2}}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\let\bicaption@LTsetup\relax
+\let\bicaption@LT@setup\relax
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@LT@setup}
+% \changes{v1.1}{2016/01/31}{Adaption to \package{longtable} package added}
+% \changes{v1.4}{2020/12/25}{Fallback code for \package{caption} package \version{3.2} added}
+% Execute the stuff defined by \cs{LT@bicaption} to prepare the typesetting
+% of the \package{longtable} bilingual caption.
+%    \begin{macrocode}
+\caption@ifundefined\caption@LT@setup{%
+  % Fallback code for caption v3.2
+  \captionsetup*[longtable]{bicaption-lt-setup}
+  \DeclareCaptionOptionNoValue{bicaption-lt-setup}{%
+    \bicaption@LTsetup
+    \global\let\bicaption@LTsetup\relax}
+}{%
+  \g@addto@macro\caption@LT@setup{%
+    \bicaption@LTsetup
+    \global\let\bicaption@LTsetup\relax}
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{thebibliography}{9}
 %   \bibitem{TLC2}
 %   Frank Mittelbach and Michel Goossens:\\
-%   \newblock {\em The {\LaTeX} Companion (2nd.~Ed.)},
+%   \newblock {\em The {\LaTeX} Companion (2nd.~Ed.)},\\
 %   \newblock Addison-Wesley, 2004.
+%
+%   \bibitem{listings}
+%   Carsten Heinz \& Brooks Moses:\\
+%   \href{http://www.ctan.org/pkg/listings}%
+%        {\emph{The Listings Package}},\\
+%   2007/02/22
+%
+%   \bibitem{longtable}
+%   David Carlisle:\\
+%   \href{http://www.ctan.org/pkg/longtable}%
+%        {\emph{The longtable package}},\\
+%   2004/02/01
 % \end{thebibliography}
 %
 % \iffalse
-- 
cgit v1.2.3

