In my texts I have to deal with lists, whose items need to be formatted seperatly, i.e.:
\funktion[3][]{T}--\funktion{S}--\funktion[3][7]{D}--\funktion{T}
In \funktion
which leads to \emphsubsup
the formatting takes place and the optional parameters are handled.
How can I shorten this task by a function like \funktionen
? I.e.:
\funktionen{[3][]{T},{Sp},[3][{7,9,11}]{D},{T}}
or even better:
\funktionen{[3][]T,Sp,[3][{7,9,11}]D,T}
Each argument can contain more than 1 character, including comma!
I've tried it with forcsvlist
from the etoolbox
package, but it takes (of course) the whole value [3][]{T}
as one single argument. Also I don't know how to realize the seperator --
.
MWE:
\documentclass[border=5]{standalone}
\usepackage{etoolbox, xparse, fixltx2e, letltxmacro}
\DeclareDocumentCommand{\subsup}{ o o m }{%
\IfValueTF{#1}{%
\IfValueTF{#2}{%
\textsubscript{#1}#3\textsuperscript{#2}%
}{%
#3\textsuperscript{#1}}%
}{#3}%
}
\DeclareDocumentCommand{\emphsubsup}{ o o m }{\emph{\subsup[#1][#2]{#3}}}%same, only emphasized
\LetLtxMacro{\funktion}{\emphsubsup}
%test
\newcommand*{\funktionen}[1]{%
\forcsvlist{\funktion}{#1}
}
\begin{document}
\funktion[3][]{T}--\funktion{Sp}--\funktion[3][7,9,11]{D}--\funktion{T}
\hskip1ex
\funktionen{[3][]{T},{Sp},[3][{7,9,11}]{D},{T}}
\end{document}
forcsvtlist
to take more than one argument may be useful for you. It's not exactly what you want, but just have to add some braces around each group:\forcsvlistargs{mycmd}{ {{1a}{1b}} , {{2a}{2b}} , {{3a}{3b}} }