0

How can I pass commas to key-value pairs when using l3keys ? Have inserted double quotes but the quotes get printed as well, something I do not want to appear.

\documentclass[a4paper,12pt]{article}

\ExplSyntaxOn

\keys_define:nn { adr_keys } { name .tl_set:N = \l_name_tl, vltw .tl_set:N = \l_vltw_tl, }

\cs_new_protected:Nn \print_adr:n { \keys_set:nn { adr_keys } { #1 }

\begin {tabular} { @{} l@{} }

  \tl_use:N \l_name_tl \\

  \tl_if_blank:VF \l_vltw_tl
    { \tl_use:N \l_vltw_tl \\ }

\end {tabular}

}

\NewDocumentCommand {\adr} { m } { \begin {flushright} \print_adr:n { #1 } \end {flushright} }

\ExplSyntaxOn

\begin{document}

\adr { name="Heime Borgia", vltw="405 Hilgard Ave, Los Angeles", }

\end{document}

Ragonese
  • 171
  • 4

1 Answers1

3

TeX's parsing rules mean that the way to 'hide' a token inside such delimited contexts is to use a {...} pair (assuming normal catcodes). This is unaffected by expl3.

\adr
  {
    name= Heime Borgia,
    vltw= {405 Hilgard Ave, Los Angeles},
  }

(It would be possible to have token-by-token parsing and pick up the " characters in a keyval context, but that would be slow and not needed here: we are dealing with input where expecting {...} treatment is reasonable.)

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036