m17n-docs
[m17n/m17n-docs.git] / styles / xr-hyper.sty
1 %% xr package (beta release)
2
3 %% Copyright (C) 1993-1997 David Carlisle
4
5 %% This is a modified version of the xr package from the Standard LaTeX
6 %% tools distribution. It has some internal changes to cooperate with
7 %% the hyperref package, and one new user level argument, also mainly of
8 %% use for hyperref.
9 %% If no problems are reported the version in the tools distribution
10 %% will be updated to match this at the next LaTeX release.
11
12 %% \externaldocument[prefix]{document}[URL]
13
14 %% The `document' referred to by the main argument is the file
15 %% document.aux
16 %% which must be somewhere on TeX's input path.
17 %% Some packages (eg hyperref) really need to know the location of the
18 %% final document rather than the aux file. By default this is assumed
19 %% to be `document.dvi'. A package may redefine the command \XR@ext to
20 %% change this default extension (eg some of the hyperref backends
21 %% define this to be `document.pdf'). However sometimes the final
22 %% document may be in a position unrelated to the aux file, or the
23 %% browser may not be able to find files at an arbitrary point in
24 %% TeX's input path, so the new final optional argument allows a full
25 %% URL to the final document to be specified.
26 %%
27 %% \externaldocument{file}[http://here.xxx.edu/this/path/to/file.dvi]
28 %%
29 %% Unless a package redefines \XR@addfile, the optional URL argument
30 %% will be ignored.
31 %%
32 %% This version (beta2) also has another improvement unrelated
33 %% to the hyperref support. Olivier Michel pointed out that
34 %% if the aux file was not on texinputs you could not always go
35 %% \externaldocument{/some/path/to/file}
36 %% specifically that worked if file.aux was a `simple'  document with
37 %% one aux file, but if \include had been used, the `sub' aux files
38 %% would not be found by xr in the remote directory.
39 %% This version calls \filename@parse to get the directory name of the
40 %% remote directory, which is then explicitly prepended to the names of
41 %% any included aux files.
42 %%
43 %% History
44 %%
45 %% 1997/10/06 v6.00beta2
46 %%
47 %% 1999/09/01 v6.00beta3
48 %%   Definitions of \XR@addURL corrected (Heiko Oberdiek).
49 %%
50 %% 2000/03/22 v6.00beta4
51 %%   \xdef changed to \protected@xdef.
52 %%
53 \NeedsTeXFormat{LaTeX2e}
54 \ProvidesPackage{xr-hyper}
55          [2000/03/22 v6.00beta4 eXternal References (DPC)]
56
57 \def\externaldocument{\@testopt\XR@{}}
58 \def\XR@[#1]#2{\@testopt{\XR@@{#1}{#2}}{#2.\XR@ext}}
59
60 \def\XR@@#1#2[#3]{{%
61   \makeatletter
62   \def\XR@prefix{#1}%
63   \def\XR@URL{#3}%
64   \filename@parse{#2}%
65   \XR@next#2.aux\relax\\}}
66 \def\XR@next#1\relax#2\\{%
67   \edef\XR@list{#2}%
68   \XR@loop{#1}}
69 \def\XR@aux{%
70   \ifx\XR@list\@empty\else\expandafter\XR@explist\fi}
71
72 \def\XR@explist{\expandafter\XR@next\XR@list\\}
73 \def\XR@loop#1{%
74 \def\f{#1}%\show\f
75 \openin\@inputcheck#1\relax
76   \ifeof\@inputcheck
77     \PackageWarning{xr}{^^JNo file #1^^JLABELS NOT IMPORTED.^^J}%
78     \expandafter\XR@aux
79   \else
80     \PackageInfo{xr}{IMPORTING LABELS FROM #1}%
81     \expandafter\XR@read\fi}
82 \def\XR@read{%
83   \read\@inputcheck to\XR@line
84   \expandafter\XR@test\XR@line...\XR@}
85 \long\def\XR@test#1#2#3#4\XR@{%
86   \ifx#1\newlabel
87      \expandafter\protected@xdef\csname r@\XR@prefix#2\endcsname
88        {\XR@addURL{#3}}%
89   \else\ifx#1\@input
90      \edef\XR@list{\XR@list\filename@area#2\relax}%
91   \fi\fi
92   \ifeof\@inputcheck\expandafter\XR@aux
93   \else\expandafter\XR@read\fi}
94
95 \providecommand*{\XR@addURL}[1]{#1}
96 % The above definition doesn't actually use the URL, hyperref 6 could
97 % make a definition like so to put the URL in the fifth field of its
98 % ref structure.
99
100 \@ifpackageloaded{hyperref}{%
101   \PackageWarningNoLine{xr-hyper}{Load package `hyperref' after `xr-hyper'}%
102 }{}
103
104 %\def\XR@addURL#1{\XR@@dURL#1{}{}{}{}\\}
105
106 %\def\XR@@dURL#1#2#3#4#5\\{%
107 %  {#1}{#2}%
108 %  \if!#4!%
109 %  \else
110 %    {#3}{#4}{\XR@URL}%
111 %  \fi
112 %}
113
114 \providecommand\XR@ext{dvi}
115
116 \endinput
117 %%
118 %% End of file `xr.sty'.
119
120