summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/coolthms/coolthms.sty
blob: a07ebcd60255ed8531bc209c9f5b1d8005c6d49b (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
%%
%% This is file `coolthms.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% coolthms.dtx 
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from coolthms.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file coolthms.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{coolthms}[2013/02/04 v1.2 Theorem markup and advanced referencing]
\let\Finv\@undefined
\let\Game\@undefined
\let\beth\@undefined
\let\gimel\@undefined
\let\daleth\@undefined
\RequirePackage{amssymb}
\RequirePackage{hyperref}
\RequirePackage{etoolbox}
\RequirePackage{scrbase} % for \ifstr string comparison macro
\RequirePackage{letltxmacro}
\RequirePackage{ifthen}
\RequirePackage{xargs}
\RequirePackage{kvoptions}
\@ifpackageloaded{amsmath}
  {\RequirePackage[thmmarks,amsmath,hyperref]{ntheorem}}
  {\RequirePackage[thmmarks,hyperref]{ntheorem}}
\RequirePackage{cleveref}
\begingroup
\catcode`\#=12
\gdef\ctp@hashchar{#}%
\endgroup
\@ifundefined{proofname}{\newcommand{\proofname}{Proof}}{}
\let\ctp@temp\proofname\relax
\AtBeginDocument{\edef\ctp@temp{\proofname}%
   \apptocmd{\select@language}{\edef\ctp@temp{\proofname}}{}{}}
\AfterEndEnvironment{proof}{\gdef\proofname{\ctp@temp}}
\DeclareStringOption[\ctp@temp]{proofname}
\DeclareStringOption[$\Box$]{proofsymbol}
\DeclareStringOption[\it]{proofcaptionstyle}
\DeclareStringOption[\coolthms@indent]{proofindent}
\DeclareStringOption[:]{separator}
\DeclareStringOption[0em]{indent}
\DeclareStringOption[0pt]{minskip}
\DeclareStringOption[6pt]{maxskip}
\DeclareBoolOption{externalchapters}
\DeclareLocalOptions{separator,indent,minskip,maxskip%
  proofname,proofsymbol,proofcaptionstyle,proofindent,externalchapters}
\ProcessKeyvalOptions*
\@ifundefined{c@chapter}{%
  \newcounter{chapter}%
  \setcounter{chapter}{1}%
}{}%
\ifcoolthms@externalchapters
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\def\refstepcounter@noarg#1{%
  \cref@old@refstepcounter{#1}%
  \cref@constructprefix{#1}{\cref@result}%
  \@ifundefined{cref@#1@alias}%
    {\def\@tempa{#1}}%
    {\def\@tempa{\csname cref@#1@alias\endcsname}}%
  \edef\chapter@current@value{\the\value{chapter}}
  \protected@edef\cref@currentlabel{%
    [\@tempa][\arabic{#1}][\cref@result]%
    \string\ifstr{\string\the\string\value{chapter}}%
    {\chapter@current@value}{\string\relax}{\thechapter.}%
    \csname p@#1\endcsname\csname the#1\endcsname}
  \protected@edef\cref@old@currentlabel{%
    [\@tempa][\arabic{#1}][\cref@result]%
    \csname p@#1\endcsname\csname the#1\endcsname}
  \ifstr{\@tempa}{chapter}{\protected@edef\cref@currentlabel{\cref@old@currentlabel}}{}}
\def\refstepcounter@optarg[#1]#2{%
  \cref@old@refstepcounter{#2}%
  \cref@constructprefix{#2}{\cref@result}%
  \edef\chapter@current@value{\the\value{chapter}}
  \protected@edef\cref@currentlabel{%
    [#1][\arabic{#2}][\cref@result]%
    \string\ifstr{\string\the\string\value{chapter}}%
    {\chapter@current@value}{\string\relax}{\thechapter.}%
    \csname p@#2\endcsname\csname the#2\endcsname}
  \protected@edef\cref@old@currentlabel{%
    [#1][\arabic{#2}][\cref@result]%
    \csname p@#2\endcsname\csname the#2\endcsname}
  \ifstr{#1}{chapter}{\protected@edef\cref@currentlabel{\cref@old@currentlabel}}{}}
    \def\ctp@label@noarg#1{%
    \letcs{\mycurrentlabel}{@currentlabel}
    \expandafter\def\csname @currentlabel\endcsname{\string\ifstr%
      {\string\the\string\value{chapter}}{\the\value{chapter}}%
      {\string\relax}{\thechpt}\mycurrentlabel}
    \label@noarg{#1}
    \cslet{@currentlabel}{\mycurrentlabel}
    }%
    \def\ctp@label@optarg[#1]#2{%
    \letcs{\mycurrentlabel}{@currentlabel}
    \expandafter\def\csname @currentlabel\endcsname{\string\ifstr%
      {\string\the\string\value{chapter}}{\the\value{chapter}}%
      {\string\relax}{\thechpt}\mycurrentlabel}
    \label@optarg[#1]{#2}
    \cslet{@currentlabel}{\mycurrentlabel}
    \def\label{\@ifnextchar[\ctp@label@optarg\ctp@label@noarg}%]
    }
\else % belongs to \ifcoolthms@externalchapters
\fi
\newtheoremstyle{keinenummern}%
  {\item[\hskip\labelsep\theorem@headerfont ##1\theorem@separator]}%
  {\item[\hskip\labelsep\theorem@headerfont ##1\ %
    {\normalfont(##3)}\theorem@separator]}
\newtheoremstyle{mitnummern}%
  {\item[\hskip\labelsep\theorem@headerfont ##1\ ##2\theorem@separator]}%
  {\item[\hskip\labelsep\theorem@headerfont ##1\ ##2\ %
    {\normalfont(##3)}\theorem@separator]}
\newtheoremstyle{unserbeweis}%
  {\item[{\hskip\labelsep\theorem@headerfont ##1\theorem@separator}]}%
  {\item[\hskip\labelsep{\theorem@headerfont ##3\theorem@separator}]}
\newcommandx*{\definetheorem}[5][1=thmcnt,3=,5=section]{
  \@ifundefined{c@#1}{
    \@ifundefined{c@#5}{
      \newtheorem{#1}{#1}
    }{
      \newtheorem{#1}{#1}[#5]
    }
  }{}
  \theoremstyle{mitnummern}
  \newtheorem{#2}[#1]{#4}
  \theoremstyle{keinenummern}
  \newtheorem{n#2}[#1]{#4}
  \ifblank{#3}{
    \crefname{#2}{#4}{#4}
  }{
    \crefname{#2}{#4}{#3}
  }
  \crefformat{#2}{##2#4~##1##3}
  \BeforeBeginEnvironment{n#2}{\addtocounter{#1}{-1}}
  \BeforeBeginEnvironment{#2}{%
     \addtocounter{#1}{1}%
     \edef\ctp@labelcode%
        {ctp@#2@\roman{chapter}@\roman{section}@\arabic{#1}}\relax%
\ifcoolthms@externalchapters
     \immediate\write\@auxout{\string\crefname{\ctp@labelcode}%
               {#4\noexpand~%
                 \string\ifstr{\string\the\string\value{chapter}}%
                 {\chapter@current@value}{\string\relax}{\thechapter.}%
                 \csname the#1\endcsname}%
               {#3\noexpand~\csname the#1\endcsname}}\relax%
     \immediate\write\@auxout{\string\crefformat{\ctp@labelcode}%
               {\string##2#4\noexpand~%
                 \string\ifstr{\string\the\string\value{chapter}}%
                 {\chapter@current@value}{\string\relax}{\thechapter.}%
                 \csname the#1\endcsname\noexpand~%
                  \ctp@hashchar1\ctp@hashchar3}}\relax%
\else
     \immediate\write\@auxout{\string\crefname{\ctp@labelcode}%
               {#4\noexpand~\csname the#1\endcsname}%
               {#4 plural\noexpand~\csname the#1\endcsname}}\relax%
     \immediate\write\@auxout{\string\crefformat{\ctp@labelcode}%
               {\string##2#4\noexpand~\csname the#1\endcsname\noexpand~%
                  \ctp@hashchar1\ctp@hashchar3}}\relax%
\fi
\ifcoolthms@externalchapters
     \def\Label##1{\cref@old@label{##1}%
       \protected@edef\cref@currentlabel{%
         \expandafter\cref@override@label@type%
         \cref@old@currentlabel\@nil{\ctp@labelcode}}%
       \protected@write\@auxout{}%
       {\string\newlabel{##1@cref}{{\cref@currentlabel}{\thepage}}}}
\else
      \edef\Label##1{\noexpand\label[\ctp@labelcode]{##1}}%
\fi
      \addtocounter{#1}{-1} %
  }% End of \BeforeBeginEnvironment
}% End of \newcommandx*{\definetheorem}
\newcommandx*{\theoremmarkup}[6][1=\bf,2=\normalfont,3=\relax,%
              4=\coolthms@indent,5=\coolthms@separator,6=arabic]{
  \theoremheaderfont{\hspace*{-\theorem@indent}#1}
  \theorembodyfont{#2}
  \theoremsymbol{#3}
  \theoremindent#4\relax
  \theoremseparator{#5}
  \theoremnumbering{#6}
}
\crefformat{equation}{#2(#1)#3}
\crefformat{chapter}{#2\chaptername~#1#3}
\theorempreskipamount\coolthms@minskip plus \coolthms@maxskip\relax
\theorempostskipamount\coolthms@minskip plus \coolthms@maxskip\relax
\theoremstyle{unserbeweis}
\theoremmarkup[\coolthms@proofcaptionstyle][\normalfont]%
  [\coolthms@proofsymbol][\coolthms@proofindent]
\expandafter\newtheorem{proof}{\coolthms@proofname}
\theoremmarkup
\endinput
%%
%% End of file `coolthms.sty'.