Skip to main content
clist_use:nn now available
Source Link

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

enter image description here

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,

  1. We declare a document command with an optional argument with a default value and a mandatory one
  2. We wrap the commands in a group to use local variables
  3. We store the mandatory argument in a scratch variable named \l_tmpa_clist of type clist
  4. 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.

Here is a solution with LaTeX3, which might be simpler

\documentclass{standalone} \ExplSyntaxOn \NewDocumentCommand \ppath { O{$\;\triangleright\;$} m } { \group_begin: \clist_set:Nn \l_tmpa_clist { #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

enter image description here

Some explanations:

  1. We declare a document command with an optional argument with a default value and a mandatory one
  2. We wrap the commands in a group to use local variables
  3. We store the mandatory argument in a scratch variable named \l_tmpa_clist of type clist
  4. We "use" that variable to display the list with the given separator

The LaTeX3 commands documentation is available on CTAN as interface3.pdf and may be available locally with texdoc interface3.

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 } { \clist_use:nn { #2 } { #1 } } \ExplSyntaxOff \begin{document} A decent file path is \ppath{File,New,Document}. \end{document} 

The output is

enter image description here

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,

  1. We wrap the commands in a group to use local variables
  2. We store the mandatory argument in a scratch variable named \l_tmpa_clist of type clist
  3. 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.

Source Link

Here is a solution with LaTeX3, which might be simpler

\documentclass{standalone} \ExplSyntaxOn \NewDocumentCommand \ppath { O{$\;\triangleright\;$} m } { \group_begin: \clist_set:Nn \l_tmpa_clist { #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

enter image description here

Some explanations:

  1. We declare a document command with an optional argument with a default value and a mandatory one
  2. We wrap the commands in a group to use local variables
  3. We store the mandatory argument in a scratch variable named \l_tmpa_clist of type clist
  4. We "use" that variable to display the list with the given separator

The LaTeX3 commands documentation is available on CTAN as interface3.pdf and may be available locally with texdoc interface3.