texlive[75959] Master/texmf-dist: varsfromjobname (3aug25)

commits+karl at tug.org commits+karl at tug.org
Sun Aug 3 21:06:00 CEST 2025


Revision: 75959
          https://tug.org/svn/texlive?view=revision&revision=75959
Author:   karl
Date:     2025-08-03 21:06:00 +0200 (Sun, 03 Aug 2025)
Log Message:
-----------
varsfromjobname (3aug25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/varsfromjobname/README.md
    trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.pdf
    trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.tex
    trunk/Master/texmf-dist/tex/latex/varsfromjobname/varsfromjobname.sty

Modified: trunk/Master/texmf-dist/doc/latex/varsfromjobname/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/varsfromjobname/README.md	2025-08-03 19:05:05 UTC (rev 75958)
+++ trunk/Master/texmf-dist/doc/latex/varsfromjobname/README.md	2025-08-03 19:06:00 UTC (rev 75959)
@@ -6,8 +6,7 @@
 
 # Credits
 
-varsfromjobname.sty is based on code by supplied by Friedrich Vosberg, Enrico Gregorio and Markus Kohm,  help from Rolf Niepraschk, Sven Naumann, Ulrich Schwarz 
-and Andreas Mathias was greatly appreciated.
+varsfromjobname.sty is based on code by supplied by Friedrich Vosberg, Enrico Gregorio and Markus Kohm, help from Rolf Niepraschk, Sven Naumann, Ulrich Schwarz and Andreas Mathias was greatly appreciated.
 
 # What does this package do?
 
@@ -18,7 +17,7 @@
 The package expects the filename to be of the form
 `one-two-three-four-five-six-seven-eight-nine.tex` and offers the following commands:
 
-* `\getfromjobname{param}`, with `param` in the range of 1 to 9 (a highlevel
+* `\getfromjobname{param}`, with `param` in the range of 1 to n (a highlevel
 interface to the following commands)
 * `\getonefromjobname`
 * `\gettwofromjobname`
@@ -35,12 +34,6 @@
 
 You can use this package for example to define the date of the document in the filename, personally I use it e.g. for `scrlttr2` letters.
 
-# Shortcomings
-
-* `\getfromjobname` is not fully expandable, use one of the other commands if you need expansion
-* Version 1.0 cannot extract information from included sub-documents
-* The package cannot handle more than nine tokens, see the reference to egreg's answer on TSX below for an updated version
-
 # References
 
 * [https://tex.stackexchange.com/questions/212169/qr-code-from-jobname/212171#212171](https://tex.stackexchange.com/questions/212169/qr-code-from-jobname/212171#212171 "QR-code from jobname")
@@ -49,17 +42,23 @@
 
 * [https://tex.stackexchange.com/questions/116755/timestamp-in-document-pdf-name/116805#116805](https://tex.stackexchange.com/questions/116755/timestamp-in-document-pdf-name/116805#116805 "Timestamp in document / pdf name")
 
-* German article in the DTK on pagewise versioning with Subversion (to be published)
+* [https://tex.stackexchange.com/questions/645185/splitting-the-jobname-by-hyphens-in-expl3-syntax "Splitting the \jobname by hyphens in expl3 syntax"]
 
 
+#License
+
+Licensed under LaTeX Project Public License (LPPL), as of today this is LPPL 1.3c. In case newer version of LPPL is published, those shall apply.
+
 # Change History
 
 - Version 0.5, as of January 11th 2009: Initial version published
 
-- Version 1.0, to be published May 2017: 
+- Version 1.0, published May 2017: 
 	- Added various commands which extract necessary information also from included documents
 	- Modified code as suggested by egreg
 
+- Version 1.1, published August 2025:
+	- Switched to expl3 syntax, allowing more than nine tokens
 
 
-2017-04-30, Uwe Ziegenhagen 
\ No newline at end of file
+2025-08-03, Uwe Ziegenhagen 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.tex	2025-08-03 19:05:05 UTC (rev 75958)
+++ trunk/Master/texmf-dist/doc/latex/varsfromjobname/varsfromjobname.tex	2025-08-03 19:06:00 UTC (rev 75959)
@@ -1,4 +1,5 @@
-\documentclass[12pt]{article}
+\documentclass[12pt]{scrartcl}
+\usepackage{url}
 \usepackage{listings}
 \nofiles
 
@@ -9,9 +10,10 @@
 \usepackage[left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}
 
 
-\date{May 1st 2016}
+\date{August 3rd, 2025 }
 \author{Uwe Ziegenhagen, ziegenhagen at gmail.com}
-\title{\texttt{varsfromjobname} Description}
+\title{The varsfromjobname Package}
+\subtitle{Version 1.1}
 
 
 
@@ -18,10 +20,18 @@
 \begin{document}
 \maketitle
 
-\noindent Using \texttt{varsfromjobname.sty} one can easily extract information from the filename, if it follows a certain form. The LaTeX command \verb|\|jobname returns the name of the LaTeX file. 
 
-If the filename consists of tokens separated by hyphen we can easily extract certain tokens that can be used inside the document. 
 
+\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} 
@@ -29,8 +39,13 @@
 \noindent and offers the following commands:
 
 \begin{itemize}
-	\item \verb|\getfromjobname|\{\textit{param}\}, with \textit{param} in the
-	 range of 1 to 9 (highlevel interface to the following commands)
+	\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|
@@ -42,11 +57,11 @@
 	\item \verb|\getninefromjobname|	
 \end{itemize}
 
-For included documents the package uses the \texttt{currfile} package to provide the following commands: 
+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 9 (highlevel interface to the following commands)
+	 range of $1$ to $n$ (highlevel interface to the following commands)
 	\item \verb|\getonefromcurrfilename|
 	\item \verb|\gettwofromcurrfilename|
 	\item \verb|\getthreefromcurrfilename|
@@ -63,7 +78,7 @@
 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}}]
+\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
@@ -88,7 +103,7 @@
 
 h: \geteightfromjobname %h 
 
-i-j: \getninefromjobname % i-j
+i-j: \getninefromjobname % i, i-j in Version 1.0 of the package
 
 a: \getfromjobname{1} % a
 
@@ -106,7 +121,7 @@
 
 h: \getfromjobname{8} % h
 
-i-j: \getfromjobname{9} % i-j
+i: \getfromjobname{9} % i, in Version 1.0 of the package
 
 \input{z-y-x-w-v-u-t-s-r-q}
 
@@ -116,7 +131,7 @@
 
 
 
-\begin{lstlisting}[caption={\textbf{z-y-x-w-v-u-t-s-r-q.tex}}]
+\begin{lstlisting}[caption={\textbf{z-y-x-w-v-u-t-s-r-q.tex}, result and command}]
 z: \getonefromcurrfilename
 
 y: \gettwofromcurrfilename
@@ -133,7 +148,7 @@
 
 s: \geteightfromcurrfilename
 
-r-q: \getninefromcurrfilename
+r: \getninefromcurrfilename % r-q in Version 1.0 of the package
 \end{lstlisting}
 
 
@@ -144,9 +159,10 @@
 	\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 2017-05-01, Uwe Ziegenhagen
+\vfill 2025-08-02, Uwe Ziegenhagen
 
 \end{document}

Modified: trunk/Master/texmf-dist/tex/latex/varsfromjobname/varsfromjobname.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/varsfromjobname/varsfromjobname.sty	2025-08-03 19:05:05 UTC (rev 75958)
+++ trunk/Master/texmf-dist/tex/latex/varsfromjobname/varsfromjobname.sty	2025-08-03 19:06:00 UTC (rev 75959)
@@ -1,167 +1,96 @@
-%begin of varsfromjobname.sty
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{varsfromjobname}[2017/05/07 v. 1.0 extracts tokens from jobname]
-\RequirePackage{ifthen}
+% varsfromjobname-expl3.sty
+\RequirePackage{expl3}
 \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 at ID-107054.user.dfncis.de>
-% requires the filename to be of the following form
-% itemone-itemtwo-itemthree- ... -itemnine.tex
+\ProvidesExplPackage
+  {varsfromjobname}
+  {2025/08/03}
+  {1.1}
+  {Extract tokens from jobname or currfilebase using LaTeX3}
 
-\makeatletter
+\ExplSyntaxOn
+\NewExpandableDocumentCommand{\getfromjobname}{m}
+ {
+  \seq_item:Nn \g_varsfromjobname_main_seq { #1 }
+ }
 
-\newcommand*{\getonefromjobname}{%
-  \expandafter\@getonefromfilename\jobname--------\@nil%
-}
+\seq_new:N \g_varsfromjobname_main_seq
+\seq_gset_split:NnV \g_varsfromjobname_main_seq { - } \c_sys_jobname_str
 
-\newcommand*{\gettwofromjobname}{%
-  \expandafter\@gettwofromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\getonefromjobname}{}
+ {
+  \getfromjobname { 1 }
+ }
 
-\newcommand*{\getthreefromjobname}{%
-  \expandafter\@getthreefromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\gettwofromjobname}{}
+ {
+  \getfromjobname { 2 }
+ }
 
-\newcommand*{\getfourfromjobname}{%
-  \expandafter\@getfourfromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\getthreefromjobname}{}
+ {
+  \getfromjobname { 3 }
+ }
+ 
+\NewExpandableDocumentCommand{\getfourfromjobname}{}
+ {
+  \getfromjobname { 4 }
+ } 
 
-\newcommand*{\getfivefromjobname}{%
-  \expandafter\@getfivefromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\getfivefromjobname}{}
+ {
+  \getfromjobname { 5 }
+ }
+ 
+\NewExpandableDocumentCommand{\getsixfromjobname}{}
+ 
+ {
+  \getfromjobname { 6 }
+ } 
 
-\newcommand*{\getsixfromjobname}{%
-  \expandafter\@getsixfromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\getsevenfromjobname}{}
+ {
+  \getfromjobname { 7 }
+ }
+ 
+\NewExpandableDocumentCommand{\geteightfromjobname}{}
+ {
+  \getfromjobname { 8 }
+ }
 
-\newcommand*{\getsevenfromjobname}{%
-  \expandafter\@getsevenfromfilename\jobname--------\@nil%
-}
+\NewExpandableDocumentCommand{\getninefromjobname}{}
+ {
+  \getfromjobname { 9 }
+ }
 
-\newcommand*{\geteightfromjobname}{%
-  \expandafter\@geteightfromfilename\jobname--------\@nil%
-}
+%currfile syntax
 
-\newcommand*{\getninefromjobname}{%
-  \expandafter\@getninefromfilename\jobname\@nil%
-}
+% Local sequence for currfile parsing
+\seq_new:N \l_varsfromjobname_currfile_seq
 
-\newcommand*\@getonefromfilename{}
-\def\@getonefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
-#1%
-}
+% Split currfilebase
+\cs_new:Nn \varsfromjobname_split_currfile:
+ {
+  \tl_set:Nx \l_tmpa_tl { \currfilebase }
+  \seq_set_split:NnV \l_varsfromjobname_currfile_seq { - } \l_tmpa_tl
+ }
 
-\newcommand*\@gettwofromfilename{}
-\def\@gettwofromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
-#2%
-}
+% Base extractor
+\NewExpandableDocumentCommand{\getfromcurrfilename}{m}
+ {
+  \varsfromjobname_split_currfile:
+  \seq_item:Nn \l_varsfromjobname_currfile_seq { #1 }
+ }
 
-\newcommand*\@getthreefromfilename{}
-\def\@getthreefromfilename#1-#2-#3-#4-#5-#6-#7-#8-#9\@nil{%
-#3%
-}
+% Convenience aliases
+\NewExpandableDocumentCommand{\getonefromcurrfilename}{}  { \getfromcurrfilename{1} }
+\NewExpandableDocumentCommand{\gettwofromcurrfilename}{}  { \getfromcurrfilename{2} }
+\NewExpandableDocumentCommand{\getthreefromcurrfilename}{}{ \getfromcurrfilename{3} }
+\NewExpandableDocumentCommand{\getfourfromcurrfilename}{} { \getfromcurrfilename{4} }
+\NewExpandableDocumentCommand{\getfivefromcurrfilename}{} { \getfromcurrfilename{5} }
+\NewExpandableDocumentCommand{\getsixfromcurrfilename}{}  { \getfromcurrfilename{6} }
+\NewExpandableDocumentCommand{\getsevenfromcurrfilename}{}{ \getfromcurrfilename{7} }
+\NewExpandableDocumentCommand{\geteightfromcurrfilename}{}{ \getfromcurrfilename{8} }
+\NewExpandableDocumentCommand{\getninefromcurrfilename}{} { \getfromcurrfilename{9} }
 
-\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
\ No newline at end of file
+\ExplSyntaxOff
\ No newline at end of file



More information about the tex-live-commits mailing list.