Tagged Questions
2
votes
2answers
95 views
What is the correct way to generate notation for a finite set using for loop in Latex?
I am trying to create a command that will take an index n as a parameter, and generate the the expanded form of this {a_1, a_2, a_3,...,a_n}.
For my first attempt, I tried to use the syntax suggested ...
6
votes
3answers
110 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 ...
7
votes
3answers
108 views
Defining commands using two loops
I would like to define a series of command using two loops.
For instance I want to create a series of variables that can have YY or NN as subscripts.
I would like to define commands \yy and \nn that ...
3
votes
2answers
470 views
TikZ: Drawing the same data with scatter plots and parallel coordinates
I am new to TikZ and trying to recreate the following image (which was created in R):
(Translation: correlation = +1, correlation = -1, two clusters, circle, normal distribution)
Each "column" ...
6
votes
1answer
188 views
How to define macros in a foreach loop with effects between iterations and after the loop without using global?
Without using \global, the following code:
\documentclass{minimal}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{etextools}
\newcommand\appendbyforeach[2]{%
...
7
votes
2answers
209 views
Getting last value in tikz foreach
I tried this, but it doesn't work as intended:
\foreach \x/\index in {4/0,5/1,19/2} {
\ifnum \index > 0
% use lastx
\fi
\pgfmathsetmacro\lastx{\x}
}
How do I set \lastx properly?
2
votes
3answers
139 views
Process Last Item in \ForEach (forarray package)
The following command of the forarray package
\ForEach{,}{\thislevelitem(\the\thislevelcount) : }}{x,y,z}
produces the output
x(1) : y(2) : z(3) :
I want to have the same output without the last ...
3
votes
2answers
164 views
\DTLdeletedb (from datatool package) has no effect within \foreach
This question led to a new feature in a package:
datatool
\DTLgdeletedb is available in (v2.13) and later.
I am trying to use a \foreach loop to iterate over a few items. For each iteration ...
6
votes
1answer
337 views
Problem setting a flag inside a TikZ `\foreach` loop
I'm pulling my hair out trying to understand why the following doesn't work. The intention is to calculate whether a given number #1 is prime, and to set \isprime to either 1 (true) or 0 (false). The ...
5
votes
1answer
373 views
Using \Alph on \foreach loop argument
Here's basically what I try to do:
\begin{tikzpicture}
\foreach \x in {1,2,3,4,5}
{
\draw (\x,1) node{\Alph{\x}};
}
\end{tikzpicture}
However if I do that, I get
ERROR: Missing number, ...
6
votes
3answers
536 views
How to get the list of predefined colors in xcolor such that the list can be used in foreach looping?
I need to get the list of predefined colors in xcolor. Hard-coding as follows is not a good coding practice.
\documentclass[dvipsnames,cmyk]{minimal}
\parindent=0pt
\usepackage{pstricks}
...
5
votes
2answers
197 views
Preparing macro content in a loop (calling \foreach from \edef)
I need to do something like \def\MyArray{{1, 2, 3, 4}} but with a dynamical number of elements.
The following command makes the string:
\newcommand{\MakeArray}[1]{\{ 1 \foreach \x in {2, ..., #1}{ , ...
6
votes
1answer
548 views
Generating tables with \@for command
I'm making a report template that requires the list of authors to be presented in several different ways, one of which is a table that lists each author and provides a space for them to sign the ...
6
votes
2answers
2k views
How to use parameter numbers and \foreach
Is there a way to use the TikZ \foreach command to do operations with parameters?
E.g. I would like to be able to write (just a silly example):
\newcommand{\foo}[9]{
\foreach \x in{1,2,...,9}{
...
3
votes
1answer
307 views
Are there list building macros in PGF/Tikz?
In Mathematica, C# linq, or other languages, we can use auxiliary functions to produce list of certain pattern.
For example:
In Mathematica, we can use Table[] or Range[] to produce a list of ...
3
votes
2answers
400 views
Unexpected tikz/counter behaviour
What I've been trying to do, futilely, is to use the foreach[counter=\xi] x in {1,2,3} statement in tikz/pgf with LaTeX. This fails, every time. Whatever. So I moved on to trying to use a counter, ...
