diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/varsfromjobname/varsfromjobname.tex |
Initial commit
Diffstat (limited to 'macros/latex/contrib/varsfromjobname/varsfromjobname.tex')
-rw-r--r-- | macros/latex/contrib/varsfromjobname/varsfromjobname.tex | 152 |
1 files changed, 152 insertions, 0 deletions
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} |