{comma-separated-list} is a data format consisting of fields, most commonly separated by commas
21
votes
8answers
727 views
What is the best way to scan over a list of somethings?
It seems that a common operation needed when defining new commands is to scan over a list of arguments (separated e.g. by a comma, but maybe by something else) and do something with each argument in ...
16
votes
4answers
248 views
Comma delimited list - how to obtain the length?
It's simple. I have a list like {0,1,54,1,3} as input argument to a command in making. How can I obtain the length of this list? Something like
\length(#1)
where #1 is the list.
16
votes
2answers
190 views
Difficulty with macro expansion (updated)
Update. I have another problem that is so closely related to this one that I decided not to raise it as a new question, but instead to edit this one. Although Heiko's answer has explained how to fix ...
15
votes
7answers
388 views
How to define a command to feed the contents of a list into an \ifcase construct?
It's common to use an \ifcase construct to redefine a command depending on the value of a counter. The following example illustrates this:
\documentclass{article}
\usepackage{xcolor}
...
15
votes
2answers
230 views
Selecting random elements from a comma separated list
I would like to have a command (either user-defined, or from a package, or whatever) that has the basic form:
\selectNrandom{N}{list, of, comma, separated, elements}{code to execute}
which will ...
13
votes
3answers
251 views
Get n-th element of a list (with etoolbox, or not)
I'm defining a list and I need to obtain the n-th element of this list. I was surprised that etoolbox doesn't provide a way to obtain it. The way I found to obtain the n-th element is along these ...
12
votes
5answers
733 views
Parse comma-separated list of command names with spaces
Problem
This question is related to How can I specify a long list of math operators? – but with a twist: I want to allow spaces in in the comma-separated list, like so:
\newacronyms{acm, ams, cpu, ...
12
votes
1answer
313 views
Sorting Comma Separated Lists defined with, or without macro
I would like to be able to sort a comma separated list.
Before I resort to writing something that would require \ensureunix :-) and having that do the sort for me, I thought I'd make an attempt to ...
11
votes
4answers
311 views
How to make a recursive Latex macro with comma separated argument list
I would like to make a macro that takes two arguments, the second of which is a comma separated list and then produces a nested commutator of argument1 with each entry of argument2. I've been ...
11
votes
5answers
863 views
How do I write a macro having comma-separated and variable number of arguments?
I want to write a macro in LaTeX2e that can pass \textcolor, which is embedded in another macro, the values of the colour model gray, rgb, or cmyk. The number of arguments specified implies the colour ...
11
votes
1answer
167 views
Using etoolbox to automatically generate input for \xymatrix
I'd like to make a command \exactseq such that, for example,
\exactseq{A,f,B,g,C}
corresponds to
\xymatrix{A \ar[r]^{f} & B \ar[r]^{g} & C}
and such that this works for inputs of ...
10
votes
2answers
109 views
How to set class options that can have multiple values?
Title says it all, but here's an example: the KOMA-Script classes provide the option toc which can have multiple values that don't interfere with each other, like values that enable the Bibliography ...
8
votes
2answers
94 views
Confusion regarding strings and numbers in tikz
I'm using a macro that uses \StrBetween from xstring
It seems to be working great.
However, when I try to use a value that it returns as a coordinate in a tikz picture, I get a confusing error.
...
8
votes
2answers
120 views
Mapping a macro onto multiple lists simultaneously
I have a macro (say \myMacro) that takes three arguments (say a, b, c) and I want to write another macro (say \otherMacro) that given three lists of parameters (comma delimited lists and all of the ...
7
votes
2answers
95 views
Deleting an element from a comma separated list
In this answer we learnt how to remove the n-th element from a comma-separated list.
How can I remove an element from a list by its value, rather than its position? For example: if my global variable ...
7
votes
3answers
121 views
Sorting to match a given list
I am looking for ideas on the following task. I want to sort the entries in \listb to those in \lista. It cannot always be assumed that only the elements of \lista are in \listb; neither can it be ...
7
votes
7answers
682 views
Iterating through two lists
I have two comma delimited lists:
ListA(a,b,c,d,e,f,g)
and
ListB(name1,name2,name3,name4,name5)
I would like to iterate through both lists at the same time, something like:
loop
readvalue ...
7
votes
3answers
246 views
parse variable length comma separated list into command
I've been trying to modify the solution here into a LaTeX3 command that takes a variable length comma separated list of numbers and an optional argument (a unit) and prints the square root of the sum ...
7
votes
1answer
351 views
How to process a comma separated list?
Using receipt of "LaTeX3: unable to convert space separated list into clist" I elaborated the following code for my needs:
\documentclass{book}
...
\usepackage{expl3}
\begin{document}
...
7
votes
1answer
92 views
Getting a random sublist from a given list
The etoolbox package provides macros to handle list, which can be useful to package/class writers, however it miss macros to get random sublists.
So I want to define the following macros:
...
6
votes
3answers
107 views
Expansion issue when adding to CSV list from within a \foreach
Another expansion issue that I am unable to guess at the correct combination of \edef/\expandafters to get to work.
Background:
Below I have defined \AddToCommaSeparateList which uses \g@addto@macro ...
6
votes
1answer
823 views
\newcommand and comma separated parameters
I would like to learn to manipulate comma separated lists in Latex.
To give a concreet but artificial example, I would like to have this command:
\swap{1,10}
expand to this:
{10,1}
How can I ...
6
votes
1answer
149 views
Problem with old ConTeXt separated list example
I have been trying to get the following small example from ConTeXt garden to work without success.
\starttext
\usemodule[database]
\def\SendMe#1#2#3#4{\framed
[align={flushleft,lohi},
width=4cm,
...
5
votes
2answers
118 views
List delimited by commas (not lines)
Note: Comma delimited lists is not a duplicate.
What I want to do is have a list environment of items, like itemize and enumerate, but I want the output to be delimited by commas instead of new ...
5
votes
2answers
386 views
Replacing matching text with a macro containing information from a CSV file
I have some data stored in a CSV file, in this manner:
000000001 @ name @ information @ more information @ some more information
I also have a information.tex file containing the numbers from the ...
5
votes
1answer
198 views
Why am I processing a comma-separated list incorrectly when using etoolbox and kvoptions?
I'm trying to pick something out of a list that has been passed from some package options by kvoptions, but docsvlist doesn't appear to be recognising the commas.
I suspect this may be something to ...
4
votes
2answers
194 views
Iterating through comma-separated arguments
I've looked all over and can't seem to find a succinct answer to this question. Is it possible (and if so, how) to create a command that will iterate through its `arguments' of comma-separated values ...
4
votes
2answers
276 views
Cutting a table to fit the available space on a page
I have a long list of data, in a CSV file, formatted like this:
tiger, 300, 10.0, 7, 4.0
lion, 200, 15.0, 5, 3.0
bear, 100, 15.0, 3, 1.0
fish, 10, 10.0, 2, 0.1
The first rows are more important ...
3
votes
2answers
55 views
Reading arguments in a command?
I now know that if I want to get for example the 3rd argument passed to a command, I have use #3. My question is if this argument is an array how can I read elements of array without a for loop?
For ...
3
votes
1answer
107 views
Comma in macro parameters
I have a macro accepting several optional arguments in a comma separated list.
I would like to assign a value containing a comma to a particular argument. Is there a way to "escape" this particular ...
3
votes
1answer
54 views
List Version of \str_if_eq
I am using \str_if_eq:xxTF{\A}{\Target}{<true>}{<false} to execute the <true> or <false> code if \A=\Target.
What is the list version equivalent of this?
So I am looking for ...
2
votes
1answer
265 views
How to create a comma-separated list in LaTeX according to the number of elements in another list?
I have been looking for a way to create dynamically a comma-separated list consisting of n entries, all entries equal, defined by \newcommand\mytext{species:} (example) and n being the number of ...
1
vote
0answers
83 views
Compare two comma separated lists
Hi I would like to compare two comma separated lists.
\documentclass[a4paper]{article}
\usepackage{comment}
\usepackage{ifthen}
\usepackage{xargs}
\usepackage{xkeyval}
\usepackage{xfor}
...

