# Programming with LaTeX — Add names and characteristics [duplicate]

I have to do a lot of certificates and I have a list of names, every name has a characteristic (A,B or C). I have designed the whole structure for the certificate and have the 'name' and 'characteristic' in blank.

My question is if it is possible to do something like

while (i in list):
code for structure with line name = i and charactertistic = char[i]
i+=1
newpage


In LaTeX, I mean writing the list and their characteristic in the code.

• Using expl3 this should be easy. – user31729 Aug 10 '16 at 16:00
• – Werner Aug 10 '16 at 16:09

Here I applied something like a hash-table, using name/characteristics as a bundled pair and splitting them with a small helper macro, setting the name as a property key and the characteristics as the key value.

The iteration about all keys is done with \prop_map_inline.

Some important notes:

• The keys must be unique -- specifying them again will just overwrite the old value.
• The order of appearance is not necessarily the same as the order of specification!

\documentclass{article}

\usepackage{expl3}

\ExplSyntaxOn
\prop_new:N \l_felipe_prop_list

\def\helpercmd#1/#2{%
\prop_put:Nnn \l_felipe_prop_list {#1} {#2}
}

\newcommand{\fillproplist}[1]{%
\seq_set_from_clist:Nn \l_tmpa_seq {#1}
\seq_map_inline:Nn \l_tmpa_seq {%
\helpercmd ##1 % Splitting!
}
}

\newcommand{\displaynamecharacteristics}{%
\prop_map_inline:Nn \l_felipe_prop_list {%
\displaynamechar{##1}{##2}% using a specialized display macro
}
}

\ExplSyntaxOff
% Change the \displaynamechar macro at will: #1 -> key name, #2 -> key value
\newcommand{\displaynamechar}[2]{%
Name = #1 \hfill Characteristics: #2%

}

\begin{document}
\fillproplist{Gandalf/A, Frodo/B, Sauron The Dark Lord/C}

\displaynamecharacteristics
\end{document}