0

how to split parameter in an argument list of function by space

\def\onto[1]{ ....i don't know how to do }

or \newcommand{\onto}[1]{ #1 } in #1 i get hello home as 1 string in example i give

\onto{hello, sonia} now i want to excess home and hello separate so i can use home as separate string and hello as separate

closed as unclear what you're asking by egreg, Sebastiano, Phelype Oleinik, siracusa, Troy Nov 13 '18 at 5:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to TeX.SX! I'm sorry, but your question is not very clear. Can you please add an approximate representation of what you want that \onto{hello,sonia} should output? – egreg Nov 6 '18 at 15:24
1

The listofitems package.

\documentclass{article}
\usepackage{listofitems}
\newcommand\splitarg[1]{%
  \setsepchar{ }%
  \readlist\myarg{#1}%
}
\begin{document}
\splitarg{This is a very big test}
Here is argument 4: \myarg[4]

\def\tmp{This is a very big test}
\splitarg{\tmp}
Here is last argument: \myarg[-1]
\end{document}

enter image description here

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