%%
%% This is file `bicaption.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bicaption.dtx  (with options: `package')
%% 
%% Copyright (C) 1994-2015 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%% 
%% http://sourceforge.net/projects/latex-caption/
%% 
%% --------------------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Axel Sommerfeldt.
%% 
%% This work consists of the files
%%   CHANGELOG, README, SUMMARY, caption.ins,
%%   caption.dtx, caption2.dtx, caption3.dtx,
%%   bicaption.dtx, ltcaption.dtx, subcaption.dtx,
%%   newfloat.dtx, and totalcount.dtx
%% the derived files
%%   caption.sty, caption2.sty, caption3.sty,
%%   bicaption.sty, ltcaption.sty, subcaption.sty,
%%   newfloat.sty, and totalcount.sty
%% and the user manuals
%%   caption-deu.tex, caption-eng.tex, and caption-rus.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\def\caption@tempa$Id: #1 #2 #3-#4-#5 #6${%
  \def\caption@tempa{#3/#4/#5 }\def\caption@tempb{#2 }}
\caption@tempa $Id: bicaption.sty 111 2015-09-17 09:48:20Z sommerfeldt $
\ProvidesPackage{bicaption}[\caption@tempa v1.1-\caption@tempb Bilingual Captions (AR)]
\RequirePackage{caption}[2015/09/01] % needs v3.3 or newer
\caption@AtBeginDocument{\caption@ifcompatibility{%
  \caption@Error{%
    The `bicaption' package does not work correctly\MessageBreak
    in compatibility mode}}{}}
\newcommand*\bicaption@Info[1]{%
  \PackageInfo{bicaption}{#1}}
\newcommand*\bicaption@InfoNoLine[1]{%
  \PackageInfo{bicaption}{#1\@gobble}}
\newcommand*\bicaption@Warning[1]{%
  \bicaption@WarningNoLine{#1\on@line}}
\newcommand*\bicaption@WarningNoLine[1]{%
  \PackageWarning{bicaption}{#1.^^J\bicaption@wh\@gobbletwo}}
\newcommand*\bicaption@wh{%
  See the bicaption package documentation for explanation.}
\newcommand*\bicaption@Error[1]{%
  \PackageError{bicaption}{#1}\bicaption@eh}
\newcommand*\bicaption@eh{%
  If you do not understand this error, please take a closer look\MessageBreak
  at the documentation of the `bicaption' package.\MessageBreak\@ehc}
\newcount\bicaption@lang
\DeclareCaptionOption{bi-lang}{%
  \caption@ifinlist{#1}{0,all,both}{%
    \bicaption@lang=0\relax
  }{\caption@ifinlist{#1}{1,1st,first}{%
    \bicaption@lang=1\relax
  }{\caption@ifinlist{#1}{2,2nd,second}{%
    \bicaption@lang=2\relax
  }{%
    \bicaption@Error{Undefined bi-lang value `#1'}%
  }}}}
\DeclareCaptionOption{bi-singlelinecheck}[1]{%
  \caption@set@bool\bicaption@ifslc{#1}}
\DeclareCaptionOption{bi-slc}[1]{%
  \caption@set@bool\bicaption@ifslc{#1}}
\DeclareCaptionOption{bi-swap}[1]{%
  \caption@set@bool\bicaption@ifswap{#1}}
\DeclareCaptionOption{lang}{\def\bicaption@language{#1}}
\let\KV@caption@language\KV@caption@lang
\newcommand*\bicaption@selectlanguage[1]{%
  \caption@ifundefined\bicaption@language{}{%
    \expandafter\selectcaptionlanguage\expandafter#1\expandafter{\bicaption@language}}}
\g@addto@macro\caption@applyfont{%
  \bicaption@selectlanguage\@firstoftwo}
\g@addto@macro\caption@prepareslc{%
  \let\bicaption@language\@undefined}
\providecommand*\selectcaptionlanguage[1]{%
  #1\select@language\selectlanguage}
\caption@ExecuteOptions{caption}{bi-lang=0,bi-slc=1,bi-swap=0}
\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
\ifcsname captionmainlanguage\endcsname
  \edef\@tempa{\noexpand\captionsetup[bi-first]{lang=\captionmainlanguage}}
  \@tempa
\fi
\caption@SetupOptions{bicaption}{\captionsetup[bi-second]{#2}}%
\caption@ProcessOptions*{bicaption}
\let\bicaption@addcontentsline@ORI\caption@addcontentsline
\renewcommand*\caption@addcontentsline[2]{%
  \caption@ifundefined\bicaption@lentry
    {\bicaption@addcontentsline@ORI{#1}{#2}}%
    {\expandafter\bicaption@addcontentsline\expandafter
       {\bicaption@lentry}{#1}{#2}%
     \global\let\bicaption@lentry\@undefined}}
\newcommand\bicaption@addcontentsline[3]{%
  \begingroup
    \let\caption@addsubcontentslines\@gobble
    \caption@setoptions{bi}%
    \ifnum\bicaption@lang=2\relax \else
      \begingroup
        \caption@setoptions{bi-first}%
        \bicaption@@addcontentsline{#2}{#3}%
      \endgroup
    \fi
    \ifnum\bicaption@lang=1\relax \else
      \begingroup
        \caption@setoptions{bi-second}%
        \bicaption@@addcontentsline{#2}{#1}%
      \endgroup
    \fi
  \endgroup
  \caption@addsubcontentslines{#2}}
\newcommand*\bicaption@@addcontentsline[2]{%
  \caption@ifcontentsline{#2}{%
    \bicaption@selectlanguage\@secondoftwo
    \bicaption@addcontentsline@ORI{#1}{#2}}}
\let\caption@@make@ORI\caption@@make
\renewcommand\caption@@make[2]{%
  \caption@ifundefined\bicaption@text
    {\caption@@make@ORI{#1}{#2}}%
    {\expandafter\bicaption@@make\expandafter
       {\bicaption@text}{#1}{#2}%
     \global\let\bicaption@text\@undefined}}
\newcommand\bicaption@@make[3]{%
  \caption@setoptions{bi}%
  \ifnum\bicaption@lang=0\relax
    \bicaption@ifslc
      {\caption@slc{#2}{#3}{}{\KV@caption@singlelinecheck0}%
       \caption@slc{#2}{#1}{}{\KV@caption@singlelinecheck0}}%
      {}%
  \fi
  \ifnum\bicaption@lang=2\relax
    \caption@thelabel
    \global\let\caption@thelabel\relax
  \else
    \begingroup
      \caption@setoptions{bi-first}%
      \caption@@make@ORI{#2}{#3}%
    \endgroup
  \fi
  \ifnum\bicaption@lang=1\relax
  \else
    \begingroup
      \caption@setoptions{bi-second}%
      \caption@@make@ORI{#2}{#1}%
    \endgroup
  \fi}
\newcommand\bicaption{\@bicaption\caption}
\newcommand\bicaptionbox{\@bicaption\captionbox}
\newcommand\bisubcaption{\@bicaption\subcaption}
\let\subbicaption\bisubcaption
\newcommand\bisubcaptionbox{\@bicaption\subcaptionbox}
\let\subbicaptionbox\bisubcaptionbox
\newcommand*\@bicaption[1]{%
  \def\bicaption@cmd{#1}%
  \@ifstar
    {\l@addto@macro\bicaption@cmd*%
     \@@bicaption}%
    {\caption@dblarg\@@@bicaption}}
\newcommand\@@bicaption[1]{%
  \@@@@bicaption{}{#1}[]}
\long\def\@@@bicaption[#1]#2{%
  \caption@dblarg{\@@@@bicaption{#1}{#2}}}
\long\def\@@@@bicaption#1#2[#3]#4{%
  \caption@getlabel#2\label{}\@nil
  \bicaption@ifswap
    {\bicaption@setup{#1}{#2}%
     \bicaption@cmd[{#3}]{#4}}%
    {\bicaption@setup{#3}{#4}%
     \bicaption@cmd[{#1}]{#2}}}
\newcommand\bicaption@setup[2]{%
  \def\bicaption@lentry{#1}%
  \def\bicaption@text{\ignorespaces#2}}
\AtBeginDocument{%
  \ifx\caption@freeze\@undefined \else
    \g@addto@macro\caption@freeze{%
      \let\caption@frozen@bicaption\bicaption
      \def\bicaption{%
        \caption@withoptargs\caption@SC@bicaption}%
      \long\def\caption@SC@bicaption#1#2{%
        \@ifnextchar[%]
          {\caption@SC@bi@caption{#1}{#2}}%
          {\caption@SC@bi@caption@{#1}{#2}}}%
      \long\def\caption@SC@bi@caption#1#2[#3]#4{%
        \caption@@freeze{\bicaption#1{#2}[{#3}]{#4}}%
        \ignorespaces}%
      \long\def\caption@SC@bi@caption@#1#2#3{%
        \caption@@freeze{\bicaption#1{#2}{#3}}%
        \ignorespaces}%
      \l@addto@macro\caption@warmup{%
        \let\bicaption\caption@frozen@bicaption}}%
  \fi}
\endinput
%%
%% End of file `bicaption.sty'.
