Here is a solution with LaTeX3, which might be simpler
Since may 2021
\clist_use:nn and \clist_use:nnnn are available as pointed out by egreg in the comments.
\documentclass{standalone} \ExplSyntaxOn \NewDocumentCommand \ppath { O{$\;\triangleright\;$} m } { \group_begin: \clist_set\clist_use:Nn \l_tmpa_clistnn { #2 } \clist_use:Nn \l_tmpa_clist { #1 } \group_end: } \ExplSyntaxOff \begin{document} A decent file path is \ppath{File,New,Document}. \end{document} The output is
Before may 2021
The instruction \clist_use:nn { #2 } { #1 } should be replaced by
\group_begin: \clist_set:Nn \l_tmpa_clist { #2 } \clist_use:Nn \l_tmpa_clist { #1 } \group_end: Some explanations:
In the second example,
- We declare a document command with an optional argument with a default value and a mandatory one
- We wrap the commands in a group to use local variables
- We store the mandatory argument in a scratch variable named
\l_tmpa_clistof type clist - We "use" that variable to display the list with the given separator
Notice the use of \clist_use:Nn instead of \clist_use:nn.
The LaTeX3 commands documentation is available on CTAN as interface3.pdf and may be available locally with texdoc interface3.
