# Spaces in l3prop

How can one store verbatim code in a LaTeX3 property list?

My goal is to store person names in a property inside a property list. This means that both accents and spaces must be stored in the key name. Here's my code:

\ExplSyntaxOn
\prop_new:N \aaa
\prop_put:Nnn \aaa {name} {Alfr\'ed R\'enyi}
\prop_item:Nn \aaa {name}
\ExplSyntaxOff


The output does not show the space between "Alfréd" and "Rényi". I suspect this is due to \ExplSyntaxOn making LaTeX ignore space. I am stuck here. Any ideas?

• Please use more the appropiate naming scheme for your variables, i.e. \l_jaeya_name_prop – user31729 Apr 13 '17 at 18:05

Either use \space or ~, otherwise spaces are gobbled in expl3 regime.

I also changed the 'wrong' name of the \prop - list variable according to the expl3 naming convention, i.e. \l_jaeya_name_prop, for example.

\documentclass{article}

\usepackage{expl3}

\begin{document}
\ExplSyntaxOn
\prop_new:N \l_jaeya_name_prop
\prop_put:Nnn \l_jaeya_name_prop {name} {Alfr\'ed\space R\'enyi}
\prop_put:Nnn \l_jaeya_name_prop {othername} {Arthur~Gumby}
\prop_item:Nn \l_jaeya_name_prop {name}~and~\prop_item:Nn \l_jaeya_name_prop {othername}
\ExplSyntaxOff
\end{document}


A better way is to store and retrieve the content with a wrapper:

\documentclass{article}

\usepackage{expl3}

\ExplSyntaxOn
\prop_new:N \l_jaeya_name_prop

\cs_new:Npn \storename #1#2{% The % isn't necessary, just for convenience for more complicated macros to remember where which bracket starts.
\prop_put:Nnn \l_jaeya_name_prop {#1} {#2}
}

\cs_new:Npn \retrievename #1{%
\prop_item:Nn \l_jaeya_name_prop {#1}
}

\ExplSyntaxOff

\begin{document}

\storename{name}{Alfr\'ed R\'enyi}
\storename{othername}{Arthur Gumby}

\retrievename{name} and \retrievename{othername}
\end{document}


• Oh, now I get it: space is gobbled because I am calling the function inside expl3, not because it is defined in expl3. Calling it outside expl3 then solves the problem. – Jaeya Apr 13 '17 at 18:13
• @Jaeya: Yes, that's the trick. The expl3 features are meant for simplifying the programming, but they shouldn't appear directly in the document body for direct typesetting. – user31729 Apr 13 '17 at 18:15
• That's what I was planning to do later, but I did that for easier testing... Thanks a lot! – Jaeya Apr 13 '17 at 18:16
• @Jaeya: You're welcome. Happy TeXing (with expl3) ;-) – user31729 Apr 13 '17 at 18:18
• +1. In expl3 I'd rather use \c_space_tl instead of \space. (Of course that's only needed after macros. ~ is much clearer) – cgnieder Apr 22 '17 at 9:54