Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{amsart}
- usepackage{amsthm}
- usepackage{zref}% http://ctan.org/pkg/zref
- makeatletter
- letoldlabellabel
- renewcommand{label}[1]{%
- zref@labelbylist{#1}{special}% Special label
- oldlabel{#1}% Old label
- }
- newcounter{splabel}
- zref@newlist{special}% Create a new property list called special
- zref@newprop{section}{arabic{section}}% Section property holds arabic{section}
- zref@addprop{special}{section}% Add a section property to special
- newcommand*{thmref}[1]{%
- stepcounter{splabel}% Increment local "special label" counter
- zref@labelbylist{#1-thesplabel}{special}% Create label
- edeftargetsec{zref@extractdefault{#1}{section}{-1}}% Extract target section
- edefsourcesec{zref@extractdefault{#1-thesplabel}{section}{-1}}% Extract source section
- ifnumtargetsec=sourcesecelsetargetsec.fi%
- ref{#1}%
- }
- newtheorem{dummy}{***}[subsection]% Used so that theorems, definitions, etc can have same counter within subsections
- newtheorem{theorem}[dummy]{Theorem}
- newtheorem{lemma}[dummy]{Lemma}
- theoremstyle{definition}
- newtheorem{definition}[dummy]{Definition}
- newtheorem{remark}[dummy]{Remark}
- renewcommand{thesubsection}{arabic{subsection}}% Custom numbering on subsection to remove section number
- begin{document}
- section{First Section}
- subsection{First Subsection in Section 1}
- begin{definition}
- Good definition.
- end{definition}
- subsection{Second Subsection in Section 1}
- begin{remark}
- Interesting remark.
- end{remark}
- begin{lemma} label{lem:name}
- Useful lemma.
- end{lemma}
- subsection{Third subsection in Section 1}
- begin{theorem} label{thm:name}
- Important theorem.
- end{theorem}
- section{Section 2}
- subsection{Another subsection} There's not much to say here.
- subsection{Last Subsection}
- As you can see, Theorem thmref{thm:name} is very important. Indeed, Lemma~thmref{lem:name} was quite useful.
- end{document}
Add Comment
Please, Sign In to add comment