{foreach} is for questions regarding the TikZ/PGF module of the same name which can also be used as a standalone package pgffor.

learn more… | top users | synonyms

4
votes
2answers
136 views

How to access the arithmetic value of count in \foreach, and use them in rotate box{}?

I have a question about access the mathematical value of count in \foreach, I will used that value to do some calculation in the following code. But it didn't work. ...
2
votes
1answer
64 views

Custom PSTricks directory tree to TikZ

I have a PSTricks implementation of a custom directory tree which I find quite appealing. I basically want to convert the whole thing to TikZ. I managed to get the very basic idea running in TikZ: I ...
3
votes
2answers
39 views

Error in foreach loop when number range defined with a macro

I am having problems to implement a loop that runs over the months of the year and the days of each month. A simple representative example of my current approach is shown below. ...
1
vote
0answers
74 views

iterating over multiple variables with \foreach it TikZ

Note: I'm aware of another response here, but its solution was a quick-fix rather than the underlying issue. Say I want to create the following diagram but using iteration: \begin{tikzpicture} ...
2
votes
1answer
54 views

Place multiple external images in a PGFPlots axis from a PGFPlotsTable

I am trying to create an environment in which I can place several georeferenced images into a PGFPlots axis. I have working code that reads in the specified image, reads in the world file (a text ...
2
votes
1answer
35 views

Difference in behaviour using one input file and many input files

I have noticed difference in behaviour when loading a single file \input{letters/all_letters} and when loading several files using a command \newcommand*{\alphabetF}{% ...
5
votes
2answers
170 views

How to incrementally shorten lines generated by TikZ's `foreach` command?

I'm trying to draw a picture of an initial segment of the cumulative hierarchy of set theory. I generated the following MWE: \documentclass{article} \usepackage{tikz} \begin{document} ...
1
vote
0answers
55 views

How to iterate foreach with two variables and a list of values

Iteration with foreach brings error in the moment I use a list with two variables as you can see in the mwe. Is there a solution possible? As the output PDF shows the error occurs when trying to use a ...
1
vote
1answer
64 views

Using \foreach for repeated structure [duplicate]

documentclass[border={5mm}]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=1, default rectangle/.style={rectangle, draw=black,thin, minimum size=1cm}, ] ...
2
votes
1answer
20 views

Problem displaying figure captions from array while looping

I'm attempting to generate multiple Figures using the code below. However, I'm having a problem with \caption{\questions(\plotNum)}. The error I receive is Incomplete \iffalse; all text was ignored ...
3
votes
2answers
107 views

How to check for more elements a foreach loop?

I want to check if there are more elements in a foreach loop. How can this be done? This is an example for loop: \foreach \p/\q in {a/{1,2,3}, b/{4,5,6}} \foreach \r in \q { (\r) } EDIT#1 An ...
4
votes
1answer
62 views

Changing color in foreach using arrayjob

I am trying to change the color within a foreach statement. Here a way is described how to do it depending on the foreach variable. However, I want to use HTML color code, so I decided to use ...
5
votes
1answer
71 views

How can I use \foreach in math environments?

I'm looking for a way to generate in a loop the rows of an align environment, or IEEEeqnarray or some such thing. I can see that \foreach works in math mode (inside \[ \] e.g.), but something like ...
3
votes
1answer
77 views

define different positions in foreach

in the following code \begin{tikzpicture} \foreach \pos in {0,...,5} { \pic at (1.85*\pos,0) {cross}; \node[formula] at ($(1.85*\pos,0)+(0.4,0.4)$) {Na}; } \end{tikzpicture} can ...
2
votes
1answer
88 views

tikz foreach loop with two variables without using slash

So I am trying to draw the figure from this question in tikz. I have two "lists" of mathematical expressions, say x and y which have same number of elements, and I want this line to be repeated for so ...
4
votes
1answer
56 views

Code with foreach AND coordinate does not compile - but if i remove one or the other, it compiles

Based on this question i did some experiments with tikzset, coordinates and foreach. The following code plots four times the same thing. Twice with and twice without a tikzset. Twice with and twice ...
3
votes
1answer
17 views

Efficiently applying the same patch to several bibdrivers

In this answer to a question about getting Biblatex to print the ISSN field for books, I suggest a solution which uses the \xpatchbibdriver command of the xpatch package: \xpatchbibdriver{book}{% ...
10
votes
1answer
128 views

pgfmathsetmacro issue in foreach

I am trying to use \pgfmathsetmacro inside a foreach loop to connect nodes which are adjacent and named according to position as follows: \foreach \src in {0,...,\T}{ ...
2
votes
3answers
100 views

Evaluate binomial coefficient with \pgfmathtruncatemacro

How is it possible to evaluate complex formulas like \binom{2^{4}-3}{2^3} with \pgfmathtruncatemacro ? I want this to evaluate to 1287. What already works: \begin{tikzpicture} \foreach \l ...
2
votes
2answers
23 views

Lists with multiline elements to iterate with foreach

I want to have a list of elements that may contain new lines on them. For example, \def\mylist{ test, test with enter, end } However, if I try to iterate over that list with \foreach i get a ! ...
1
vote
2answers
69 views

Automated matrix padding in tikz

I encounter an error with the following code : \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning,shapes.multipart, fit,backgrounds,calc} \begin{document} \node[matrix, ...
4
votes
1answer
81 views

LaTeX foreach with non-numerical indices

I'm writing a simple script to produce randomized cards that I use to teach statistical ideas in my class. I've used Tikz to produce randomized cards that all follow the layout that I want using ...
3
votes
2answers
86 views

\foreach element of a table column

I want to code a \foreach for each element in the column Label of my.dat. Something like: \foreach \L[count=\i] in column {Label} from {my.dat} What is the right syntax? I can't find anywhere. ...
-1
votes
1answer
64 views

How to increase the \foreach number in tikz

\foreach \z in {0,1,...,150}{ \draw [fill=black] (\z, {add(101/add(1,2*\z),-\z*\z/add(1,2*\z))}) circle (1pt);} Dimension too large.
2
votes
2answers
52 views

Input a list of files

I want to include multiple files in my source. The files are to be included in a file liste.tex in the following format: fichier1.tex files2.tex test3.tex .... I relied on answering the questions ...
6
votes
1answer
65 views

Using tikz \foreach inside an \edef

I would like to use \foreach inside an \edef, for example to define a set of random points as follows: \edef\mypoints{% \foreach \x in {0,.1,...,1} {\pgfmathparse{rand} ...
3
votes
1answer
115 views

Tikz foreach does not work well

My goal is to create a complete bipartite graph with assigning numbers to the vertices. My idea was to use \foreach, which worked well for creating the vertices, but I couldn't add the numbers. What ...
2
votes
0answers
51 views

Defining and expanding macros In loops

I want to define and expand macros in a \foreach loop. The names of the macros depend on the iteration step. The macros I define are interpreted as strings rather than sets of numbers that I actually ...
2
votes
4answers
125 views

TikZ's \foreach \x/\y in… the set of running indices being a macro

Please look at this minimal example which contains my question: \documentclass[english]{article} \usepackage{tikz,ifthen,listings} \newcommand\IndexListOne{1,2,3} ...
5
votes
2answers
108 views

error using \foreach with ellipse directions

The following line \foreach \x / \y in {0.422201/1.000000,1.000000/2.368540} {\draw[very thin] (0,0) ellipse (\x and \y)}; gives ERROR: Package PGF Math Error: Unknown operator `a' or `an' (in ...
2
votes
1answer
32 views

foreach and renewcommand

I want renew a variable in a foreach loop, but my codes won't work. Please help! \documentclass{article} \usepackage{pgffor} \newcommand\tests{ \newcommand\mytext{aaa} \foreach \i in ...
5
votes
3answers
272 views

pgfplots: use foreach inside addplot

I want to add a bunch of evenly spaced vertical lines to a plot using \foreach. I can do it like this: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.10} ...
2
votes
1answer
109 views

Print iteration counter in for loop

I am new using for loops in latex, and not sure if the following is possible. This is basically what I am trying to achieve: \documentclass{article} \begin{document} \foreach \x in {a,b,c} { ...
1
vote
1answer
60 views

How can I use \foreach to place nodes in a pgfplots axis?

I am trying to foreach over some coordinates to place nodes at whilst inside an axis environment. I followed the advice here, but I am getting nowhere; the following fails with error ! Argument of ...
0
votes
1answer
79 views

Insert pdf pages side by side

I have two versions (A4 size) of a document: new.pdf and old.pdf. I'd like to share with co-authors a pdf with pages side by side, so should be easy to compare the changes in the output. Here ...
6
votes
5answers
511 views

How can I draw several polygons on the same base line using TikZ?

I want to construct a figure that will be symmetrical polygons on the same base. So, there is an equilateral triangle, a square, a pentagon, a hexagon, etc. one side of all these is the same ...
0
votes
1answer
130 views

How to color multiple plots in rainbow colors?

I´m trying to color multiple curves of a line in rainbow colors wiht tikz. I´ve found the [wave] option for color from the xcolor pagacke, but I can't get it to work inside tikz's draw command. ...
3
votes
1answer
226 views

tikz foreach calculations

I am trying to do a simple calculation with the tikz foreach, but it does something very suprising: \documentclass{article} \usepackage{tikz} \usepackage[active,tightpage]{preview} ...
3
votes
0answers
57 views

trying to load images with foreach

Im trying to load images from a directory but I cant because I dont know why \i does not indicates the number, code searches the directory and the files were not found.. \documentclass{beamer} ...
2
votes
2answers
166 views

Accessing value in forloop

This code is not compiling and creates an error "Missing number, treated as zero". \newcounter{x} \forloop{x}{0}{\value{x} < 5}{ value is \value{x} \\ } How can the value of x be printed ...
5
votes
1answer
84 views

Use \foreach in non-Tikz context

I want to create my own footnote-command for floating environments: %begin figure bla\myFootnote{XXX} blabla\myFootnote{YYY} blabla\myFootnote{ZZZ} %end figure some text \printSavedFootnotes The ...
1
vote
1answer
57 views

adding labels after the arcs with a foreach loop

I have this code that generates a cycle graph with labels in the arcs (reference here): \documentclass[border=2pt,tikz]{standalone} \usepackage{wasysym} ...
3
votes
2answers
162 views

leading zero in \foreach of a TikZ calendar

The calendar TikZ library creates for each day a node called (<name>-<year>-<month>-<day>). But there is a leading zero for <day> from 1 to 9, that is, to use the node of ...
5
votes
3answers
119 views

foreach loop for adding arcs using commands path and edge

i want to know how to use the foreach loop for adding arcs using commands \path and edge. For instance, the following code generates a cycle and the task is to add the arcs not manually: ...
5
votes
1answer
159 views

tikz: help with this foreach loop

i'm getting an error in this code, can someone help me. I'm trying to create two concentric cycles, but it doesn't seems to work. \def\n{10} \defn\radio{3.00cm} \begin{tikzpicture} \foreach \x in ...
2
votes
3answers
235 views

Drawing an array of nodes using the foreach-construct

I sometimes need to visualize an array-like structure with tikz. I use nodes for array elements and position the next node right of the previous one, i.e., like this: \node[draw,rectangle] (n0) ...
5
votes
1answer
308 views

Changing color in foreach

I'm trying to create a picture like this: where I have a grid and I depict the boxes shifting by colors changing. I was hoping I could achieve this effect easily in Tikz with a foreach (I am very ...
4
votes
0answers
56 views

Using dynamic bounds in a tikz \foreach [duplicate]

I'm trying to draw something like an inner box integral approximation but with dynamic upper bound, lower bound, and stepsize. Unfortunately the \foreach command of tikz is not cooperating. ...
2
votes
1answer
137 views

One coordinate a function, the other a Brownian Motion

I am new with Tikz and I have a question which I did not manage to solve looking at other posts. I was wondering how to draw a figure in 2D, in which the first component (the x) is a function of x ...
5
votes
1answer
164 views

Why is my minipage in beamer foreach environment moving horizontally?

I am preparing a presentation with several very similar slides so I would like to use a \foreach loop with \only to generate them. The frames also contains minipages and these minipages seem to cause ...