%%
%% This is file `bicaption.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bicaption.dtx  (with options: `package')
%% 
%% Copyright (C) 1994-2012 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%% 
%% --------------------------------------------------------------------------
%% 
%% 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 caption.ins, caption.dtx, caption2.dtx,
%% caption3.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx, and newfloat.dtx,
%% the derived files caption.sty, caption2.sty, caption3.sty,
%% bicaption.sty, ltcaption.sty, subcaption.sty, and newfloat.sty,
%% and the user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{bicaption}[2011/10/30 v1.0a Bilingual Captions (AR)]
\RequirePackage{caption}[2011/08/28] % needs v3.2c or newer
\caption@AtBeginDocument{\caption@ifcompatibility{%
  \caption@Error{%
    The `bicaption' package does not work correctly\MessageBreak
    in compatibility mode}}{}}
\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{%
  \@ifstar
    {\bicaption@select@language\select@language}
    {\bicaption@select@language\selectlanguage}}
\newcommand*\bicaption@select@language[1]{%
  \caption@ifundefined\bicaption@language{}{%
    \expandafter#1\expandafter{\bicaption@language}}}
\g@addto@macro\caption@applyfont{%
  \bicaption@selectlanguage*}
\g@addto@macro\caption@prepareslc{%
  \let\bicaption@language\@undefined}
\caption@ExecuteOptions{caption}{bi-lang=0,bi-slc=1,bi-swap=0}
\ifcsname bbl@main@language\endcsname
  \edef\@tempa{\noexpand\captionsetup[bi-first]{lang=\bbl@main@language}}
  \@tempa
\else\ifcsname xpg@main@language\endcsname
  \edef\@tempa{\noexpand\captionsetup[bi-first]{lang=\xpg@main@language}}
  \@tempa
\else
  \bicaption@WarningNoLine{Please load this package after the babel package}
\fi\fi
\caption@SetupOptions{bicaption}{\captionsetup[bi-second]{#2}}%
\caption@ProcessOptions*{bicaption}
\let\caption@kernel@addcontentsline@ORI\caption@kernel@addcontentsline
\renewcommand*\caption@kernel@addcontentsline[2]{%
  \caption@ifundefined\bicaption@lentry
    {\caption@kernel@addcontentsline@ORI{#1}{#2}}%
    {\expandafter\bicaption@addcontentsline\expandafter{\bicaption@lentry}{#1}{#2}%
     \global\let\bicaption@lentry\@undefined}}
\newcommand\bicaption@addcontentsline[3]{%
  \begingroup
    \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}
\newcommand*\bicaption@@addcontentsline[2]{%
  \caption@ifcontentsline{#2}{%
    \bicaption@selectlanguage\relax
    \caption@kernel@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}{\captionwidth}{}%
                    {\caption@set@bool\caption@ifslc0}%
       \caption@@slc{#2}{#1}{\captionwidth}{}%
                    {\caption@set@bool\caption@ifslc0}}%
      {}%
  \fi
  \ifnum\bicaption@lang=2\relax
    \bicaption@label
    \global\let\bicaption@label\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{%
  \bicaption@getlabel#2\label{}\@nil
  \bicaption@ifswap
    {\bicaption@setup{#1}{#2}%
     \bicaption@cmd[{#3}]{#4}}%
    {\bicaption@setup{#3}{#4}%
     \bicaption@cmd[{#1}]{#2}}}
\long\def\bicaption@getlabel#1\label#2#3\@nil{%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty
    \let\bicaption@label\relax
  \else
    \def\@tempb{*}%
    \ifx\@tempa\@tempb
      \def\bicaption@label{\label*}%
      \bicaption@@getlabel#3\@nil
    \else
      \def\bicaption@label{\label}%
      \bicaption@@getlabel{#2}#3\@nil
    \fi
  \fi}
\long\def\bicaption@@getlabel#1#2\@nil{%
  \def\@tempa{#1}%
  \def\@tempb{[}%
  \ifx\@tempa\@tempb
    \bicaption@@@getlabel#1#2\@nil
  \else
    \l@addto@macro\bicaption@label{{#1}}%
  \fi}
\long\def\bicaption@@@getlabel[#1]#2\@nil{%
  \l@addto@macro\bicaption@label{[{#1}]}%
  \bicaption@@getlabel#2\@nil}
\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}
\newcommand*\bicaption@declarelist[1]{%
  \@namedef{listof#1}{\bicaption@listof#1}}
\@onlypreamble\bicaption@declarelist
\def\bicaption@listof#1 {\@nameuse{listof#1}}
\caption@ForEachType{\bicaption@declarelist{#1}}
\endinput
%%
%% End of file `bicaption.sty'.
