summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/varsfromjobname
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/varsfromjobname
Initial commit
Diffstat (limited to 'macros/latex/contrib/varsfromjobname')
-rw-r--r--macros/latex/contrib/varsfromjobname/README.md65
-rw-r--r--macros/latex/contrib/varsfromjobname/varsfromjobname.pdfbin0 -> 183061 bytes
-rw-r--r--macros/latex/contrib/varsfromjobname/varsfromjobname.sty167
-rw-r--r--macros/latex/contrib/varsfromjobname/varsfromjobname.tex152
4 files changed, 384 insertions, 0 deletions
diff --git a/macros/latex/contrib/varsfromjobname/README.md b/macros/latex/contrib/varsfromjobname/README.md
new file mode 100644
index 0000000000..d9506c5d93
--- /dev/null
+++ b/macros/latex/contrib/varsfromjobname/README.md
@@ -0,0 +1,65 @@
+# VarsFromJobname
+
+Sources for my varsfromjobname LaTeX package, available also from CTAN:
+
+[https://www.ctan.org/tex-archive/macros/latex/contrib/varsfromjobname](https://www.ctan.org/tex-archive/macros/latex/contrib/varsfromjobname "CTAN varsfromjobname")
+
+# 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.
+
+# What does this package do?
+
+Using `varsfromjobname.sty` one can easily extract information from the filename, if it follows a certain form.
+
+The standard LaTeX command `\jobname` returns the name of the LaTeX (master) file. If the filename consists of tokens separated by hyphen we can easily extract certain tokens that can be used _inside_ the document.
+
+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
+interface to the following commands)
+* `\getonefromjobname`
+* `\gettwofromjobname`
+* `\getthreefromjobname`
+* `\getfourfromjobname`
+* `\getfivefromjobname`
+* `\getsixfromjobname`
+* `\getsevenfromjobname`
+* `\geteightfromjobname`
+* `\getninefromjobname`
+
+# Why can it be useful?
+
+
+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")
+
+Remark: [egreg](https://tex.stackexchange.com/users/4427/egreg "egreg") gave an improved version of the code written with expl3 which also overcomes the limitation of nine parameters.
+
+* [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)
+
+
+# Change History
+
+- Version 0.5, as of January 11th 2009: Initial version published
+
+- Version 1.0, to be published May 2017:
+ - Added various commands which extract necessary information also from included documents
+ - Modified code as suggested by egreg
+
+
+
+2017-04-30, Uwe Ziegenhagen \ No newline at end of file
diff --git a/macros/latex/contrib/varsfromjobname/varsfromjobname.pdf b/macros/latex/contrib/varsfromjobname/varsfromjobname.pdf
new file mode 100644
index 0000000000..89240294a0
--- /dev/null
+++ b/macros/latex/contrib/varsfromjobname/varsfromjobname.pdf
Binary files differ
diff --git a/macros/latex/contrib/varsfromjobname/varsfromjobname.sty b/macros/latex/contrib/varsfromjobname/varsfromjobname.sty
new file mode 100644
index 0000000000..57893a1f39
--- /dev/null
+++ b/macros/latex/contrib/varsfromjobname/varsfromjobname.sty
@@ -0,0 +1,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 \ No newline at end of file
diff --git a/macros/latex/contrib/varsfromjobname/varsfromjobname.tex b/macros/latex/contrib/varsfromjobname/varsfromjobname.tex
new file mode 100644
index 0000000000..55516a138a
--- /dev/null
+++ b/macros/latex/contrib/varsfromjobname/varsfromjobname.tex
@@ -0,0 +1,152 @@
+\documentclass[12pt]{article}
+\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{May 1st 2016}
+\author{Uwe Ziegenhagen, ziegenhagen@gmail.com}
+\title{\texttt{varsfromjobname} Description}
+
+
+
+\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.
+
+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} in the
+ range of 1 to 9 (highlevel interface to the following commands)
+ \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 documents the package uses the \texttt{currfile} package 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)
+ \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}}]
+% 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-j
+
+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-j: \getfromjobname{9} % i-j
+
+\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}}]
+z: \getonefromcurrfilename
+
+y: \gettwofromcurrfilename
+
+x: \getthreefromcurrfilename
+
+w: \getfourfromcurrfilename
+
+v: \getfivefromcurrfilename
+
+u: \getsixfromcurrfilename
+
+t: \getsevenfromcurrfilename
+
+s: \geteightfromcurrfilename
+
+r-q: \getninefromcurrfilename
+\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
+\end{description}
+
+
+\vfill 2017-05-01, Uwe Ziegenhagen
+
+\end{document}