I've found myself in a situation where I need to dynamically add a list of strings inside a tabular cell in multiple instances, each string in their own line. To tackle this, I tried to go with the following approach, using the makecell and forarray packages:
\documentclass{article} \usepackage{makecell} \usepackage{forarray} \begin{document} \newcommand{\listcontacts}[1]{\ForEach{,}{\scriptsize\textbf{\thislevelitem}\\}{#1}} \begin{tabular}{ r r } \hline \textbf{NAME} & \textbf{CONTACT} \\ \hline John Doe & \makecell[r]{\listcontacts{Number One,Number Two,Number Three}} \\ % Error: Tried to expand an \endforeachtoken. Something is wrong. \hline \end{tabular} \listcontacts{Number One,Number Two,Number Three} % renders fine \end{document} As you can see, the list renders fine outside of the table, but behaves strangely inside makecell due to the programmatically added line breaks, on top of an error thrown at the affected line. Using anything different than a line break, it renders fine inside the cell as well.
I already tried to use pgfmath as an alternative way to iterate, as well as \StrSubstitute from the xstring package to downright replace the commata with line breaks. Even line breaks in the command parameter itself won't be processed correctly by makecell.
This leaves me wondering, is there any way to add line breaks inside makecell besides to do so statically? How would I achieve this?

