| 1 |
%% |
| 2 |
%% This is file `bicaption.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% bicaption.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 1994-2023 Axel Sommerfeldt ([email protected]) |
| 10 |
%% |
| 11 |
%% https://gitlab.com/axelsommerfeldt/caption |
| 12 |
%% |
| 13 |
%% -------------------------------------------------------------------------- |
| 14 |
%% |
| 15 |
%% This work may be distributed and/or modified under the |
| 16 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 17 |
%% of this license or (at your option) any later version. |
| 18 |
%% The latest version of this license is in |
| 19 |
%% http://www.latex-project.org/lppl.txt |
| 20 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 21 |
%% version 2003/12/01 or later. |
| 22 |
%% |
| 23 |
%% This work has the LPPL maintenance status "maintained". |
| 24 |
%% |
| 25 |
%% This Current Maintainer of this work is Axel Sommerfeldt. |
| 26 |
%% |
| 27 |
%% This work consists of the files |
| 28 |
%% caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx, |
| 29 |
%% caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx, |
| 30 |
%% caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx, |
| 31 |
%% caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx, |
| 32 |
%% the derived files |
| 33 |
%% caption.sty, caption-light.sty, caption2.sty, caption3.sty, |
| 34 |
%% caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto, |
| 35 |
%% caption-koma.sto, caption-memoir.sto, caption-ntg.sto, |
| 36 |
%% caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty. |
| 37 |
%% |
| 38 |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 39 |
\providecommand\DeclareRelease[3]{} |
| 40 |
\providecommand\DeclareCurrentRelease[2]{} |
| 41 |
\DeclareCurrentRelease{v1}{2011/07/13} |
| 42 |
\ProvidesPackage{bicaption}[2023/02/19 v1.6 Bilingual Captions (AR)] |
| 43 |
\RequirePackage{caption}[2011/11/10] % we need at least v3.2e |
| 44 |
\newcommand*\bicaption@Info[1]{% |
| 45 |
\PackageInfo{bicaption}{#1}} |
| 46 |
\newcommand*\bicaption@InfoNoLine[1]{% |
| 47 |
\PackageInfo{bicaption}{#1\@gobble}} |
| 48 |
\newcommand*\bicaption@Warning[1]{% |
| 49 |
\bicaption@WarningNoLine{#1\on@line}} |
| 50 |
\newcommand*\bicaption@WarningNoLine[1]{% |
| 51 |
\PackageWarning{bicaption}{#1.^^J\bicaption@wh\@gobbletwo}} |
| 52 |
\newcommand*\bicaption@wh{% |
| 53 |
See the `bicaption' package documentation for explanation.} |
| 54 |
\newcommand*\bicaption@Error[1]{% |
| 55 |
\PackageError{bicaption}{#1}{\caption@@eh{bicaption}}} |
| 56 |
\providecommand*\caption@@eh[1]{% |
| 57 |
If you do not understand this error, please take a closer look\MessageBreak |
| 58 |
at the documentation of the `#1' package, especially the\MessageBreak |
| 59 |
section about errors.\MessageBreak\@ehc} |
| 60 |
\newcount\bicaption@lang |
| 61 |
\DeclareCaptionOption{bi-lang}{% |
| 62 |
\caption@ifinlist{#1}{0,all,both}{% |
| 63 |
\bicaption@lang=0\relax |
| 64 |
}{\caption@ifinlist{#1}{1,1st,first}{% |
| 65 |
\bicaption@lang=1\relax |
| 66 |
}{\caption@ifinlist{#1}{2,2nd,second}{% |
| 67 |
\bicaption@lang=2\relax |
| 68 |
}{% |
| 69 |
\bicaption@Error{Undefined bi-lang value `#1'}% |
| 70 |
}}}} |
| 71 |
\DeclareCaptionOption{bi-singlelinecheck}[1]{% |
| 72 |
\caption@set@bool\bicaption@ifslc{#1}} |
| 73 |
\DeclareCaptionOption{bi-slc}[1]{% |
| 74 |
\caption@set@bool\bicaption@ifslc{#1}} |
| 75 |
\DeclareCaptionOption{bi-swap}[1]{% |
| 76 |
\caption@set@bool\bicaption@ifswap{#1}} |
| 77 |
\DeclareCaptionOption{bi-separator}[1]{% |
| 78 |
\caption@set{biseparator}{#1}} |
| 79 |
\providecommand*\caption@set[2]{% |
| 80 |
\@ifundefined{caption@#1@#2}% |
| 81 |
{\caption@Error{Undefined #1 `#2'}}% |
| 82 |
{\expandafter\let\csname caption@#1\expandafter\endcsname\csname caption@#1@#2\endcsname}} |
| 83 |
\newcommand\DeclareBiCaptionSeparator[2]{% |
| 84 |
\caption@decl{biseparator}{#1}{#2}} |
| 85 |
\@onlypreamble\DeclareBiCaptionSeparator |
| 86 |
\providecommand*\caption@decl[2]{% |
| 87 |
\global\long\expandafter\def\csname caption@#1@#2\endcsname} |
| 88 |
\DeclareBiCaptionSeparator{none}{} |
| 89 |
\DeclareBiCaptionSeparator{smallskip}{\smallskip} |
| 90 |
\DeclareBiCaptionSeparator{medskip}{\medskip} |
| 91 |
\DeclareBiCaptionSeparator{bigskip}{\bigskip} |
| 92 |
\caption@ifundefined\SetCaptionDefault |
| 93 |
{\def\caption@biseparator@default{\caption@biseparator@none}} |
| 94 |
{\SetCaptionDefault{biseparator}{none}} |
| 95 |
\DeclareCaptionOption{lang}{% |
| 96 |
\caption@ifundefined\bicaption@language |
| 97 |
\bicaption@language@setupkeys |
| 98 |
\relax |
| 99 |
\edef\bicaption@language{#1}% |
| 100 |
\let\bicaption@language@setoptions\@empty |
| 101 |
\global\let\bicaption@language@value\bicaption@language} |
| 102 |
\let\KV@caption@language\KV@caption@lang |
| 103 |
\newcommand*\bicaption@language@keylist{} |
| 104 |
\newcommand*\DeclareCaptionLangOption[1]{% |
| 105 |
\@ifundefined{KV@caption@#1}% |
| 106 |
{\bicaption@Error{Undefined caption option `#1'}}% |
| 107 |
{\@cons\bicaption@language@keylist{{#1}}}} |
| 108 |
\let\DeclareCaptionLanguageOption\DeclareCaptionLangOption |
| 109 |
\newcommand*\bicaption@language@setupkeys{% |
| 110 |
\def\@elt##1{% |
| 111 |
\expandafter\let\csname KV@bicaption@##1\expandafter\endcsname |
| 112 |
\csname KV@caption@##1\endcsname |
| 113 |
\@namedef{KV@caption@##1}{\bicaption@KV{##1}}}% |
| 114 |
\bicaption@language@keylist |
| 115 |
\let\@elt\relax} |
| 116 |
\newcommand\bicaption@KV[2]{% |
| 117 |
\@bicaption@KV{#1}{#2}% |
| 118 |
\l@addto@macro\bicaption@language@setoptions{% |
| 119 |
\@bicaption@KV{#1}{#2}}} |
| 120 |
\newcommand\@bicaption@KV[1]{% |
| 121 |
\@nameuse{KV@bicaption@#1}} |
| 122 |
\DeclareCaptionLangOption{name} |
| 123 |
\newcommand*\bicaption@selectlanguage[1]{% |
| 124 |
\caption@ifundefined\bicaption@language{}{% |
| 125 |
\expandafter\selectcaptionlanguage\expandafter#1\expandafter |
| 126 |
{\bicaption@language}% |
| 127 |
\bicaption@language@setoptions}} |
| 128 |
\g@addto@macro\caption@beginhook{% |
| 129 |
\bicaption@selectlanguage\@firstoftwo} |
| 130 |
\providecommand*\selectcaptionlanguage[1]{% |
| 131 |
#1\select@language\selectlanguage} |
| 132 |
\caption@ExecuteOptions{caption}{bi-lang=0,bi-slc=1,bi-swap=0,bi-separator=default} |
| 133 |
\AtBeginDocument{% |
| 134 |
\ifcsname captionmainlanguage\endcsname |
| 135 |
\bicaption@InfoNoLine{% |
| 136 |
Main language is set to \captionmainlanguage}% |
| 137 |
\else |
| 138 |
\bicaption@setmainlanguage |
| 139 |
\fi |
| 140 |
\ifcsname captionmainlanguage\endcsname |
| 141 |
\captionsetup*[bi-first]{lang=\captionmainlanguage}% |
| 142 |
\else |
| 143 |
\ifcsname bicaption@language@value\endcsname % option "lang=" was used |
| 144 |
\expandafter\bicaption@Warning |
| 145 |
\else |
| 146 |
\expandafter\bicaption@Info |
| 147 |
\fi |
| 148 |
{Main language is not set}% |
| 149 |
\fi} |
| 150 |
\newcommand*\bicaption@setmainlanguage{% |
| 151 |
\ifcsname bbl@main@language\endcsname |
| 152 |
\bicaption@InfoNoLine{% |
| 153 |
babel found, main language is \bbl@main@language}% |
| 154 |
\let\captionmainlanguage\bbl@main@language |
| 155 |
\else\ifcsname xpg@main@language\endcsname |
| 156 |
\bicaption@InfoNoLine{% |
| 157 |
polyglossia found, main language is \xpg@main@language}% |
| 158 |
\let\captionmainlanguage\xpg@main@language |
| 159 |
\fi\fi} |
| 160 |
\@onlypreamble\bicaption@setmainlanguage |
| 161 |
\caption@SetupOptions{bicaption}{\captionsetup*[bi-second]{#2}}% |
| 162 |
\caption@ProcessOptions*{bicaption} |
| 163 |
\let\bicaption@addcontentsline@ORI\caption@addcontentsline |
| 164 |
\renewcommand*\caption@addcontentsline[2]{% |
| 165 |
\bicaption@LT@setup |
| 166 |
\global\let\bicaption@LT@setup\relax |
| 167 |
\caption@ifundefined\bicaption@lentry |
| 168 |
{\bicaption@addcontentsline@ORI{#1}{#2}}% |
| 169 |
{\expandafter\bicaption@addcontentsline\expandafter |
| 170 |
{\bicaption@lentry}{#1}{#2}% |
| 171 |
\global\let\bicaption@lentry\@undefined}} |
| 172 |
\newcommand\bicaption@addcontentsline[3]{% |
| 173 |
\begingroup |
| 174 |
\let\caption@addsubcontentslines\@gobble |
| 175 |
\caption@setoptions{bi}% |
| 176 |
\ifnum\bicaption@lang=2\relax \else |
| 177 |
\begingroup |
| 178 |
\caption@setoptions{bi-first}% |
| 179 |
\bicaption@@addcontentsline{#2}{#3}% |
| 180 |
\endgroup |
| 181 |
\fi |
| 182 |
\ifnum\bicaption@lang=1\relax \else |
| 183 |
\begingroup |
| 184 |
\caption@setoptions{bi-second}% |
| 185 |
\bicaption@@addcontentsline{#2}{#1}% |
| 186 |
\endgroup |
| 187 |
\fi |
| 188 |
\endgroup |
| 189 |
\caption@addsubcontentslines{#2}} |
| 190 |
\newcommand*\bicaption@@addcontentsline[2]{% |
| 191 |
\caption@ifcontentsline{#2}{% |
| 192 |
\bicaption@selectlanguage\@secondoftwo |
| 193 |
\bicaption@addcontentsline@ORI{#1}{#2}}} |
| 194 |
\caption@ifundefined\caption@@make@ |
| 195 |
{\let\caption@@make@\caption@@make} |
| 196 |
{} |
| 197 |
\renewcommand\caption@@make[2]{% |
| 198 |
\caption@ifundefined\bicaption@text |
| 199 |
{\begingroup |
| 200 |
\caption@@make@{#1}{#2}% |
| 201 |
\endgroup}% |
| 202 |
{\expandafter\bicaption@@make\expandafter |
| 203 |
{\bicaption@text}{#1}{#2}% |
| 204 |
\global\let\bicaption@text\@undefined}% |
| 205 |
\@nameuse{caption@@make@epilogue}} |
| 206 |
\newcommand\bicaption@@make[3]{% |
| 207 |
\caption@setoptions{bi}% |
| 208 |
\ifnum\bicaption@lang=0\relax |
| 209 |
\bicaption@ifslc |
| 210 |
{\bicaption@slc{#2}{#3}{}{\caption@setsinglelinecheck0}% |
| 211 |
\bicaption@slc{#2}{#1}{}{\caption@setsinglelinecheck0}}% |
| 212 |
{}% |
| 213 |
\fi |
| 214 |
\ifnum\bicaption@lang=2\relax |
| 215 |
\caption@thelabel |
| 216 |
\let\bicaption@tempa\relax |
| 217 |
\else |
| 218 |
\begingroup |
| 219 |
\caption@setoptions{bi-first}% |
| 220 |
\caption@@make@{#2}{#3}% |
| 221 |
\endgroup |
| 222 |
\def\bicaption@tempa{\bicaption@separator\caption@biseparator}% |
| 223 |
\fi |
| 224 |
\ifnum\bicaption@lang=1\relax |
| 225 |
\else |
| 226 |
\bicaption@tempa |
| 227 |
\begingroup |
| 228 |
\caption@setoptions{bi-second}% |
| 229 |
\caption@@make@{#2}{#1}% |
| 230 |
\endgroup |
| 231 |
\fi |
| 232 |
\global\bicaption@clrlabel} |
| 233 |
\newcommand*\bicaption@separator{\par} |
| 234 |
\caption@ifundefined\caption@@slc |
| 235 |
{\newcommand\bicaption@slc{\caption@slc}} |
| 236 |
{\newcommand\bicaption@slc[2]{\caption@@slc{#1}{#2}{\captionwidth}}} |
| 237 |
\providecommand*\caption@setsinglelinecheck{% |
| 238 |
\caption@set@bool\caption@ifslc} |
| 239 |
\newcommand*\bicaptionsetup{% |
| 240 |
\caption@teststar\@bicaptionsetup*{}} |
| 241 |
\newcommand*\@bicaptionsetup[1]{% |
| 242 |
\kernel@ifnextchar[%] |
| 243 |
{\bicaption@setup@options{#1}}% |
| 244 |
{\bicaption@setup*}} |
| 245 |
\def\bicaption@setup@options#1[#2]{% |
| 246 |
\bicaption@setup{#1[{#2}]}} |
| 247 |
\newcommand*\bicaption@setup[2]{% |
| 248 |
\captionsetup#1[bi-first]{#2}% |
| 249 |
\captionsetup#1[bi-second]} |
| 250 |
\newcommand\bicaption{\@bicaption\caption} |
| 251 |
\newcommand\bicaptionbox{\@bicaption\captionbox} |
| 252 |
\newcommand\bisubcaption{\@bicaption\subcaption} |
| 253 |
\let\subbicaption\bisubcaption |
| 254 |
\newcommand\bisubcaptionbox{\@bicaption\subcaptionbox} |
| 255 |
\let\subbicaptionbox\bisubcaptionbox |
| 256 |
\newcommand*\@bicaption[1]{% |
| 257 |
\@ifstar |
| 258 |
{\def\bicaption@cmd{\bicaption@star{#1}}% |
| 259 |
\@@bicaption}% |
| 260 |
{\def\bicaption@cmd{#1}% |
| 261 |
\caption@dblarg\@@@bicaption}} |
| 262 |
\newcommand\@@bicaption[1]{% |
| 263 |
\@@@@bicaption{}{#1}[]} |
| 264 |
\long\def\@@@bicaption[#1]#2{% |
| 265 |
\caption@dblarg{\@@@@bicaption{#1}{#2}}} |
| 266 |
\long\def\@@@@bicaption#1#2[#3]#4{% |
| 267 |
\bicaption@getlabel{#2}% |
| 268 |
\bicaption@ifswap |
| 269 |
{\bicaption@set{#1}{#2}% |
| 270 |
\bicaption@cmd[{#3}]{#4}}% |
| 271 |
{\bicaption@set{#3}{#4}% |
| 272 |
\bicaption@cmd[{#1}]{#2}}} |
| 273 |
\long\def\bicaption@star#1[#2]{#1*} |
| 274 |
\@ifundefined{caption@getlabel}{% |
| 275 |
\newcommand\bicaption@getlabel[1]{% caption3 < v1.7 |
| 276 |
\bicaption@@getlabel#1\label{}\@nil} |
| 277 |
\long\def\bicaption@@getlabel#1\label#2#3\@nil{% |
| 278 |
\def\@tempa{#2}% |
| 279 |
\ifx\@tempa\@empty |
| 280 |
\let\caption@thelabel\relax |
| 281 |
\else |
| 282 |
\def\@tempb{*}% |
| 283 |
\ifx\@tempa\@tempb |
| 284 |
\def\caption@thelabel{\label*}% |
| 285 |
\bicaption@@@getlabel#3\@nil |
| 286 |
\else |
| 287 |
\def\caption@thelabel{\label}% |
| 288 |
\bicaption@@@getlabel{#2}#3\@nil |
| 289 |
\fi |
| 290 |
\fi} |
| 291 |
\long\def\bicaption@@@getlabel#1#2\@nil{% |
| 292 |
\def\@tempa{#1}% |
| 293 |
\def\@tempb{[}% |
| 294 |
\ifx\@tempa\@tempb |
| 295 |
\bicaption@@@@getlabel#1#2\@nil |
| 296 |
\else |
| 297 |
\l@addto@macro\caption@thelabel{{#1}}% |
| 298 |
\fi} |
| 299 |
\long\def\bicaption@@@@getlabel[#1]#2\@nil{% |
| 300 |
\l@addto@macro\caption@thelabel{[{#1}]}% |
| 301 |
\bicaption@@@getlabel#2\@nil} |
| 302 |
}{\@ifundefined{caption@@@@getlabel}{% |
| 303 |
\newcommand\bicaption@getlabel[1]{% caption3 >= v1.7 |
| 304 |
\caption@getlabel#1\label{}\@nil} |
| 305 |
}{% |
| 306 |
\newcommand*\bicaption@getlabel{% caption3 >= v2.0 |
| 307 |
\caption@getlabel} |
| 308 |
}} |
| 309 |
\@ifundefined{caption@clrlabel}{% |
| 310 |
\newcommand*\bicaption@clrlabel{\let\caption@thelabel\relax} % caption3 < v2.3 |
| 311 |
}{% |
| 312 |
\newcommand*\bicaption@clrlabel{\caption@clrlabel} % caption3 >= v2.3 |
| 313 |
} |
| 314 |
\newcommand\bicaption@set[2]{% |
| 315 |
\def\bicaption@lentry{#1}% |
| 316 |
\def\bicaption@text{\ignorespaces #2}} |
| 317 |
\newcommand*\bicaption@clear{% |
| 318 |
\let\bicaption@lentry\@undefined |
| 319 |
\let\bicaption@text\@undefined} |
| 320 |
\AtBeginDocument{% |
| 321 |
\ifx\caption@freeze\@undefined \else |
| 322 |
\g@addto@macro\caption@freeze{% |
| 323 |
\let\caption@frozen@bicaption\bicaption |
| 324 |
\def\bicaption{% |
| 325 |
\caption@withoptargs\caption@SC@bicaption}% |
| 326 |
\long\def\caption@SC@bicaption#1#2{% |
| 327 |
\kernel@ifnextchar[%] |
| 328 |
{\caption@SC@bi@caption{#1}{#2}}% |
| 329 |
{\caption@SC@bi@caption@{#1}{#2}}}% |
| 330 |
\long\def\caption@SC@bi@caption#1#2[#3]#4{% |
| 331 |
\caption@@freeze{\bicaption#1{#2}[{#3}]{#4}}% |
| 332 |
\ignorespaces}% |
| 333 |
\long\def\caption@SC@bi@caption@#1#2#3{% |
| 334 |
\caption@@freeze{\bicaption#1{#2}{#3}}% |
| 335 |
\ignorespaces}% |
| 336 |
\l@addto@macro\caption@warmup{% |
| 337 |
\let\bicaption\caption@frozen@bicaption}}% |
| 338 |
\fi} |
| 339 |
\caption@IfPackageLoaded{listings}[2004/02/13 v1.2]{% |
| 340 |
\lst@Key{caption1}\relax{% |
| 341 |
\lstKV@OptArg[{#1}]{#1}{% |
| 342 |
\bicaption@ifswap |
| 343 |
{\bicaption@set{##1}{##2}}% |
| 344 |
{\def\lst@@caption{##1}\def\lst@caption{##2}}}% |
| 345 |
\let\lst@title\@empty}% |
| 346 |
\lst@Key{caption2}\relax{% |
| 347 |
\lstKV@OptArg[{#1}]{#1}{% |
| 348 |
\bicaption@ifswap |
| 349 |
{\def\lst@@caption{##1}\def\lst@caption{##2}}% |
| 350 |
{\bicaption@set{##1}{##2}}}% |
| 351 |
\let\lst@title\@empty}% |
| 352 |
\lst@AddToHookExe{TextStyle}{% |
| 353 |
\bicaption@clear}% |
| 354 |
}{} |
| 355 |
\newcommand\LT@bicaption{% |
| 356 |
\noalign\bgroup |
| 357 |
\@ifstar |
| 358 |
{\gdef\bicaption@cmd{\LT@c@ption\@gobble}% |
| 359 |
\LT@@bicaption}% |
| 360 |
{\gdef\bicaption@cmd{\LT@c@ption\@firstofone}% |
| 361 |
\caption@dblarg\LT@@@bicaption}} |
| 362 |
\newcommand\LT@@bicaption[1]{% |
| 363 |
\LT@@@@bicaption{}{#1}[]} |
| 364 |
\long\def\LT@@@bicaption[#1]#2{% |
| 365 |
\caption@dblarg{\LT@@@@bicaption{#1}{#2}}} |
| 366 |
\long\def\LT@@@@bicaption#1#2[#3]#4{% |
| 367 |
\gdef\bicaption@LTsetup{% |
| 368 |
\bicaption@getlabel{#2}% |
| 369 |
\bicaption@LT@setup}% |
| 370 |
\gdef\bicaption@LT@setup{% |
| 371 |
\bicaption@ifswap |
| 372 |
{\bicaption@set{#1}{#2}}% |
| 373 |
{\bicaption@set{#3}{#4}}}% |
| 374 |
\bicaption@ifswap |
| 375 |
{\egroup\bicaption@cmd[{#3}]{#4}}% |
| 376 |
{\egroup\bicaption@cmd[{#1}]{#2}}} |
| 377 |
\let\bicaption@LTsetup\relax |
| 378 |
\let\bicaption@LT@setup\relax |
| 379 |
\caption@ifundefined\caption@LT@setup{% |
| 380 |
% Fallback code for caption v3.2 |
| 381 |
\captionsetup*[longtable]{bicaption-lt-setup} |
| 382 |
\DeclareCaptionOptionNoValue{bicaption-lt-setup}{% |
| 383 |
\bicaption@LTsetup |
| 384 |
\global\let\bicaption@LTsetup\relax} |
| 385 |
}{% |
| 386 |
\g@addto@macro\caption@LT@setup{% |
| 387 |
\bicaption@LTsetup |
| 388 |
\global\let\bicaption@LTsetup\relax} |
| 389 |
} |
| 390 |
\endinput |
| 391 |
%% |
| 392 |
%% End of file `bicaption.sty'. |