4
votes
1answer
40 views

TikZ: issue with lines in foreach loop

\documentclass[tikz]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \coordinate (h) at (0, 3); \coordinate (O) at (0, 0); \draw (O) -- +(-3, 0); \draw[-latex] (O) -- ...
7
votes
2answers
149 views

How to make a portion of curve red using TikZ?

I want to make the the closed loop part of the figure by "ultra red" color only and the other part by blue. (from (2,0) .. (0,0.93) .. (-0.93,0) .. (0,-0.93) .. (2,0)) \documentclass{standalone} ...
5
votes
1answer
218 views

Plotting loops: trajectories and directions

Plotting loops: trajectories have directions. How to plot the following figures using tikz 1st I start to plot the 2nd fig using the code \begin{tikzpicture} \draw (3,2) ellipse (.5cm and ...
11
votes
1answer
116 views

PGF's `foreach` recognises when there are no list items and doesn't run the code. Is this guaranteed?

The PGF \foreach macro behaves differently when the item list is totally empty than it does when a single item happens to be empty. \documentclass{article} \usepackage{pgffor} \begin{document} ...
6
votes
3answers
169 views

How can I get these two nested \foreach loops to work?

I try to use nested \foreach loops to create edges between many nodes. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node (a) at (0, 1) {}; \node (b) at (0, ...
4
votes
2answers
128 views

How to get the number of elements in a \foreach loop?

Does the PGF command \foreach provide a simple possibility to get the number of elements iterated? It has a parameter count to hold the current element number, so a workaround is to iterate the list ...
6
votes
2answers
81 views

Extra row appearing in table assembled in pgf for loop

I'm constructing a table one line at time inside a \pgfplotsforeachungrouped. An unwanted line appears after the \hline at the end of the last round of the loop as evidenced by the lone decimal point ...
6
votes
1answer
294 views

TikZ Self Loops Style Question

I have a question on how to "style" the self loops in my diagram. Here is my preamble: \documentclass[letterpaper]{tufte-handout} % Additional LaTeX Packages \usepackage{amsmath} ...
5
votes
3answers
289 views

Nested lists in \foreach loop in TikZ

I want to draw a bunch of nodes with different styles (a, b, ...) at different points (named 00, 01, ...). I am using the following code: \foreach \n/\lst in { a/{00, 14, 20, 34}, b/{01, 11, 23, ...
5
votes
2answers
223 views

Problems using `addlegendentry` in a loop with `pfgplots`

I have some spectra to plot, which I exported from the Siemens Xray toolbox, which works nicely with pgfplots. Since these are multiple files that look the same I think I can do it with a for loop, ...
5
votes
2answers
256 views

How can I label TikZ-graphs on four vertices with a loop?

I need to draw all these simple labelled graphs on four vertices. Anyway, can I do this in a quick manner with a loop? And put them in an array? I have already drawn all unlabelled simple graphs on ...
2
votes
2answers
290 views

TikZ: drawing an evolution of an ellipse to a hyperbola with the same focus

Is there a high speed way to draw the evolution of an ellipse, to a parabola, and then into a few hyperbolas with the same focus? From the picture, we see that we start out with three elliptical ...
8
votes
1answer
292 views

TikZ: Automating a process with a for loop instead of coding in each piece

I am positive I could create the incoming hyperbolas and then the deflections by the planet by hand for each one, but how the image is set up conjures up the felling this could be done through ...
4
votes
1answer
164 views

Running out of main memory when using loops in TikZ

I have a TikZ drawing (namely, pairs of rulers) that I want to replicate 12 times, side by side. I'm using foreach constructs to help me in this process and to draw the 5-cm, 1-cm and 1-mm ticks for ...
2
votes
1answer
169 views

How to insert N images using TikZ's \foreach?

I'd like to avoid having to copy & paste the same code 50 times in my input file, so I'm trying to use the automation offered by TikZ's \foreach. I do not know why this code generates 101 errors. ...
3
votes
0answers
321 views

“No shape named intersection-1 is known” error in TikZ [closed]

I want to draw a circle with arrows ending not perpendicular but straight on the surface. I managed so far to draw the paths I need and I already read about the naming of paths, but I get an error as ...
3
votes
1answer
305 views

Automated table for excercise points in tikz

I'm a computer science student. And I write most of my excercises in LaTeX. So I often have to create a table for excercise points, with different numbers of excercises and different amounts of points ...
6
votes
2answers
418 views

How to decrease the counter in tikz foreach loop

I have the following code: \documentclass[11pt]{article} \usepackage[a4paper]{geometry} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{tikz} \usetikzlibrary{positioning} ...
4
votes
1answer
242 views

Continuing a TikZ animation with \onslide after a \foreach loop

I want to produce an animation in a tikzpicture environment in Beamer. The animation consists in a series of slides produced by combining \foreach and \onslide, which works fine. I then want to ...
2
votes
2answers
143 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 ...
5
votes
2answers
255 views

Parallel loop [python-like zip] in Tikz

An easy way to write axis labels in Tikz is: \foreach \x/\xtext in {-1,-0.5,0.5,1} \draw[very thin,gray] (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\xtext$}; Is it possible to have something ...
4
votes
1answer
414 views

Adjusting font size for fake perspective

I'd like to add text on the paths on the left side with font size continuously adjusted from \Huge to \tiny to achieve a perspective like effect. The font size steps shouldn't be \Huge, \huge, \LARGE, ...
3
votes
2answers
214 views

having problems using arrayjobx with tikz - how can i use arrays in tikz?

I need the help of some smart people ;) I want to draw a picture with TikZ, which is heavily based on randomization and I want to make it quite parametrized. It's actually a graph of n nodes where ...
4
votes
2answers
702 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
269 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]{% ...
8
votes
2answers
340 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?
1
vote
0answers
438 views

Generate trees based on number of nodes and children allowed [closed]

I am doing an experiment, and would like to generate images of Binary Trees and Exponential Trees using LaTeX. The difference between these two structures is the number of children allowed per node ...
6
votes
1answer
247 views

\foreach with indexed names of curves

I am constructing several curves, which are all constructed differently, but they have path name=lambda1, ..., lambda4. Later, I intersect each of them with one path. Attached is a working minimal ...
11
votes
4answers
3k views

PGF/TikZ: How to store strings in array?

I'm trying to generate a lot of name badges. I'm wondering, is it possible to store the names as strings in one array, according to the PGF manual: ...
6
votes
1answer
480 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 ...
7
votes
1answer
561 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, ...
8
votes
2answers
833 views

While loops in TikZ?

Is it possible to have while loops in TikZ, or some equivalent loop which only terminates after a certain condition?
5
votes
1answer
430 views

Use a loop to generate a list for another (foreach) loop

Is it possible to use a loop to generate a list for a foreach loop? More specifically I want the following: Consider the following answer to a question I asked some time ago: ...
11
votes
1answer
855 views

Possible to combine “…” and “x/y” in TikZ's foreach?

I'll start with a simple, minimal non-working example: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \x/\y in {1/20,2/18,...,10/2} \node at (\x,0) {\y}; ...
11
votes
2answers
2k views

Variables in TikZ

I use TikZ to draw graphics in LaTeX. I'd like to do arithmetic on variables. For example I haves nodes named after N-1 and N-2 and I'd like to create the N-3 and N-4 nodes as +2 from the first nodes. ...
5
votes
1answer
537 views

How to generate named nodes from the counter used in `foreach` in TikZ?

I'm trying to generate multiple nodes in TikZ using the foreach operator, but whatever I try I get compilation errors. I need all nodes to be named in order to draw edges between them. Having read ...
1
vote
1answer
196 views

Looping and linking with TikZ

How would you build a grid using a nested foreach, defining one node for each iteration? If I were coding in Python, I would write: nodes = {} for i in range(10): for j in range(5): ...
3
votes
1answer
686 views

How to create lists in tikz

I would like to create lists and use them in tikz \foreach loops. Example: \newcommand{\createSquareList}[1]{ this is the part I do not know } \foreach \n in \createSquareList{5} { % do ...
2
votes
1answer
386 views

Place symbols/nodes at intersection between an arc and some horizontal lines with \foreach in TikZ

I'd like to place an symbol I've defined at all the intersection point between an arc and some horizontal lines: I know how to use \foreach for other cases, but I'm really not sure how to setup the ...
14
votes
1answer
3k views

Using double for-loop in tikz

In the manual one can find the ... option to obtain a range in the for-loop. For example: \foreach \x in {0,0.1,...,6} {\x, } On the other hand, one can have a for-loop which runs over two ...
2
votes
1answer
669 views

using foreach to draw a chain with a branch

This is an extension to How to draw the border of a node using late options I'm drawing a chain of nodes with different colors using foreach from tikz. Now I want to add a branch, also using foreach. ...
3
votes
1answer
487 views

How to include multiple images inside a TikZ loop

I have a case, where my files are named images_001.png .... images_011.png. I tried to put them like this: \def\filelists{1/{"t0_01"},2/{"038"}, 3/{"050"},4/{"060"}} \foreach \i\element in ...
2
votes
2answers
757 views

pgfplots: setlength inside foreach

I have the following code, where the size of the cube marks is set to \x inside a foreach loop: \begin{tikzpicture} \begin{axis}[axis lines=none] \newlength{\mylen} \foreach \x in {1,2,...,10} ...
6
votes
2answers
4k 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
337 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
477 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, ...
4
votes
1answer
1k views

Tikz array as argument

Problem I'm drawing flow diagrams in Tikz, and they basically include a header, followed by a list of flow components set below an arrow. I've written functions to take arguments in Tikz before, but ...
22
votes
2answers
1k views

naming paths inside a TikZ foreach loop

Is it possible to create named paths inside a foreach loop with the name depending on the counter? I want to write something like \documentclass{article} \usepackage{tikz} ...