-
Notifications
You must be signed in to change notification settings - Fork 3
/
pathcontrol.tex
34 lines (34 loc) · 1.24 KB
/
pathcontrol.tex
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
%!TEX root = main.tex
%% Makes figures available within scope of exercise folder.
%% e.g. the exercise in exercises/ohmslaw/cone.tex only
%% have to write \input{cylfig} instead of \input{figs/ohmslaw/cone/cylfig}
\makeatletter
\xdef\figuresPath{\@figrootDir/}
\gdef\fileInputPath{}
%:§ref
%:=\thisfilepath
%: Contains the path to the exercisefile relative to the build file.
%: Useful for inputing files in the same directory as an exercisefile.
%:-
\gdef\thisfilepath{} %<- current exercise path
\gdef\fileInputBase{}
% \providecommand*{\tstcommand}{HELLO}
\@ifundefined{input@path}{\gdef\input@path{}}{}
\AtBeginDocument{%
\providecommand*{\input@path}{}
\providecommand*{\Ginput@path}{}
\g@addto@macro\input@path{{\fileInputBase}{\fileInputPath}}%
\g@addto@macro\Ginput@path{{\fileInputBase}{\fileInputPath}}%
}
\At\PathControl{
\makeatletter
\xdef\figuresPath{\@figrootDir/}
% Parse file and add \@figrootDir/path/to/directoryWithSameNameAsExerciseFile/
% and \@figrootDir/path/to/ to the input stream
\edef\exfile{\exerciseFile}
\expandafter\filename@parse{\exfile}
\xdef\thisfilepath{\@exercisesDir/\filename@area}
\xdef\fileInputPath{\figuresPath\filename@area}
\xdef\fileInputBase{\figuresPath\filename@area\filename@base/}
\makeatother
}