-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetClassPath.tex
More file actions
90 lines (83 loc) · 2.43 KB
/
getClassPath.tex
File metadata and controls
90 lines (83 loc) · 2.43 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
% !TeX spellcheck = fr-CA
% !TeX encoding = UTF-8
% !TeX engine = pdflatex
% !TeX enableShellEscape = true
\documentclass{article}
\makeatletter
\def\thepwd@default{./}
\let\thepwd\thepwd@default
\let\theclasspath\@empty
\def\@getcl@ss#1.cls#2\relax{\def\@currentclass{#1}}
\def\@getclass{\expandafter\@getcl@ss\@filelist\relax}
\newcommand\getclasspath{%
\begingroup
\@getclass
\edef\filename{\@currentclass.cls}%
\@onelevel@sanitize\filename%
\let\thepwd\thepwd@default
\let\theclasspath\@empty
\IfFileExists{\jobname.fls}{%
\openin\@inputcheck=\jobname.fls\relax
\endlinechar\m@ne
\readline\@inputcheck to \line
\expandafter\getclasspath@extr\line\relax\relax\relax\relax\relax
\expandafter\getclasspath@defs\expandafter{\filename}%
\loop
\readline\@inputcheck to \line
\@onelevel@sanitize\line
\expandafter\getclasspath@path\expandafter{\line}%
\ifeof\@inputcheck
\let\iterate\relax
\fi
\ifx\theclasspath\@empty
\repeat
\closein\@inputcheck
}{%
\PackageWarning{getclasspath}
{The required recorder file (.fls) was not found.\MessageBreak
Please compile with the '-recorder' option.\MessageBreak
Occurred}%
}%
\ifx\theclasspath\@empty
\let\theclasspath\thepwd
\fi
\edef\@tempa{%
\def\noexpand\thepwd{\thepwd}%
\def\noexpand\theclasspath{\theclasspath}%
}%
\expandafter
\endgroup
\@tempa
}
\def\getclasspath@extr#1#2#3#4#5\relax{%
\edef\@tempa{\detokenize{#1#2#3}}%
\edef\@tempb{\detokenize{PWD}}%
\ifx\@tempa\@tempb
\edef\thepwd{\detokenize{#4#5/}}%
\fi
}
\begingroup
\catcode`I=12
\catcode`N=12
\catcode`P=12
\catcode`U=12
\catcode`T=12
\gdef\getclasspath@defs#1{%
\def\getclasspath@@path ##1INPUT ##2#1\relax##3\relax##4\@nnil{%
\ifx\@empty##4\@empty\else
\def\theclasspath{##2}%
\fi
}%
\def\getclasspath@path##1{%
\getclasspath@@path##1\relax INPUT \@empty#1\relax{}\relax\@nnil
}%
}
\endgroup
\makeatother
\getclasspath
\message{Class path: \theclasspath^^J}
\begin{document}
The absolute path to the document class \newline \texttt{\theclasspath}.
\end{document}
% https://tex.stackexchange.com/questions/42417/full-path-of-current-file
% https://tex.stackexchange.com/questions/73/which-document-class-is-being-used