Debian Codegraph @

texmf-dist/doc/latex/varsfromjobname/varsfromjobname.tex

raw
1 \documentclass[12pt]{scrartcl}
2 \usepackage{url}
3 \usepackage{listings}
4 \nofiles
5
6 \usepackage{varsfromjobname}
7 \usepackage[default]{sourcesanspro}
8 \setlength{\parskip}{1em}
9 \setlength{\parindent}{0em}
10 \usepackage[left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}
11
12
13 \date{August 3rd, 2025 }
14 \author{Uwe Ziegenhagen, [email protected]}
15 \title{The varsfromjobname Package}
16 \subtitle{Version 1.1}
17
18
19
20 \begin{document}
21 \maketitle
22
23
24
25 \textbf{What is this package good for?}
26
27 \noindent Using \texttt{varsfromjobname.sty} one can easily extract information from the filename.
28
29 How does it work?
30
31 The LaTeX command \verb|\|jobname returns the name of the LaTeX main job file. \verb|\|currfile from the \texttt{currfile} package does the same for files which have been included into a document with \verb|\|input or \verb|\|include.
32
33 If the filename consists of tokens/words separated by hyphen we can easily extract specific tokens and use them in the document, e.\,g. to include documents, images, etc. dynamically.
34
35 The package expects the filename to be of the form
36
37 \noindent\texttt{one-two-three-four-five-six-seven-eight-nine.tex}
38
39 \noindent and offers the following commands:
40
41 \begin{itemize}
42 \item \verb|\getfromjobname|\{\textit{param}\}, with \textit{param} an integer. In the \LaTeX2e\ version the integer was in the range of 1 to 9, with expl3 programming this limit does not exist anymore.
43
44 \end{itemize}
45
46 Some short-cut commands have been added for convenience, which do not require a parameter:
47
48 \begin{itemize}
49 \item \verb|\getonefromjobname|
50 \item \verb|\gettwofromjobname|
51 \item \verb|\getthreefromjobname|
52 \item \verb|\getfourfromjobname|
53 \item \verb|\getfivefromjobname|
54 \item \verb|\getsixfromjobname|
55 \item \verb|\getsevenfromjobname|
56 \item \verb|\geteightfromjobname|
57 \item \verb|\getninefromjobname|
58 \end{itemize}
59
60 For included or inputted documents the package uses the \texttt{currfile} package by Martin Scharrer, see \url{https://ctan.org/pkg/currfile}, to provide the following commands:
61
62 \begin{itemize}
63 \item \verb|\getfromcurrfilename|\{\textit{param}\}, with \textit{param} in the
64 range of $1$ to $n$ (highlevel interface to the following commands)
65 \item \verb|\getonefromcurrfilename|
66 \item \verb|\gettwofromcurrfilename|
67 \item \verb|\getthreefromcurrfilename|
68 \item \verb|\getfourfromcurrfilename|
69 \item \verb|\getfivefromcurrfilename|
70 \item \verb|\getsixfromcurrfilename|
71 \item \verb|\getsevenfromcurrfilename|
72 \item \verb|\geteightfromcurrfilename|
73 \item \verb|\getninefromcurrfilename|
74 \end{itemize}
75
76 \section*{Example}
77
78 Place the code from Listing 1 in a file \textbf{a-b-c-d-e-f-g-h-i-j.tex} and the code from
79 Listing~2 in a file named \textbf{z-y-x-w-v-u-t-s-r-q.tex}. Then compile the first file with pdflatex.
80
81 \begin{lstlisting}[caption={\textbf{a-b-c-d-e-f-g-h-i-j.tex}, result and command}]
82 % testfiles for varsfromjobname.sty
83 \documentclass{article}
84 \listfiles
85 \usepackage[utf8]{inputenc}
86 \usepackage[T1]{fontenc}
87 \usepackage{varsfromjobname}
88 \begin{document}
89
90 a: \getonefromjobname % a
91
92 b: \gettwofromjobname % b
93
94 c: \getthreefromjobname % c
95
96 d: \getfourfromjobname % d
97
98 e: \getfivefromjobname % e
99
100 f: \getsixfromjobname % f
101
102 g: \getsevenfromjobname % g
103
104 h: \geteightfromjobname %h
105
106 i-j: \getninefromjobname % i, i-j in Version 1.0 of the package
107
108 a: \getfromjobname{1} % a
109
110 b: \getfromjobname{2} % b
111
112 c: \getfromjobname{3} % c
113
114 d: \getfromjobname{4} % d
115
116 e: \getfromjobname{5} % e
117
118 f: \getfromjobname{6} % f
119
120 g: \getfromjobname{7} % g
121
122 h: \getfromjobname{8} % h
123
124 i: \getfromjobname{9} % i, in Version 1.0 of the package
125
126 \input{z-y-x-w-v-u-t-s-r-q}
127
128 \end{document}
129 \end{lstlisting}
130
131
132
133
134 \begin{lstlisting}[caption={\textbf{z-y-x-w-v-u-t-s-r-q.tex}, result and command}]
135 z: \getonefromcurrfilename
136
137 y: \gettwofromcurrfilename
138
139 x: \getthreefromcurrfilename
140
141 w: \getfourfromcurrfilename
142
143 v: \getfivefromcurrfilename
144
145 u: \getsixfromcurrfilename
146
147 t: \getsevenfromcurrfilename
148
149 s: \geteightfromcurrfilename
150
151 r: \getninefromcurrfilename % r-q in Version 1.0 of the package
152 \end{lstlisting}
153
154
155 \section*{Change History}
156
157 \begin{description}
158 \item [Version 0.5] as of January 11th 2009: Initial version published
159 \item [Version 1.0] published May 2017:
160 Added various commands which extract necessary information also from included documents
161 Modified code as suggested by egreg
162 \item [Version 1.1] published August 2025: switched to expl3 syntax, allowing more than nine tokens with a cleaner syntax
163 \end{description}
164
165
166 \vfill 2025-08-02, Uwe Ziegenhagen
167
168 \end{document}