0 foreach questions.

8 Complex Count in \foreach for number line

2 answers, 624 views tikz-pgf counters foreach
I am looking to create simple number lines. I have asked a similar question: Resetting numerical labels in \foreach commands on a numberline. But now I am in a different situation. I know how to ...

3 How to store an array of values?

3 answers, 72 views tikz-pgf foreach pgfmath
I need to calculate the mean of a bunch of values generated by a function inside a loop. Is it possible? \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{...

1 How to do arithmetic with variables used in for loop?

1 answers, 26 views foreach variable arithmetic
How can I use arithmetic inside a node's curly brackets? I have this, and it prints for example "0+1" in a circle. I would like to have circles that show the sum of their coordinates. \begin{...

1 How to suppress a join edge in chains when using foreach?

1 answers, 14 views foreach tikz-chains join
How to remove/suppress the edge from node 3 to node 4 in the following code using chains and join? Do I have to split the foreach into two smaller ones? \documentclass[tikz]{standalone} \...

4 Why does “\x-1” not work in node name?

3 answers, 298 views nodes foreach pgfmath
How to fix the error in referring to a node using \x-1? It works in [below left = \x-1] but does not work in \draw[->] (\x-1) to (\x). \documentclass[tikz]{standalone} \usepackage{pgffor,pgfmath}...

3 Update pgfmath macro in foreach loop

I need to update a variable defined in a pgfmathsetmacro command inside a foreach loop. Apparently, the var is only updated when it is used after the update command. Here is a MWE: \begin{tikzpicture}...

13 Shading 25 squares within a square using \foreach

8 answers, 561 views tikz-pgf foreach
In a square of edge length 5*sqrt(2), I have 45 congruent squares of edge length sqrt(2) drawn. I would like to shade 25 of them - 5 of them in each row. I shaded the 5 squares in the bottom row and ...

4 Shading different fractions of the same equilateral triangle using \foreach

3 answers, 98 views tikz-pgf foreach
In the following diagram, I have three views of an equilateral triangle partitioned by smaller congruent equilateral triangles. May I have a suggestion for using \foreach to reduce the repetitive ...

6 Putting repeated symbols along a path with decorations?

1 answers, 332 views tikz-pgf foreach pgf-decorations
I have a drawing of a curved-plate capacitor: \documentclass[]{standalone} \usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture}[ ...

Accessing list of key-value lists as macro argument

0 answers, 24 views macros foreach key-value data-structures
I'm looking to create a macro that takes a list of key-value lists as an argument. I don't know the right data structure that can be used for this kind of situation in LaTeX and also didn't find it ...

4 Color names in foreach loop

2 answers, 312 views tikz-pgf color loops foreach
Edit: I can't delete this question despite it being based on a silly mistake. Please don't waste time reading/answering. I'm trying to draw a row of boxes which alternate colours, and I'm using a \...

7 Macro not working in foreach loop

2 answers, 200 views macros pgfplotstable expansion loops foreach
I'm trying to color the cells in a few columns with different colors, depending on bounds passed as an argument. I would like to have one macro that takes two arguments: a .csv file and a comma ...

pgfplotsforeachungrouped with >2 entries

0 answers, 31 views pgfplots macros foreach
I'm having trouble understanding why \pgfplotsforeachungrouped is breaking in certain spots. Why does this work: \documentclass{article} \usepackage{pgfplotstable} \def\macroOne#1{ #1 } \...

2 trying to load images with foreach [closed]

0 answers, 87 views pgfplots graphics foreach
I'm trying to load images from a directory but I can't because I don't know why \i does not indicate the number, code searches the directory and the files were not found.. \documentclass{beamer} \...

3 \pgfplotsforeachungrouped: how to escape & and \\

1 answers, 121 views matrices loops foreach branching
Disclaimer: I've barely started to learn LaTeX so bear with me. Problem: I use a lot of matrices like this Which I absolutely hate to code manually. Obvious solution would be a nested for loop, ...

8 pgfplots: use foreach inside addplot

3 answers, 1.406 views pgfplots foreach
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} \...

1 Drawing a (4x4)-grid in TikZ using \foreach - riding the wave of \foreach fun [closed]

0 answers, 51 views tikz-pgf foreach
How do I draw a 4x4 grid over the following TikZ diagram using \foreach? Is it preferable to do so with one \foreach command? \documentclass{amsart} \usepackage{mathtools} \usepackage{tikz} \...

4 Fail to get flash effect by given times when using animate package

1 answers, 46 views tikz-pgf foreach animate
Text flash effect is the purpose of the following simple code. Some text should flash for a given times(here is nine times) by a \foreach loop command. However, it can not pass compile. This error ...

7 How to draw a curve from a previously calculated list of points

4 answers, 585 views tikz-pgf foreach
I need to draw a curve from a list of points whose coordinates have been calculated beforehand in a foreach loop I manage to generate my points and to use them independently, I think to manage to ...

1 Passing List in Pgfplotstableset [duplicate]

1 answers, 51 views pgfplots lists pgfplotstable foreach
I'm pretty new to LaTex, so please forgive my sloppy code. I'm trying to create a table from a csv file, and pass a list of colors in so that LaTex will color each cell of the a column of the table ...

8 How to iteratively define coordinates in TikZ?

2 answers, 269 views tikz-pgf foreach coordinates
I'm attempting to iteratively define a coordinate system in TikZ. Essentially, I'd want to replicate the following using a \foreach command: \begin{tikzpicture} \coordinate (A1) at (0,0); \...

How to have mix of numbers and letters in \foreach

I want to run this command \foreach \x [count = \xi] in {L,1} \matrix [matrix of math nodes,left delimiter={[},right delimiter={]},fill=white,ampersand replacement=\&] (mm\x)%give the ...

1 Tikz: foreach loop and hard-coded version producing different output [duplicate]

0 answers, 17 views tikz-pgf foreach
It seems to me that the following two pieces of tikz code should be equivalent; why do they produce different output? Is there a way I can get the output of the hard-coded variant using a loop? \...

2 Setting line start position does not work when using double foreach

2 answers, 41 views tikz-pgf foreach draw
I am drawing a nice diagram with Tikz. The following works perfectly: \foreach \m [ evaluate=\m as \nstart using ((\m - 1) * 4) + 1, evaluate=\m as \nstep using ((\m - 1) * 4) + 2, evaluate=\m as \...

Insert multiple pictures

1 answers, 35 views graphics floats captions loops foreach
I would like to add all my certificates in my LaTeX document as pictures. Is there any way that lets me insert multiple images without captions as follows: Each image fits on one page for example ...

4 Defining a sequence for repeated use in foreach loops

2 answers, 80 views tikz-pgf macros foreach
I have a macro that does exactly what I want when I used it with a literal sequence, but not with a sequence that has been defined for reuse: \documentclass[tikz,14pt,border=10pt]{standalone} %%%< ...

7 TikZ foreach “experience bar”

5 answers, 199 views tikz-pgf tikz-styles foreach
I'm trying to get TikZ to make a sort of experience bar command where I can just call it and enter a number out of say, 6, and it will return that many "filled" dots, and 6 minus that many "unfilled" ...

4 \foreach with two or more variables

2 answers, 273 views tikz-pgf foreach
I often find myself wanting to use some feature that allows me to loop through several sets where the nth item in each list is paired together with the nth item in the other lists. \begin{tikzpicture}...

3 Do not evaluate variable in foreach

0 answers, 53 views tikz-pgf foreach
I have a bunch of variables defined with similar names, e.g.: \def\wstepsA{1/2/0,2/3.5/1}; All variables have a name wsteps + a letter, and I want to iterate over them using tikz's foreach: \...

1 Defining lists for multiple indices in pgfplots

1 answers, 29 views pgfplots lists pgfplotstable foreach
I am trying to plot several column pairs using the \foreach loop command with pgfplotstable in the following way. \documentclass[tikz]{standalone} \usepackage{pgfplots,pgfplotstable} \begin{document} ...

3 Using a string as a coordinate fails

2 answers, 53 views tikz-pgf foreach pgfmath
When I use \pgfresult to get a node label in a \foreach, I have no problem. However, I can't seem to get the syntax right to create a coordinate with the same method. \documentclass{article} \...

5 Passing an array type argument for new command

3 answers, 936 views tikz-pgf macros loops foreach
I've looked around and can't seem to find anywhere, but I was wondering if there is somewhere you can do something like the following: \newcommand{\loopy}[1]{ \begin{tikzpicture} \foreach ...

2 positioning label node depending on slope of a edge

2 answers, 38 views tikz-pgf tikz-styles foreach
I am creating a set of nodes with a foreach. After that i am drawing a edge between them that should show a value in the middle above the line. Unfortunately there are some situations where the line ...

2 Increase all x-coordinates with help of a foreach loop

1 answers, 36 views tikz-pgf foreach
Given a figure of two lines with x and y coordinates, I want to duplicate the figure and increase all x coordinates by the same integer (in this example by 3). I was trying to use a foreach loop, but ...

4 tikz: Bug in 'intersections' library when naming paths inside loop?

1 answers, 60 views tikz-pgf foreach intersections
I draw two circles and name their path inside a \foreach loop. Trying to name intersections of these two paths throws an error unless I name a third path. \documentclass{article} \usepackage{tikz} \...

4 How can make scope for rotating one disc around an axis?

I have a rigid body formed by one disc (D) and one rod (T): -i want to draw the rotation of the disc around the j_1 axis -i want the to make a scope for moving the disc on the stem and rotate it ...

! TeX capacity exceeded, sorry [main memory size=5000000]. for foreach

1 answers, 105 views tikz-pgf foreach pgfmathparse
I was blocked on this point, I'm going to compile a code in which I'm using the command foreach: \pgfmathtruncatemacro{\iar}{{\RodLength*\iBngle/180}}%L=\iBngle*x=\RodLength*\iBngle/360%360 ou 180 ...

1 \tikzmark in \foreach loop problem

1 answers, 38 views foreach tikzmark
The use of \tikzmark in a \foreach loop leads to this error message : ! Undefined control sequence. \tikzmark ...reid \@undefined \let \tikzmark@next ...

1 Missing \endcsname inserted in table contents defined within a foreach loop

1 answers, 61 views tables counters pgfplotstable foreach
! Missing \endcsname inserted. \countuno l.67 } From what I've seen about this error the fact that it is a tex error makes it very difficult to pinpoint its origins. Hopefully ...

7 Misunderstanding tikz foreach loop

3 answers, 280 views tikz-pgf foreach automation
I have two diagrams (both are supposed to be the same), one with explicit draw and node commands, the other one with foreach loops. Obviously, I don't understand foreach loops, as I can only get one ...

2 Missing } error from multiple “\immedite\write”s within a foreach loop; the current plot has no coordinates error with gnuplot

1 answers, 35 views pgfplots conditionals foreach gnuplot write
I suspect that these errors are coming from a section of code in which I loop through a master data file and restructure it so that I can give the newly made file as an argument to pgfplots. If I ...

2 draw line between points given by single command

1 answers, 63 views tikz-pgf plot foreach
What I want to do is draw a line between points that are defined in a command like this but without the connect to (0,0): \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{...

2 Missing \endgroup error with ifs nested in foreach and pgf calculations

\documentclass{article} \usepackage{pgfplots, pgfplotstable} \usepackage{filecontents} \usepackage{indentfirst} \usepackage{amsmath} \usepackage{float} \usepackage{hhline} \usepackage{multirow} \...

two disc in rotation around z-axis using tikz-3dplot?

1 answers, 116 views tikz-pgf foreach animations tikz-3dplot
I am beginner with tikz-3dplot, I want to draw this figure I used the explanation given in John Kormylo, \documentclass[tikz]{standalone} \usepackage{tikz,tikz-3dplot} \usetikzlibrary{patterns}% ...

7 How to detect “empty” elements inside a tikz \foreach statement

3 answers, 136 views tikz-pgf macros foreach
I want to define a macro that feeds its contents into a tikz \foreach statement, for example: \newcommand\Macro[1]{ \foreach \x in {#1} {x=\x.} } which is then used as \Macro{1,2,3,4}. Sometimes, I ...

1 Pythagorean spiral: Problem with \foreach and \pgfmathresult?

1 answers, 43 views tikz-pgf foreach
The code below shows the problem. There are two tikzpictures. The first is the code expanded and this works. The second is the same code but put within a \foreach loop. This doesn't work. I assume ...

1 adding a constant to a foreach counter? [duplicate]

1 answers, 84 views tikz-pgf foreach
Is there any way to define a new value that is a counter + a constant? e.g. \foreach\k in {0,1,...,7} { \def\m % ???? I want to make m=k+4 \draw[->] (box\k) -- (box\m); }