summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xtcapts/xt_capts.sty
blob: 6b2000fd681757eb456838558c7f912051626395 (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
%%
%% This is file `xt_capts.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xt_capts.dtx  (with options: `package')
%% 
%% Copyright (C) 1997 Olaf Fricke
%% 
%% IMPORTANT NOTICE:
%% This file is part of the eXTendend CAPTionS package.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xt_capts}
         [1998/02/25 v1.1d eXTended CAPTionS (OFR)]

\long\def\g@prependto@macro#1#2{%
  \begingroup \def\reserved@a{#2}%
    \toks@\expandafter\expandafter\expandafter{%
      \expandafter\reserved@a#1}%
    \xdef#1{\the\toks@}%
    \endgroup}
\def\BeforeAtBeginDocument{\g@prependto@macro\@begindocumenthook}
\def\AfterAtBeginDocument#1{\g@prependto@macro\@preamblecmds{#1}}
\@onlypreamble\BeforeAtBeginDocument
\@onlypreamble\AfterAtBeginDocument
\def\BeforeAtEndDocument#1{\g@prependto@macro\@enddocumenthook{#1}}

\newcommand{\DeclareCaption}[2]{%
  \xtc@init{#2}%
  \DeclareTextCommand#1{#2}}
\newcommand{\ProvideCaption}[2]{%
  \xtc@init{#2}%
  \ProvideTextCommand#1{#2}}
\@onlypreamble\DeclareCaption
\newcommand{\DeclareCaptionDefault}[1]{%
  \DeclareTextCommand#1{lang?}}
\newcommand{\ProvideCaptionDefault}[1]{%
  \ProvideTextCommand#1{lang?}}
\@onlypreamble\DeclareCaptionDefault
\expandafter\let\csname lang?-cmd\endcsname\xtc@changed@lang
\def\xtc@use@lang#1{%
  \expandafter\let\csname\xtc@lang -cmd\endcsname\xtc@changed@lang
  \edef\xtc@lang{#1}%
  \expandafter\let\csname\xtc@lang -cmd\endcsname\xtc@current@lang}
\def\xtc@lang{lang?}
\def\xtc@current@lang#1{%
   \ifx\protect\@typeset@protect
      \@inmathwarn#1%
   \else
      \noexpand#1\expandafter\@gobble
   \fi}
\def\xtc@changed@lang#1#2{%
   \ifx\protect\@typeset@protect
      \@inmathwarn#1%
      \expandafter\ifx\csname\xtc@lang\string#1\endcsname\relax
         \expandafter\ifx\csname lang?\string#1\endcsname\relax
            \expandafter\def\csname lang?\string#1\endcsname{%
               \xtc@unavailable#1%
            }%
         \fi
         \global\expandafter\let
               \csname\xtc@lang \string#1\expandafter\endcsname
               \csname lang?\string#1\endcsname
      \fi
      \csname\xtc@lang\string#1%
         \expandafter\endcsname
   \else
      \noexpand#1%
   \fi}
\gdef\xtc@unavailable#1{%
  \@latex@error{%
    Command \protect#1 unavailable in language \xtc@lang%
    }\@eha}
\declare@robustcommand\UseCaption[2]{%
  \@inmathwarn#2%
  \expandafter\ifx\csname #1\string#2\endcsname\relax
    \expandafter\ifx\csname lang?\string#2\endcsname\relax
      \expandafter\def\csname lang?\string#2\endcsname{%
        \xtc@unavailable#2%
        }%
    \fi
    \global\expandafter\let
    \csname #1\string#2\expandafter\endcsname
    \csname lang?\string#2\endcsname
  \fi
  \csname #1\string#2\endcsname
  }

\newcommand{\xtc@init}[1]{%
  \expandafter\ifx\csname xtc@#1\endcsname\relax
    \expandafter\def\csname xtc@#1\endcsname{%
      \xtc@use@lang{#1}}%
    \expandafter\let\csname #1-cmd\endcsname\xtc@changed@lang
    \ifx\@begindocumenthook\@undefined
      \xtc@install{#1}%
    \else
      \AtBeginDocument{\xtc@install{#1}}%
    \fi
  \fi}
\newcommand{\xtc@install}[1]{%
  \begingroup\expandafter\endgroup
  \expandafter\ifx\csname captions#1\endcsname\@undefined
    \PackageWarningNoLine{xt_capts}{%
      You haven't defined the language #1\space yet.\MessageBreak
      Nevertheless, \string\UseCaption{#1}{\string\foo} will work}
  \else
    \expandafter\g@addto@macro\csname captions#1\expandafter\endcsname
      \csname xtc@#1\endcsname
  \fi}
\AfterAtBeginDocument{%
  \ifx\languagename\@undefined
    \xtc@use@lang{english}%
  \else
    \xtc@use@lang\languagename
  \fi}
\BeforeAtBeginDocument{%
  \ifx\languagename\@undefined
    \ifx\captionsenglish\@undefined
      \let\captionsenglish\@empty
    \fi
  \fi}

\endinput
%%
%% End of file `xt_capts.sty'.