I would like to understand if there is a simple way to implement the following feature in LaTeX:

I would like to create mycustomsty.sty that I would call like this:

\usepackage[author={string1, string2, ..., stringN}]{mycustomsty}

and that would have the same output as simply typing:

\author{string1 \and string2 \and ... \and stringN}

directly in the TeX file.

  • The package filecontents is used to have one single file (MWE). Of course you can put the sty in a separate file.
  • Use kvoptions to pass the string to the package.
  • Use xstring to make string substitutions.
  • To make it possible to replace a string with a command (\and), witch should not be expanded, but also interpret the inputstring as an expanded command \expandarg is used. (from xstring documentation: "In this case, the first token of each argument is expanded one time while all other tokens are left unchanged")







        \StrSubstitute{\myauthorgenerator@author}{,}{\and }%

\usepackage[author={Frodo,Sam,Pippin, Merry}]{myauthorgenerator}




enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.