In the following MWE, I tried to create a command (but I also tried with a macro) that receives #1
argument. In this case, I am trying to create a comma separated list. However, as shown in the figure below, it seems that the argument works as just one element \x
of the list when I call it via \printKW
, as if the commas weren't actual commas. How do I create a command (or macro) that stores a comma separated list and how can I call it via another command (or macro)?. Thank you!
\documentclass{article}
\usepackage{pgf, tikz}
\setlength{\parskip}{0.5cm}
\newcommand\KeyWords[1]{\def\@KeyWords{#1}}
\newcommand\printKW{\@KeyWords}
\newcommand{\kwmacro}{Letter, Word, Phrase, Paragraph, Page, Book, Library}
\KeyWords{Letter, Word, Phrase, Paragraph, Page, Book, Library}
\begin{document}
\textbf{Comprehensive knowledge storage follows the evolutionary sequence given by}
\foreach \x [count=\n] in \kwmacro {(\n) \x, }
\textbf{while the access to it follows the reverse order.}
\textbf{Keywords:}
\foreach \x [count=\n] in \printKW {\n.~\x. }
\end{document}
\def
. If you want to process all comma separated arguments by your own macro, I can show you how to do it. Or you want to cooperate comma separated lists with pgf macros like in your example? Why do you want to insert\printKW
in the context of\foreach
? You can use directly\kwmacro
as shown above in your example.