summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/thmtools/thm-autoref.sty
blob: ea5ac3709b2590c61ea3c791d18616e0267a0e2e (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
%%
%% This is file `thm-autoref.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% thm-autoref.dtx  (with options: `autoref')
%% This is a generated file.
%% 
%% This file is part of the `thmtools' package.
%% The `thmtools' package has the LPPL maintenance status: maintained.
%% Current Maintainer is Ulrich M. Schwarz, ulmi@absatzen.de
%% 
%% Copyright (C) 2008-2011 by Ulrich M. Schwarz.
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, version 1.3a.
%% This version is obtainable at
%% http://www.latex-project.org/lppl/lppl-1-3a.txt
%% 
%% 
\NeedsTeXFormat {LaTeX2e}
\ProvidesPackage {thm-autoref}[2011/06/02 v61]

\RequirePackage{thm-patch, aliasctr, parseargs, keyval}

\let\@xa=\expandafter
\let\@nx=\noexpand

\newcommand\thmt@autorefsetup{%
  \@xa\def\csname\thmt@envname autorefname\@xa\endcsname\@xa{\thmt@thmname}%
  \ifthmt@hassibling
    \@counteralias{\thmt@envname}{\thmt@sibling}%
    \@xa\def\@xa\thmt@autoreffix\@xa{%
      \@xa\let\csname the\thmt@envname\@xa\endcsname
        \csname the\thmt@sibling\endcsname
      \def\thmt@autoreffix{}%
    }%
    \protected@edef\thmt@sibling{\thmt@envname}%
  \fi
}
\g@addto@macro\thmt@newtheorem@predefinition{\thmt@autorefsetup}%
\g@addto@macro\thmt@newtheorem@postdefinition{\csname thmt@autoreffix\endcsname}%

\def\thmt@refnamewithcomma #1#2#3,#4,#5\@nil{%
  \@xa\def\csname\thmt@envname #1utorefname\endcsname{#3}%
  \ifcsname #2refname\endcsname
    \csname #2refname\endcsname{\thmt@envname}{#3}{#4}%
  \fi
}
\define@key{thmdef}{refname}{\thmt@trytwice{}{%
  \thmt@refnamewithcomma{a}{c}#1,\textbf{?? (pl. #1)},\@nil
}}
\define@key{thmdef}{Refname}{\thmt@trytwice{}{%
  \thmt@refnamewithcomma{A}{C}#1,\textbf{?? (pl. #1)},\@nil
}}

\ifcsname Autoref\endcsname\else
\let\thmt@HyRef@testreftype\HyRef@testreftype
\def\HyRef@Testreftype#1.#2\\{%
  \ltx@IfUndefined{#1Autorefname}{%
    \thmt@HyRef@testreftype#1.#2\\%
  }{%
    \edef\HyRef@currentHtag{%
      \expandafter\noexpand\csname#1Autorefname\endcsname
      \noexpand~%
    }%
  }%
}

\let\thmt@HyPsd@@autorefname\HyPsd@@autorefname
\def\HyPsd@@Autorefname#1.#2\@nil{%
  \tracingall
  \ltx@IfUndefined{#1Autorefname}{%
    \thmt@HyPsd@@autorefname#1.#2\@nil
  }{%
    \csname#1Autorefname\endcsname\space
  }%
}%
\def\Autoref{%
  \parse{%
  {\parseFlag*{\def\thmt@autorefstar{*}}{\let\thmt@autorefstar\@empty}}%
  {\parseMand{%
    \bgroup
    \let\HyRef@testreftype\HyRef@Testreftype
    \let\HyPsd@@autorefname\HyPsd@@Autorefname
    \@xa\autoref\thmt@autorefstar{##1}%
    \egroup
    \let\@parsecmd\@empty
  }}%
  }%
}
\fi % ifcsname Autoref

\AtBeginDocument{%
  \@ifpackageloaded{nameref}{%
    \addtotheorempostheadhook{%
      \expandafter\NR@gettitle\expandafter{\thmt@shortoptarg}%
  }}{}
}

\AtBeginDocument{%
  \@ifpackageloaded{cleveref}{%
    \@ifpackagelater{cleveref}{2010/04/30}{%
    % OK, new enough
    }{%
      \PackageWarningNoLine{thmtools}{%
        Your version of cleveref is too old!\MessageBreak
        Update to version 0.16.1 or later%
      }
    }
  }{}
}
\endinput
%%
%% End of file `thm-autoref.sty'.