\documentclass[12pt]{scrartcl}
\usepackage{url}
\usepackage{listings}
\nofiles

\usepackage{varsfromjobname}
\usepackage[default]{sourcesanspro}
\setlength{\parskip}{1em}
\setlength{\parindent}{0em}
\usepackage[left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}


\date{August 3rd, 2025 }
\author{Uwe Ziegenhagen, ziegenhagen@gmail.com}
\title{The varsfromjobname Package}
\subtitle{Version 1.1}



\begin{document}
\maketitle



\textbf{What is this package good for?}

\noindent Using \texttt{varsfromjobname.sty} one can easily extract information from the filename.

How does it work?

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.

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.

The package expects the filename to be of the form 

\noindent\texttt{one-two-three-four-five-six-seven-eight-nine.tex} 

\noindent and offers the following commands:

\begin{itemize}
	\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.

\end{itemize}

Some short-cut commands have been added for convenience, which do not require a parameter:

\begin{itemize}
	\item \verb|\getonefromjobname|
	\item \verb|\gettwofromjobname|
	\item \verb|\getthreefromjobname|
	\item \verb|\getfourfromjobname|
	\item \verb|\getfivefromjobname|
	\item \verb|\getsixfromjobname|
	\item \verb|\getsevenfromjobname|
	\item \verb|\geteightfromjobname|
	\item \verb|\getninefromjobname|	
\end{itemize}

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: 

\begin{itemize}
	\item \verb|\getfromcurrfilename|\{\textit{param}\}, with \textit{param} in the
	 range of $1$ to $n$ (highlevel interface to the following commands)
	\item \verb|\getonefromcurrfilename|
	\item \verb|\gettwofromcurrfilename|
	\item \verb|\getthreefromcurrfilename|
	\item \verb|\getfourfromcurrfilename|
	\item \verb|\getfivefromcurrfilename|
	\item \verb|\getsixfromcurrfilename|
	\item \verb|\getsevenfromcurrfilename|
	\item \verb|\geteightfromcurrfilename|
	\item \verb|\getninefromcurrfilename|	
\end{itemize}

\section*{Example}

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
 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.

\begin{lstlisting}[caption={\textbf{a-b-c-d-e-f-g-h-i-j.tex}, result and command}]
% testfiles for varsfromjobname.sty
\documentclass{article}
\listfiles
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{varsfromjobname}
\begin{document}

a: \getonefromjobname % a

b: \gettwofromjobname % b

c: \getthreefromjobname % c

d: \getfourfromjobname % d

e: \getfivefromjobname % e

f: \getsixfromjobname % f 

g: \getsevenfromjobname % g

h: \geteightfromjobname %h 

i-j: \getninefromjobname % i, i-j in Version 1.0 of the package

a: \getfromjobname{1} % a

b: \getfromjobname{2} % b 

c: \getfromjobname{3} % c

d: \getfromjobname{4} % d

e: \getfromjobname{5} % e

f: \getfromjobname{6} % f

g: \getfromjobname{7} % g 

h: \getfromjobname{8} % h

i: \getfromjobname{9} % i, in Version 1.0 of the package

\input{z-y-x-w-v-u-t-s-r-q}

\end{document}
\end{lstlisting}




\begin{lstlisting}[caption={\textbf{z-y-x-w-v-u-t-s-r-q.tex}, result and command}]
z: \getonefromcurrfilename

y: \gettwofromcurrfilename

x: \getthreefromcurrfilename

w: \getfourfromcurrfilename

v: \getfivefromcurrfilename

u: \getsixfromcurrfilename

t: \getsevenfromcurrfilename

s: \geteightfromcurrfilename

r: \getninefromcurrfilename % r-q in Version 1.0 of the package
\end{lstlisting}


\section*{Change History}

\begin{description}
	\item [Version 0.5] as of January 11th 2009: Initial version published
	\item [Version 1.0] published May 2017:
        Added various commands which extract necessary information also from included documents
        Modified code as suggested by egreg
     \item [Version 1.1] published August 2025: switched to expl3 syntax, allowing more than nine tokens with a cleaner syntax
\end{description}

    
\vfill 2025-08-02, Uwe Ziegenhagen

\end{document}
