summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-05-22 23:12:35 +0000
committerKarl Berry <karl@freefriends.org>2013-05-22 23:12:35 +0000
commitfcb85af9df475453dec233df300e23d07c20205a (patch)
treece40d838f2e44da9065ca0f5d24e109122e0b149 /Master/texmf-dist/tex
parent8720829c9cba68ab04a8d8e4f0e6e0fd31cabed7 (diff)
theoremref (22may13)
git-svn-id: svn://tug.org/texlive/trunk@30640 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/theoremref/theoremref.sty64
1 files changed, 52 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/latex/theoremref/theoremref.sty b/Master/texmf-dist/tex/latex/theoremref/theoremref.sty
index aac31ecd9b3..c7d56e3f6aa 100644
--- a/Master/texmf-dist/tex/latex/theoremref/theoremref.sty
+++ b/Master/texmf-dist/tex/latex/theoremref/theoremref.sty
@@ -1,12 +1,12 @@
% see the bottom of the file for a description and usage notes
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{theoremref}
- [2008/05/13 References with automatic theorem names]
+ [2013/05/22 References with automatic theorem names]
+\def\thmref@lc#1{#1}
\DeclareOption{lowercase}{\let\thmref@lc\lowercase}
\DeclareOption{reftex}
- {\renewcommand\th[1]{\csname th\expandafter\@gobble\string#1\endcsname}}
-\def\thmref@lc#1{#1}
+ {\def\thmref@th#1{\csname th\expandafter\@gobble\string#1\endcsname}}
\ProcessOptions\relax
%hook in \@thm to get the name
@@ -14,10 +14,12 @@
\thmref@oldthm{#1}{#2}}
\def\thmref@amsthm#1#2#3{\thmref@lc{\def\thmref@currname{#3}}%
\thmref@oldthm{#1}{#2}{#3}}
-\def\thmref@setup{\let\thmref@oldthm\@thm
- \@ifpackageloaded{amsthm}{\let\@thm\thmref@amsthm}%
- {\let\@thm\thmref@newthm}}
-\AtBeginDocument{\thmref@setup}
+
+%\let\thnameref\pageref fails miserably when the ref is undefined
+\DeclareRobustCommand\thnameref[1]
+ {\expandafter\thmref@setref\csname r@#1\endcsname}
+\def\thmref@setref#1{\ifx#1\relax?THM?\else\expandafter\@secondoftwo#1\fi}
+\def\thmref@sethyp#1{\ifx#1\relax?THM?\else\expandafter\@secondoffive#1\fi}
%hacked version of \label from the kernel
\DeclareRobustCommand\thlabel[1]{\@bsphack
@@ -25,10 +27,26 @@
{\string\newlabel{#1}{{\@currentlabel}{\thmref@currname}}}%
\@esphack}
-%\let\thnameref\pageref fails miserably when the ref is undefined
-\DeclareRobustCommand\thnameref[1]
- {\expandafter\thmref@setref\csname r@#1\endcsname}
-\def\thmref@setref#1{\ifx#1\relax?THM?\else\expandafter\@secondoftwo#1\fi}
+%... or from hyperref/nameref.sty
+\def\thlabel@hyperref#1{%
+ \@bsphack
+ \begingroup
+ \let\label\@gobble
+ \def\ref{\protect\ref}%
+ \edef\@currentlabstr{%
+ \expandafter\strip@prefix\meaning\@currentlabelname
+ }%
+ \protected@write\@auxout{}{%
+ \string\newlabel{#1}{%
+ {\@currentlabel}%
+ {\thmref@currname}% <--
+ {\expandafter\strip@period\@currentlabstr\relax.\relax\@@@}%
+ {\@currentHref}{}%
+ }%
+ }%
+ \endgroup
+ \@esphack
+}
\newif\ifthmref@comma \newif\ifthmref@final \newcount\thmref@num
\DeclareRobustCommand\thref[1]{\let\thmref@last\empty \let\thmref@stack\empty
@@ -52,6 +70,18 @@
\def\thmref@one#1{\ifnum\thmref@num>0,\fi
\space$\ref{#1}$\advance\thmref@num 1\relax}
+\AtBeginDocument{\thmref@setup}
+\def\thmref@setup{%
+ \let\thmref@oldthm\@thm
+ \@ifpackageloaded{amsthm}{\let\@thm\thmref@amsthm}%
+ {\let\@thm\thmref@newthm}%
+ \@ifpackageloaded{hyperref}{%
+ \expandafter\let\csname thlabel\space\endcsname\thlabel@hyperref
+ \let\thmref@setref\thmref@sethyp
+ }\relax
+ \ifx\thmref@th\@undefined\else\let\th\thmref@th\fi%
+}
+
\endinput
package: theoremref
@@ -158,13 +188,23 @@ CAVEATS
``amsthm'' packages, as well as the default theorem system in base
LaTeX. It may fail for other theorem-like packages.
+ The package is compatible with ``hyperref'', but not with other
+ packages that change the syntax of ``\newlabel'' commands written
+ to the aux file.
+
+
+HISTORY
+
+2008-05-13: Initial public release.
+2013-05-22: Added support for hyperref.
+
LICENSE
The theoremref package is dually licensed under GPL or LPPL at your
option:
-Copyright (C) 2008 Emil Je\v{r}\'abek
+Copyright (C) 2008, 2013 Emil Je\v{r}\'abek
This package may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3