*** empty log message ***
[m17n/m17n-docs.git] / styles / nameref.sty
1 %%
2 %% This is file `nameref.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% nameref.dtx  (with options: `package')
8 %% 
9 \def\filedate{2001/01/27}
10 \def\fileversion{2.19}
11 %% This file is part of the `Hyperref Bundle'.
12 %% -------------------------------------------
13 %%
14 %% It may be distributed under the conditions of the LaTeX Project Public
15 %% License, either version 1.2 of this license or (at your option) any
16 %% later version.  The latest version of this license is in
17 %%    http://www.latex-project.org/lppl.txt
18 %% and version 1.2 or later is part of all distributions of LaTeX
19 %% version 1999/12/01 or later.
20 %%
21 %% The list of all files belonging to the `Hyperref Bundle' is
22 %% given in the file `manifest.txt'.
23 \ProvidesPackage{nameref}[\filedate\space v\fileversion
24   \space Cross-referencing by name of section]
25 \def\strip@period#1.\relax#2\@@@{#1}
26 \newif\ifNR@showkeys
27 \NR@showkeysfalse
28 \@ifpackageloaded{showkeys}{%
29   \begingroup
30     \@ifundefined{SK@@label}{%
31     }{%
32       \global\NR@showkeystrue
33     }%
34   \endgroup
35 }{}
36 \def\label#1{%
37   \@bsphack
38   \begingroup
39     \let\label\@gobble
40     \def\ref{\protect\ref}%
41     \edef\@currentlabstr{%
42       \expandafter\strip@prefix\meaning\@currentlabelname
43     }%
44     \protected@write\@auxout{}{%
45       \string\newlabel{#1}{%
46         {\@currentlabel}%
47         {\thepage}%
48         {\expandafter\strip@period\@currentlabstr\relax.\relax\@@@}%
49         {\@currentHref}{}%
50       }%
51     }%
52   \endgroup
53   \@esphack
54 }%
55 \ifNR@showkeys
56   \def\label#1{%
57     \@bsphack
58     \SK@\SK@@label{#1}%
59     \begingroup
60       \let\label\@gobble
61       \def\ref{\protect\ref}%
62       \edef\@currentlabstr{%
63         \expandafter\strip@prefix\meaning\@currentlabelname
64       }%
65       \protected@write\@auxout{}{%
66         \string\newlabel{#1}{%
67           {\@currentlabel}%
68           {\thepage}%
69           {\expandafter\strip@period\@currentlabstr\relax.\relax\@@@}%
70           {\@currentHref}{}%
71         }%
72       }%
73     \endgroup
74     \@esphack
75   }%
76 \fi
77 \let\ltx@label\label
78 \@ifundefined{slabel}{}{%
79   \def\slabel#1{%
80     \@bsphack
81     \if@filesw
82       {%
83         \let\label\@gobble
84         \def\ref{\protect\ref}%
85         \edef\@currentlabstr{%
86           \expandafter\strip@prefix\meaning\@currentlabelname
87         }%
88         \let\thepage\relax
89         \def\protect{\noexpand\noexpand\noexpand}%
90         \edef\@tempa{%
91           \write\@auxout{%
92             \string\newlabel{#1}{%
93               {\thesubequation}%
94               {\thepage}%
95               {\expandafter\strip@period
96                 \@currentlabstr\relax.\relax\@@@}%
97               {\@currentHref}{}%
98             }%
99           }%
100         }%
101         \expandafter
102       }%
103       \@tempa
104       \if@nobreak\ifvmode\nobreak\fi\fi
105     \fi
106     \@esphack
107   }%
108 }
109 \def\@writetocindents@{%
110   \begingroup
111   \@for\@tempa:=-1,0,1,2,3\do{%
112     \immediate\write\@auxout{%
113       \string\newlabel{tocindent\@tempa}{%
114         \csname r@tocindent\@tempa\endcsname{}{}{}{}%
115       }%
116     }%
117   }%
118   \endgroup}
119 \let\NR@sect\@sect
120 \newcounter{section@level}
121 \def\@sect#1#2#3#4#5#6[#7]#8{%
122   \setcounter{section@level}{#2}%
123   \def\@currentlabelname{#7}%
124   \NR@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{\Sectionformat{#8}{#2}}%
125 }
126 \let\NR@ssect\@ssect
127 \def\@ssect#1#2#3#4#5{%
128   \def\@currentlabelname{#5}%
129   \NR@ssect{#1}{#2}{#3}{#4}{\Sectionformat{#5}{#1}}%
130 }
131 \let\NR@part\@part
132 \def\@part[#1]#2{%
133   \def\@currentlabelname{#1}%
134   \NR@part[{#1}]{#2}%
135 }
136 \let\NR@chapter\@chapter
137 \def\@chapter[#1]#2{%
138   \def\@currentlabelname{#1}%
139   \NR@chapter[{#1}]{#2}%
140 }
141 \let\NR@schapter\@schapter
142 \def\@schapter#1{%
143   \def\@currentlabelname{#1}%
144   \NR@schapter{#1}%
145 }
146 \def\@currentlabelname{}
147 \def\@currentHref{}
148 \long\def\@firstoffive#1#2#3#4#5{#1}
149 \long\def\@secondoffive#1#2#3#4#5{#2}
150 \long\def\@thirdoffive#1#2#3#4#5{#3}
151 \long\def\@fourthoffive#1#2#3#4#5{#4}
152 \long\def\@fifthoffive#1#2#3#4#5{#5}
153 \providecommand*\@safe@activestrue{}%
154 \providecommand*\@safe@activesfalse{}%
155 \def\T@ref#1{%
156   \@safe@activestrue
157   \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}%
158   \@safe@activesfalse
159 }%
160 \def\T@pageref#1{%
161   \@safe@activestrue
162   \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}%
163   \@safe@activesfalse
164 }%
165 \ifNR@showkeys
166   \ifx\SK@ref\@empty
167   \else
168     \def\T@ref#1{%
169       \@safe@activestrue
170       \SK@\SK@@ref{#1}%
171       \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}%
172       \@safe@activesfalse
173     }%
174     \def\T@pageref#1{%
175       \@safe@activestrue
176       \SK@\SK@@ref{#1}%
177       \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}%
178       \@safe@activesfalse
179     }%
180   \fi
181 \fi
182 \providecommand\ref{\protect\T@ref}
183 \providecommand\pageref{\protect\T@pageref}
184 \def\T@nameref#1{%
185   \@safe@activestrue
186   \expandafter\@setref\csname r@#1\endcsname\@thirdoffive{#1}%
187   \@safe@activesfalse
188 }%
189 \ifNR@showkeys
190   \ifx\SK@ref\@empty
191   \else
192     \def\T@nameref#1{%
193       \@safe@activestrue
194       \SK@\SK@@ref{#1}%
195       \expandafter\@setref\csname r@#1\endcsname\@thirdoffive{#1}%
196       \@safe@activesfalse
197     }%
198   \fi
199 \fi
200 \def\nameref{\protect\T@nameref}
201 \def\Nameref#1{`\nameref{#1}' on page~\pageref{#1}}
202 \providecommand\Sectionformat[2]{#1}
203 \ifx\csname @@vpageref\endcsname\relax
204 \else
205   \def\@@vpageref#1[#2]#3{%
206     \leavevmode\unskip
207     \global\advance\c@vrcnt\@ne
208     \@ifundefined{r@\the\c@vrcnt @vr}%
209       {\@namedef{r@\the\c@vrcnt @vr}{{??}{??}{??}{??}{??}}}{}%
210     \edef\@tempa{%
211       \expandafter\expandafter\expandafter
212       \@secondoffive\csname r@\the\c@vrcnt @vr\endcsname
213     }%
214     \@ifundefined{r@\the\c@vrcnt @xvr}%
215       {\@namedef{r@\the\c@vrcnt @xvr}{{??}{??}{??}{??}{??}}}{}%
216     \edef\@tempb{%
217       \expandafter\expandafter\expandafter
218       \@secondoffive\csname r@\the\c@vrcnt @xvr\endcsname
219     }%
220     {%
221       \let\@currentlabel\@empty
222       \expandafter\label\expandafter{\the\c@vrcnt @xvr}%
223     }%
224     \ifx\@tempa\@tempb
225     \else
226       \vref@err{%
227         \noexpand\vref at page boundary
228         \@tempb-\@tempa\space (may loop)%
229       }%
230     \fi
231     \@ifundefined{r@#3}{\@namedef{r@#3}{{??}{??}{??}{??}{??}}}{}%
232     \edef\@tempb{%
233       \expandafter\expandafter\expandafter
234       \@secondoffive\csname r@#3\endcsname
235     }%
236     \space
237     \ifx\@tempa\@tempb
238       #1%
239     \else
240       #2%
241       \is@pos@number\@tempb{%
242         \is@pos@number\@tempa{%
243           \@tempcnta\@tempa
244           \advance\@tempcnta\@ne
245         }{%
246           \@tempcnta\maxdimen
247         }%
248         \ifnum \@tempb =\@tempcnta
249           \ifodd\@tempcnta
250             \if@twoside
251               \reftextfaceafter
252             \else
253               \reftextafter
254             \fi
255           \else
256             \reftextafter
257           \fi
258         \else
259           \advance\@tempcnta-2
260           \ifnum \@tempb =\@tempcnta
261             \ifodd\@tempcnta
262               \reftextbefore
263             \else
264               \if@twoside
265                 \reftextfacebefore
266               \else
267                 \reftextbefore
268               \fi
269             \fi
270           \else
271             \reftextfaraway{#3}%
272           \fi
273         \fi
274       }{%
275         \reftextfaraway{#3}%
276       }%
277     \fi
278     {%
279       \let\@currentlabel\@empty
280       \expandafter\label\expandafter{\the\c@vrcnt @vr}%
281     }%
282   }%
283   \DeclareRobustCommand\vnameref[1]{%
284     \unskip~\nameref{#1}%
285     \@vpageref[\unskip]{#1}%
286   }
287 \fi
288 \endinput
289 %%
290 %% End of file `nameref.sty'.