| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2008-2014 by Ulrich M. Schwarz |
| 4 |
% Copyright (C) 2019 by Frank Mittelbach |
| 5 |
% Copyright (C) 2020- by Yukai Chou |
| 6 |
% |
| 7 |
% This file may be distributed and/or modified under the conditions of |
| 8 |
% the LaTeX Project Public License, version 1.3c. |
| 9 |
% The license can be obtained from |
| 10 |
% http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 11 |
% |
| 12 |
% \fi |
| 13 |
% |
| 14 |
%\iffalse (hide this from DocInput) |
| 15 |
%<*autoref> |
| 16 |
%\fi |
| 17 |
% |
| 18 |
% \pkg{hyperref}'s |\autoref| command does not work well with theorems that |
| 19 |
% share a counter: it'll always think it's a Lemma even if it's a Remark |
| 20 |
% that shares the Lemma counter. Load this package to fix it. No further |
| 21 |
% intervention needed. |
| 22 |
% |
| 23 |
%\StopEventually{} |
| 24 |
% \begin{macrocode} |
| 25 |
|
| 26 |
\RequirePackage{thm-patch, aliasctr, parseargs, keyval} |
| 27 |
|
| 28 |
\let\@xa=\expandafter |
| 29 |
\let\@nx=\noexpand |
| 30 |
|
| 31 |
\newcommand\thmt@autorefsetup{% |
| 32 |
\@xa\def\csname\thmt@envname autorefname\@xa\endcsname\@xa{\thmt@thmname}% |
| 33 |
\ifthmt@hassibling |
| 34 |
\@counteralias{\thmt@envname}{\thmt@sibling}% |
| 35 |
\@xa\def\@xa\thmt@autoreffix\@xa{% |
| 36 |
\@xa\global\@xa\let\csname the\thmt@envname\@xa\endcsname |
| 37 |
\csname the\thmt@sibling\endcsname |
| 38 |
\def\thmt@autoreffix{}% |
| 39 |
}% |
| 40 |
\protected@edef\thmt@sibling{\thmt@envname}% |
| 41 |
\fi |
| 42 |
} |
| 43 |
\g@addto@macro\thmt@newtheorem@predefinition{\thmt@autorefsetup}% |
| 44 |
\g@addto@macro\thmt@newtheorem@postdefinition{\csname thmt@autoreffix\endcsname}% |
| 45 |
|
| 46 |
\def\thmt@refnamewithcomma #1#2#3,#4,#5\@nil{% |
| 47 |
\@xa\def\csname\thmt@envname #1utorefname\endcsname{#3}% |
| 48 |
\ifcsname #2refname\endcsname |
| 49 |
\csname #2refname\@xa\endcsname\@xa{\thmt@envname}{#3}{#4}% |
| 50 |
\fi |
| 51 |
} |
| 52 |
\define@key{thmdef}{refname}{\thmt@trytwice{}{% |
| 53 |
\thmt@refnamewithcomma{a}{c}#1,\textbf{?? (pl. #1)},\@nil |
| 54 |
}} |
| 55 |
\define@key{thmdef}{Refname}{\thmt@trytwice{}{% |
| 56 |
\thmt@refnamewithcomma{A}{C}#1,\textbf{?? (pl. #1)},\@nil |
| 57 |
}} |
| 58 |
|
| 59 |
|
| 60 |
\ifcsname Autoref\endcsname\else |
| 61 |
\let\thmt@HyRef@testreftype\HyRef@testreftype |
| 62 |
\def\HyRef@Testreftype#1.#2\\{% |
| 63 |
\ltx@IfUndefined{#1Autorefname}{% |
| 64 |
\thmt@HyRef@testreftype#1.#2\\% |
| 65 |
}{% |
| 66 |
\edef\HyRef@currentHtag{% |
| 67 |
\expandafter\noexpand\csname#1Autorefname\endcsname |
| 68 |
\noexpand~% |
| 69 |
}% |
| 70 |
}% |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
\let\thmt@HyPsd@@autorefname\HyPsd@@autorefname |
| 75 |
\def\HyPsd@@Autorefname#1.#2\@nil{% |
| 76 |
\tracingall |
| 77 |
\ltx@IfUndefined{#1Autorefname}{% |
| 78 |
\thmt@HyPsd@@autorefname#1.#2\@nil |
| 79 |
}{% |
| 80 |
\csname#1Autorefname\endcsname\space |
| 81 |
}% |
| 82 |
}% |
| 83 |
\def\Autoref{% |
| 84 |
\parse{% |
| 85 |
{\parseFlag*{\def\thmt@autorefstar{*}}{\let\thmt@autorefstar\@empty}}% |
| 86 |
{\parseMand{% |
| 87 |
\bgroup |
| 88 |
\let\HyRef@testreftype\HyRef@Testreftype |
| 89 |
\let\HyPsd@@autorefname\HyPsd@@Autorefname |
| 90 |
\@xa\autoref\thmt@autorefstar{##1}% |
| 91 |
\egroup |
| 92 |
\let\@parsecmd\@empty |
| 93 |
}}% |
| 94 |
}% |
| 95 |
} |
| 96 |
\fi % ifcsname Autoref |
| 97 |
|
| 98 |
% not entirely appropriate here, but close enough: |
| 99 |
\AtBeginDocument{% |
| 100 |
\@ifpackageloaded{nameref}{% |
| 101 |
\addtotheorempostheadhook{% |
| 102 |
\expandafter\NR@gettitle\expandafter{\thmt@shortoptarg}% |
| 103 |
}}{} |
| 104 |
} |
| 105 |
|
| 106 |
\AtBeginDocument{% |
| 107 |
\@ifpackageloaded{cleveref}{% |
| 108 |
\@ifpackagelater{cleveref}{2010/04/30}{% |
| 109 |
% OK, new enough |
| 110 |
}{% |
| 111 |
\PackageWarningNoLine{thmtools}{% |
| 112 |
Your version of cleveref is too old!\MessageBreak |
| 113 |
Update to version 0.16.1 or later% |
| 114 |
} |
| 115 |
} |
| 116 |
}{} |
| 117 |
} |
| 118 |
% \end{macrocode} |
| 119 |
%\iffalse |
| 120 |
%</autoref> |
| 121 |
%\fi |