22.07.2013 Views

ntheorem.pdf. - Mirrors.med.harvard.edu

ntheorem.pdf. - Mirrors.med.harvard.edu

ntheorem.pdf. - Mirrors.med.harvard.edu

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Original syntax: \newlabel{〈label〉}{{〈section〉}{〈page〉}}<br />

Modified syntax: \newlabel{〈label〉} {{〈section〉}{〈page〉}}[〈type〉]<br />

Definition of \newlabel: \def\newlabel{\@newl@bel r}.<br />

Therefore, the modification is encoded into the \@newl@bel macro:<br />

221 \def\@newl@bel#1#2#3{%<br />

222 \@ifpackageloaded{babel}{\@safe@activestrue}\relax%<br />

223 \@ifundefined{#1@#2}%<br />

224 \relax<br />

225 {\gdef \@multiplelabels {%<br />

226 \@latex@warning@no@line{There were multiply-defined labels}}%<br />

227 \@latex@warning@no@line{Label ‘#2’ multiply defined}}%<br />

228 \global\@na<strong>med</strong>ef{#1@#2}{#3}%<br />

229 \@ifnextchar[{\set@label@type{#1}{#2}}%]<br />

230 \relax}%<br />

231 \def\set@label@type#1#2[#3]{%<br />

232 \global\@na<strong>med</strong>ef{#1@#2@type}{#3}}<br />

the macro is called with three arguments (same as originally):<br />

#1=r,<br />

〈labelname〉 := #2 is the label name,<br />

#3 is a pair (section, page-number) consisting of the values needed for \ref<br />

and \pageref, respectively.<br />

Line 222: adaptation to babel<br />

Lines 223–228: The original definition (both standard L ATEX and babel).<br />

Line 229: if an optional argument follows (containing the environment-type),<br />

continue with \set@label@type, otherwise return (the original behavior).<br />

Lines 231, 232: set \r@〈labelname〉@type to the type of the respective environment.<br />

\thref \thref is an adaptation of \ref:<br />

233 \def\thref#1{%<br />

234 \expandafter\ifx\csname r@#1@type\endcsname\None<br />

235 \PackageWarning{\basename}{thref: Reference Type of ‘#1’ on page<br />

236 \thepage \space undefined}\G@refundefinedtrue<br />

237 \else\csname r@#1@type\endcsname~\fi<br />

238 \expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}}<br />

Lines 233, 238: similar to \ref.<br />

Line 222: if a legal theorem type is given, then output \r@〈labelname〉@type<br />

and avoid linebreaking between the type and the number.<br />

\testdef A problem occurred, when about 250 labels to theorem-like environments<br />

have been defined: after the end of a document, the .aux file is read once<br />

more (to check if references changed). Here, L ATEX redefines \@newl@bel<br />

into \@testdef – and L ATEX does not know that <strong>ntheorem</strong>’s \label has an<br />

43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!