# Tag Info

8

This is essentially in expl3 out of the box. The idea is to map the original list; if an item is not in the remove list, add it to a temporary list and, at the end, reset the original list to the temporary one. I added just some syntactic sugar to name lists, which allows to have many of them without defining new macros. \documentclass{article} \usepackage{...

7

Use count=\n: \documentclass{article} \usepackage{pgf, tikz} \begin{document} \textbf{Comprehensive knowledge storage follows the evolutionary sequence given by} \foreach \x in {letter, word, phrase, paragraph, page, book, library} {\x, }% <----- \textbf{while the access to it follows the reverse order.} \bigskip \textbf{Keywords:} \foreach \x [count=\...

6

As Andrew said, expl3 has great high-level tools for many things, including list processing. But expl3 or not, the most important thing is to understand what you are doing, and post a minimal working example when you are stuck (your code doesn't have \end{document}). So, I'll focus on your “second approach.” You initialize the result with a first item which ...

5

A different approach with listofitems. In essence, I use the remove-list as the list separators. Thus, they don't show up in a digested list regurgitation, because they were removed as list separators (along with the excess commas). \documentclass{article} \usepackage{listofitems} \newcommand\subtractlists[2]{% \expandafter\setsepchar\expandafter{\...

5


5

As Henri said in the comment, the \foreach loop is grouped, so it isn't really fit for this type of application. You can use expl3's \seq_use:Nn <seq var> {<thing>} to add <thing> between each item of <seq var>: \documentclass{article} \usepackage{amsmath,xparse} \ExplSyntaxOn \seq_new:N \l_trevion_tmp_seq \NewDocumentCommand \Hor {...

4

Here's one alternative LaTeX3 property lists to store and retrieve the values. Use \ReadCSVArray{<file name>} to read the .csv file, and then use \ArrayItem{<key>} to retrieve the <value> associated with the key. \ArrayItem is expandable so that if the <value> is numeric, then you can use in numerical expressions in \fpeval (for ...

4

Macros in PGF foreach loops are only expanded once but \printKW needs two steps to expand to the list. The can be fixed for all instances of the foreach loop by patching the internal macros. Here I introduce a check whether the macro is expandable and if it is perform a full expansion (expl3 f-type) on it. You also want \makeatletter ... \makeatother ...

3

A slightly (more compact) version with expl3: \begin{filecontents*}{\jobname.csv} "N","n","M" 200,100,50 \end{filecontents*} \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\readcsvfile}{m} {% #1 is the file name \lrnv_readcsvfile:n { #1 } } \NewExpandableDocumentCommand{\getcsvitem}{m} { \prop_item:Nn \...

3

This is a quite common problem in LaTeX because TeX doesn't provide good tools to write a sturdy parser that will understand the difference of a , which is supposed to separate two items in a list and the , which is just part of a sentence. In fact, most programming languages don't do that and rely on something else to differentiate those, like wrapping a ...

2

The correct way to proceed is described in the KOMA-Script documentation as Some options can have several values simultaneously. For such options, it is possible, with the help of \KOMAoption, to pass a list of values to a single option. The individual values are given as a comma-separated value list. So, in your example: \documentclass[any_option]{...

2


1

As you can see in the answer to the question How to change the space between the itemize “items” in LaTeX?, \itemsep is already defined in LaTeX. If you wish, you can combine the exchanging of non-delimited macro-arguments with good old \romannumeral-expansion for defining a macro which checks the toplevel-expansion of \Variety for emptiness and then appends ...

1

So, I solved it. It's an issue of using expand. Still haven't fully grasped the idea of expand but found a similar old thread here So, the above works if I add \dtlexpandnewvalue in the macro \readlist\keylist{ColA,ColB,ColC} \newcommand{\addemptyrow}{% \DTLnewrow{mydata}%%% \dtlexpandnewvalue \foreachitem\key\in\keylist{% \...

1

Although an accepted answer is posted, I would also offer the option to use DataTool. I kept the raw \DTLfetch command exposed. it could be encapsulated in its own macro to achieve your objective. \documentclass{article} % datatool does the database work \usepackage{datatool} % the file contents \begin{filecontents*}{values.csv} color, N, n_trees, M red, ...

1

For completeness, I threw in an xstring based solution. Note that xstring does not ignore the spaces after the commas. \documentclass{article} \usepackage{xcolor} \usepackage{xstring} \def\thecolors{black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow} \newcounter{...

Only top voted, non community-wiki answers of a minimum length are eligible