latex - inputting all items of a list into an environment -


i have list of names input given surrounding, e.g. box. put in different way: i'd latex create surrounding every item in given list.

here's list: frank, fred, fran

here's surrounding:

\fbox{\name}

\name following: inputs first item list , creates \fbox each successive item in list until end of list, result outputting same (but saving typing of)

\fbox{frank} \fbox{fred} \fbox{fran}

i thinking of list of names "count" (redefining 1 frank, 2 fred...) , might wrong approach. realise command can not 2 things @ once.

if there's simple solution this: called , can find it? searching 'variables' or 'foreach' didn't help.

depending on application, can either specify list explicitly, or in file:

  1. as explicit list (see how iterate on comma separated list?):

    \documentclass{article} \usepackage{etoolbox}  \newcommand{\printlist}[1]{%   \begin{enumerate}     \renewcommand*{\do}[1]{\item \fbox{##1}}%     \docsvlist{#1}%   \end{enumerate}% }  \begin{document}  \printlist{frank, fred, fran}  \end{document} 
  2. as file in (say) names.csv:

    \documentclass{article}  \usepackage{filecontents} \begin{filecontents*}{names.csv} frank fred fran \end{filecontents*}  \usepackage{datatool}  \newcommand{\printlist}[1]{%   \dtlloaddb[noheader,keys=name]{namesdb}{#1}% load names database file   \begin{enumerate}     \dtlforeach{namesdb}{\name=name}{\item \fbox{\name}}   \end{enumerate} }  \begin{document}  \printlist{names.csv}  \end{document} 

in both instances, output resembles:

enter image description here


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -