blob: 8f4720f66df56d6e1cf361c78bb05e500932b292 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
%%
%% This is file `inversepath.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% inversepath.dtx (with options: `package')
%%
%% __________________________________
%% Copyright (C) 2007 Will Robertson
%%
%% License information appended.
%%
%%
\ProvidesPackage{inversepath}
[26/04/2007 v0.1 Inverse relative paths]
\newcommand\inversepath[1]{%
\let\ip@origjobpath\ip@jobpath
\let\ip@directpath\@empty
\let\ip@inversepath\@empty
\ip@strippath#1/\@nil/%
\let\ip@jobpath\ip@origjobpath
\ip@inversepath}
\newcommand\absolutepath[1]{\def\ip@jobpath{#1}}
\def\ip@literaldotdot{..}
\def\ip@strippath#1/#2/{%
\ifx\@nil#2\relax
\def\ip@lastelement{#1}%
\else
\edef\ip@directpath{\ip@directpath#1/}
\def\@tempa{#1}%
\ifx\@tempa\ip@literaldotdot
\unless\ifdefined\ip@jobpath
\PackageError{inversepath}
{No absolute path specified}
{You must declare the file path of the main
file with \protect\absolutepath{} to be able to
resolve back-relative paths}%
\fi
\let\ip@olddirectpath\ip@directpath
\let\ip@oldinversepath\ip@inversepath
\let\ip@directpath\@empty
\let\ip@inversepath\@empty
\expandafter\ip@strippath\ip@jobpath\@nil/
\let\@tempa\ip@lastelement
\let\ip@jobpath\ip@directpath
\let\ip@directpath\ip@olddirectpath
\let\ip@inversepath\ip@oldinversepath
\ifx\@tempa\@empty
\PackageError{inversepath}
{Absolute path too shallow to resolve
such a deep relative path}
{You're trying to go back more directories than you have!}
\fi
\edef\ip@inversepath{\@tempa/\ip@inversepath}%
\else
\edef\ip@inversepath{../\ip@inversepath}%
\fi
\def\@tempa{\ip@strippath#2/}%
\expandafter\@tempa
\fi}
%%
%% Copyright (C) 2006 by Will Robertson <wspr81@gmail.com>
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status)
%% by Will Robertson.
%%
%% This work consists of the file inversepath.dtx
%% and the derived files inversepath.sty and inversepath.pdf.
%%
%%
%% End of file `inversepath.sty'.
|