summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/caption/bicaption.sty
blob: 4be2e5578bc9b0a6d7862b6f7e9d0e5d89b8dceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
%%
%% This is file `bicaption.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bicaption.dtx  (with options: `package')
%% 
%% Copyright (C) 1994-2020 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%% 
%% https://gitlab.com/axelsommerfeldt/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
%%   caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
%%   caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
%%   caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
%%   caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
%% the derived files
%%   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.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{bicaption}[2020/10/25 v1.3 Bilingual Captions (AR)]
\RequirePackage{caption}[2020/08/23] % needs v3.5 or newer
\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}
\newcommand*\bicaption@CheckCompatibility{%
  \caption@ifcompatibility{%
    \bicaption@Error
      {This package does not work with\MessageBreak
       caption option `compatibility=v1'}%
    \endinput}{}}
\bicaption@CheckCompatibility
\caption@AtBeginDocument{%
  \bicaption@CheckCompatibility
  \let\bicaption@CheckCompatibility\@undefined}
\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{bi-separator}[1]{%
  \caption@set{biseparator}{#1}}
\newcommand\DeclareBiCaptionSeparator[2]{%
  \caption@decl{biseparator}{#1}{#2}}
\@onlypreamble\DeclareBiCaptionSeparator
\DeclareBiCaptionSeparator{none}{}
\DeclareBiCaptionSeparator{smallskip}{\smallskip}
\DeclareBiCaptionSeparator{medskip}{\medskip}
\DeclareBiCaptionSeparator{bigskip}{\bigskip}
\SetCaptionDefault{biseparator}{none}
\DeclareCaptionOption{lang}{%
  \caption@ifundefined\bicaption@language
    \bicaption@language@setupkeys
    \relax
  \def\bicaption@language{#1}%
  \let\bicaption@language@setoptions\@empty}
\let\KV@caption@language\KV@caption@lang
\newcommand*\bicaption@language@keylist{}
\newcommand*\DeclareCaptionLangOption[1]{%
  \@ifundefined{KV@caption@#1}%
    {\bicaption@Error{Undefined caption option `#1'}}%
    {\@cons\bicaption@language@keylist{{#1}}}}
\let\DeclareCaptionLanguageOption\DeclareCaptionLangOption
\newcommand*\bicaption@language@setupkeys{%
  \def\@elt##1{%
    \expandafter\let\csname KV@bicaption@##1\expandafter\endcsname
                    \csname KV@caption@##1\endcsname
    \@namedef{KV@caption@##1}{\bicaption@KV{##1}}}%
  \bicaption@language@keylist
  \let\@elt\relax}
\newcommand\bicaption@KV[2]{%
  \@bicaption@KV{#1}{#2}%
  \l@addto@macro\bicaption@language@setoptions{%
    \@bicaption@KV{#1}{#2}}}
\newcommand\@bicaption@KV[1]{%
  \@nameuse{KV@bicaption@#1}}
\DeclareCaptionLangOption{name}
\newcommand*\bicaption@selectlanguage[1]{%
  \caption@ifundefined\bicaption@language{}{%
    \expandafter\selectcaptionlanguage\expandafter#1\expandafter
      {\bicaption@language}%
    \bicaption@language@setoptions}}
\g@addto@macro\caption@beginhook{%
  \bicaption@selectlanguage\@firstoftwo}
\providecommand*\selectcaptionlanguage[1]{%
  #1\select@language\selectlanguage}
\caption@ExecuteOptions{caption}{bi-lang=0,bi-slc=1,bi-swap=0,bi-separator=default}
\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]{%
  \bicaption@LT@setup
  \global\let\bicaption@LT@setup\relax
  \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}}}
\renewcommand\caption@@make[2]{%
  \caption@ifundefined\bicaption@text
    {\begingroup
       \caption@@make@{#1}{#2}%
     \endgroup}%
    {\expandafter\bicaption@@make\expandafter
       {\bicaption@text}{#1}{#2}%
     \global\let\bicaption@text\@undefined}%
  \caption@@make@epilogue}
\newcommand\bicaption@@make[3]{%
  \caption@setoptions{bi}%
  \ifnum\bicaption@lang=0\relax
    \bicaption@ifslc
      {\caption@slc{#2}{#3}{}{\caption@setsinglelinecheck0}%
       \caption@slc{#2}{#1}{}{\caption@setsinglelinecheck0}}%
      {}%
  \fi
  \ifnum\bicaption@lang=2\relax
    \caption@thelabel
    \global\let\caption@thelabel\relax
    \let\bicaption@tempa\relax
  \else
    \begingroup
      \caption@setoptions{bi-first}%
      \caption@@make@{#2}{#3}%
    \endgroup
    \def\bicaption@tempa{\bicaption@separator\caption@biseparator}%
  \fi
  \ifnum\bicaption@lang=1\relax
  \else
    \bicaption@tempa
    \begingroup
      \caption@setoptions{bi-second}%
      \caption@@make@{#2}{#1}%
    \endgroup
  \fi
}
\newcommand*\bicaption@separator{\par}
\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]{%
  \@ifstar
    {\def\bicaption@cmd{\bicaption@star{#1}}%
     \@@bicaption}%
    {\def\bicaption@cmd{#1}%
     \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}%
  \bicaption@ifswap
    {\bicaption@setup{#1}{#2}%
     \bicaption@cmd[{#3}]{#4}}%
    {\bicaption@setup{#3}{#4}%
     \bicaption@cmd[{#1}]{#2}}}
\long\def\bicaption@star#1[#2]{#1*}
\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}[]}
\long\def\LT@@@bicaption[#1]#2{%
  \caption@dblarg{\LT@@@@bicaption{#1}{#2}}}
\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}}}
\let\bicaption@LTsetup\relax
\let\bicaption@LT@setup\relax
\g@addto@macro\caption@LT@setup{%
  \bicaption@LTsetup
  \global\let\bicaption@LTsetup\relax}
\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'.