Simpler input for newcommand with many arguments

listofitemsmacros

I have a mathematical symbol with 6 labels but there are multiple conventions for displaying such a symbol. One way would be [F^{abc}_d]_{ef} but other people use, e.g., [F^{abc}_d]^{e}_{f} or other forms. Since I'm at the start of writing a thesis I'd prefer not to make an absolute choice and decided to define a command with 6 labels as input such as

\newcommand{\F}[6]{[F^{{#1} {#2} {#3}}_{#4}]^{#5}_{#6}}

but then I have to type \F{a}{b}{c}{d}{e}{f} which is a bit cumbersome. Is there any way that I could call the new command using a comma separated list, e.g. \F{a,b,c,d,e,f}, instead of the standard way??

Best Answer

The listofitems package can parse lists, using a comma (default) or other designated tokens.

Note that your list will need at least 5 commas, or an error will occur when calling \Fvar[6].

\documentclass{article}
\usepackage{listofitems}
\newcommand{\F}[1]{%
  \readlist*\Fvar{#1}%
  [F^{{\Fvar[1]} {\Fvar[2]} {\Fvar[3]}}_{\Fvar[4]}]^{\Fvar[5]}_{\Fvar[6]}}
\begin{document}
\begin{equation}
\F{a,b,c,d,e,f}
\end{equation}
\end{document}

enter image description here