summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/varsfromjobname/varsfromjobname.sty
blob: 57893a1f394050f9fdb769ecc75e61666318a6bd (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
%begin of varsfromjobname.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{varsfromjobname}[2017/05/07 v. 1.0 extracts tokens from jobname]
\RequirePackage{ifthen}
\RequirePackage{currfile}

% Author: Uwe Ziegenhagen
% based on code supplied by Friedrich Vosberg and Markus Kohm
% help by Rolf Niepraschk and Sven Naumann, Ulrich Schwarz 
% and Andreas Mathias was greatly appreciated
% see posting <3983639.NRU96H2Y1Y@ID-107054.user.dfncis.de>
% requires the filename to be of the following form
% itemone-itemtwo-itemthree- ... -itemnine.tex

\makeatletter

\newcommand*{\getonefromjobname}{%
  \expandafter\@getonefromfilename\jobname--------\@nil%
}

\newcommand*{\gettwofromjobname}{%
  \expandafter\@gettwofromfilename\jobname--------\@nil%
}

\newcommand*{\getthreefromjobname}{%
  \expandafter\@getthreefromfilename\jobname--------\@nil%
}

\newcommand*{\getfourfromjobname}{%
  \expandafter\@getfourfromfilename\jobname--------\@nil%
}

\newcommand*{\getfivefromjobname}{%
  \expandafter\@getfivefromfilename\jobname--------\@nil%
}

\newcommand*{\getsixfromjobname}{%
  \expandafter\@getsixfromfilename\jobname--------\@nil%
}

\newcommand*{\getsevenfromjobname}{%
  \expandafter\@getsevenfromfilename\jobname--------\@nil%
}

\newcommand*{\geteightfromjobname}{%
  \expandafter\@geteightfromfilename\jobname--------\@nil%
}

\newcommand*{\getninefromjobname}{%
  \expandafter\@getninefromfilename\jobname\@nil%
}

\newcommand*\@getonefromfilename{}
\def\@getonefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#1%
}

\newcommand*\@gettwofromfilename{}
\def\@gettwofromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#2%
}

\newcommand*\@getthreefromfilename{}
\def\@getthreefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#3%
}

\newcommand*\@getfourfromfilename{}
\def\@getfourfromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#4%
}

\newcommand*\@getfivefromfilename{}
\def\@getfivefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#5%
}

\newcommand*\@getsixfromfilename{}
\def\@getsixfromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#6%
}

\newcommand*\@getsevenfromfilename{}
\def\@getsevenfromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#7%
}

\newcommand*\@geteightfromfilename{}
\def\@geteightfromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#8%
}

\newcommand*\@getninefromfilename{}
\def\@getninefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
#9%
}

% as proposed by egreg, 
% https://tex.stackexchange.com/questions/212169/qr-code-from-jobname
\newcommand{\getfromjobname}[1]{%
  \ifcase#1 \or%
    \getonefromjobname\or%
    \gettwofromjobname\or%
    \getthreefromjobname\or%
    \getfourfromjobname\or%
    \getfivefromjobname\or%
    \getsixfromjobname\or%
    \getsevenfromjobname\or%
    \geteightfromjobname\or%
    \getninefromjobname%
  \fi%
}

% for the currfilebase version

\newcommand*{\getonefromcurrfilename}{%
  \expandafter\@getonefromfilename\currfilebase--------\@nil%
}

\newcommand*{\gettwofromcurrfilename}{%
  \expandafter\@gettwofromfilename\currfilebase--------\@nil%
}

\newcommand*{\getthreefromcurrfilename}{%
  \expandafter\@getthreefromfilename\currfilebase--------\@nil%
}

\newcommand*{\getfourfromcurrfilename}{%
  \expandafter\@getfourfromfilename\currfilebase--------\@nil%
}

\newcommand*{\getfivefromcurrfilename}{%
  \expandafter\@getfivefromfilename\currfilebase--------\@nil%
}

\newcommand*{\getsixfromcurrfilename}{%
  \expandafter\@getsixfromfilename\currfilebase--------\@nil%
}

\newcommand*{\getsevenfromcurrfilename}{%
  \expandafter\@getsevenfromfilename\currfilebase--------\@nil%
}

\newcommand*{\geteightfromcurrfilename}{%
  \expandafter\@geteightfromfilename\currfilebase--------\@nil%
}

\newcommand*{\getninefromcurrfilename}{%
  \expandafter\@getninefromfilename\currfilebase\@nil%
}

\newcommand{\getfromcurrfilename}[1]{%
  \ifcase#1 \or%
    \getonefromcurrfilename\or%
    \gettwofromcurrfilename\or%
    \getthreefromcurrfilename\or%
    \getfourfromcurrfilename\or%
    \getfivefromcurrfilename\or%
    \getsixfromcurrfilename\or%
    \getsevenfromcurrfilename\or%
    \geteightfromcurrfilename\or%
    \getninefromcurrfilename%
  \fi%
}

\makeatother
% end of jobdate.sty