4
votes
1answer
65 views

How can I automate the generation of this dynamic-programming graph?

I would like to draw the following dynamical programming graph. I believe it could be sped by using the foreach syntax. The code I have started to write is \documentclass[tikz, convert = ...
5
votes
1answer
122 views

No shape is known for just created foreach nodes

This can be similarly formulated to Why are just-created TikZ shapes "unknown"?; but its slightly different. Here is the MWE: \documentclass[% 12pt, journal, onecolumn, twoside, draftcls, ...
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) -- ...
8
votes
1answer
165 views

Increments in \foreach loop with two variables, TikZ

I'm trying to draw a stack of arrows at different angles in a \foreach loop in TikZ. I don't want to have to declare every z coordinate and angle manually so I was using the {1,2,...,10} syntax but ...
3
votes
1answer
78 views

Retain coordinate value in tikz foreach loop

I would like to retain a computed coordinate value from one step of a tikz foreach loop to the next. In the code below, I would like the increment in the y-value to depend on the previous y-value, ...
5
votes
1answer
68 views

Why does this \pgfmathparse not work outside the \foreach loop?

The LaTeX code below builds in Sublime Text 2 and gives the results: 7, -3.0, 4, -9.0, 11, -9.0, 1, two, 3.0, IV, cinq, sechs, 7.0, But it gives the following errors when I remove the % ...
5
votes
1answer
84 views

Why doesn't a \foreach variable work in \draw in an \axis?

I'm finding some weird behavior with TikZ's \foreach within an \begin{axis} environment. This works: \foreach \x in {-2,-1,...,2} { \addplot[thick, domain=0.05+(\x*2-1)*pi/2:+(\x*2+1)*pi/2-0.05] ...
7
votes
2answers
133 views

An application of \foreach command in TikZ to generate labels

I would like ask you to help me solve the following application of foreach of TikZ package. By means of the following code: \documentclass{article} \usepackage{tikz} \begin{document} ...
6
votes
1answer
110 views

\foreach problem

I have the following problem I want to avoid a \foreach loop in a macro if not necessary, but I don't know how to do a test in a tikz picture, I undersand why \ifthenelse can not work. In my example ...
6
votes
3answers
125 views

How can we correctly implement a list of two (calculated) variables?

I want to use foreach to loop through two variables at the same time, in Tikz. I'd like to go through the variable \y from 0 to 7. At the same time, I'd like to go through \yy from 0 to 14, by ...
2
votes
1answer
70 views

Pointing to a node with calculated name, why do I get to the east, not to the center?

It seems like I'm doing something wrong when using foreach variables to indicate node numbers. The two foreach loops are anchoring the paths to the east of each node. Why does this happen? ...
1
vote
1answer
40 views

PGF’s \foreach can’t replace in [start chain=\here]?

Here in TikZ/PGF, I need two lines of dots to connect them later. – I make those dots with chains in a \foreach loop. But I can’t get the naming to work in the loop. The code below works, but ...
4
votes
1answer
80 views

Pass a list through pgfkey

I'm declaring a new shape [which looks like an Integrated Circuit]. One of the options I want to provide for this shape should be a list of positive integers with arbitrary length [which configures ...
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
1answer
84 views

\alph without counters

When I iterate numbers with TikZ \foreach, they are stored in a macro. Now, when I need the letter corresponding to this macro, I can only convert it by saving it to a counter and then receiving it ...
6
votes
2answers
156 views

Creating anchors in a shape with a \foreach loop

I was playing around with this question, and in particular tried to modify and expand the linked example. It works fine, but there is an error when I try to use a \foreach loop to define the different ...
4
votes
1answer
186 views

(x)ifthen in TikZ

I am searching for a way to conditionally handle some items in a TikZ \foreach specially using an \ifthenelse condition. However, the compiler responds ! Undefined control sequence. <argument> ...
6
votes
1answer
125 views

using computations with \foreach in tikz

I am trying to learn \foreach in TikZ and I am confused because of all the errors I get. Here is a code sample I tried that gave me: ForeachEvaluateTest.tex:0:File ended while scanning use of ...
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, ...
11
votes
2answers
216 views

\pgfmath and \foreach in TikZ

I am quite new to TikZ. I have the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{chains} \begin{document} \begin{tikzpicture}[start chain=circle placed ...
1
vote
1answer
251 views

Drawing TikZ pictures step by step for beamer slides [duplicate]

I want to uncover/draw a picture bit by bit for beamer slides. I imagined that using \only inside a \foreach loop should work, for instance: \documentclass{beamer} \usepackage{tikz} \begin{document} ...
8
votes
4answers
199 views

Why doesn't this code combining \foreach with \newtheorem work?

Here is an example document. \documentclass[a4paper]{amsart} \usepackage{tikz} \theoremstyle{definition} \newtheorem{baseTheorem}{Base Theorem}[section] \foreach \x in ...
4
votes
1answer
135 views

number format in \pgfmathsetmacro for auto-foldernaming in tikz \foreach environment

What I want to do is creating automatically the filenames of the datafiles inside a foreachloop in tikz. Maybe it's better to show a minimal example first: \documentclass{standalone} ...
3
votes
1answer
684 views

TikZ: using name intersections to define a node

Two questions: What is going wrong with these nodes that are defined from the intersections? Can this be automated with \foreach syntax to find the other vectors for the 2nd point? I couldn't ...
7
votes
1answer
171 views

double foreach for color shifting nodes

I want to draw the bottom series of circles: Here is my code: \documentclass[margin=.5cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[every node/.style={circle}] \foreach ...
5
votes
1answer
102 views

change numbering when using \foreach to assign numbers for aid lines in a diagram

\documentclass[11pt]{article} \usepackage{xfrac, array, tabu, multirow, graphicx, setspace, dcolumn, tikz} \usepackage[fleqn]{mathtools} \usepackage[ngerman]{babel} \usepackage[applemac]{inputenc} ...
5
votes
1answer
79 views

TikZ: Can a \foreach command run inside decoration = {markings,?

Can I use \foreach inside of decoration = {markings, ...? \documentclass[convert = false, tikz]{standalone} \usetikzlibrary{decorations.markings} \usetikzlibrary{arrows} \begin{document} ...
7
votes
2answers
182 views

TikZ: naming paths in a \foreach and accessing them later

\documentclass[convert = false, tikz]{standalone} \usetikzlibrary{calc} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \coordinate (P1) at (60:4cm); \coordinate (P2) at ...
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
291 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 ...
5
votes
2answers
277 views

TikZ: Combining multiple paths in and outside foreach

I am trying to generate a path from a list of directions (as seen on the numpad). The coordinates are generated correctly, but because I use multiple call to \path the arrowheads are drawn on each ...
7
votes
2answers
250 views

TikZ: \foreach in macro with argument as list

The code below generates: What I expect is: Why does the \foreach seem to treat the entire list as one value? How do I fix it? \documentclass{article} \usepackage{xparse} \usepackage{xstring} ...
2
votes
1answer
132 views

Error compilation tikz, intersection & foreach

I want to compile this code (using PDFLaTeX) \documentclass[12pt]{article} \usepackage[ansinew]{inputenc} \usepackage[T1]{fontenc} \usepackage{tikz} \usepackage{color} ...
1
vote
0answers
39 views

Iterate over certain matrix cells [duplicate]

I have a matrix and want to reference several nodes of this matrix. How do I add a line for some of the cells? I came up with this: \documentclass[12pt]{scrbook} \usepackage{tikz} ...
4
votes
1answer
180 views

Trouble using pgfmathsetmacro in foreach loop more than once

I'm trying to draw a series of lines where the x-coordinate is given by a geometric sequence, as in the following example: \begin{tikzpicture} \foreach \i in {0,...,3} ...
5
votes
1answer
227 views

Complex Count in \foreach for number line

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 ...
28
votes
3answers
616 views

Why doesn't TikZ's \foreach iterate over the last element of the list?

This code \documentclass{report} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[dashed] (1,-1) -- (1,2) node[above] {$1$}; \draw[dashed] (2,-1) -- (2,2) node[above] {$2$}; \foreach ...
3
votes
1answer
110 views

PGF's \foreach when list requires completion

Please is there anything I am doing wrong that PGF's \foreach is failing here? \def\alist{} \foreach\x in {% 2pt_A,4pt_A,...pt_A,10pt_A }{% \xdef\alist{\alist\ifx\alist\@empty\else,\fi\x}% } ...
7
votes
2answers
271 views

Resetting numerical labels in \foreach commands on a numberline

I am looking to create quick number lines. What I have so far is this: \documentclass[letterpaper,12pt]{book} \usepackage{tikz} \usetikzlibrary{shapes,snakes,backgrounds,arrows} \begin{document} ...
4
votes
2answers
216 views

How to use declared TikZ functions in \foreach condition?

How is it possible to use a declare function in the condition of \foreach? Here's my MWE: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[declare function={a = 0; b = ...
7
votes
1answer
410 views

Tikz: \foreach and axis environment incompatibility

I'm trying to plot a figure with TikZ. I have a few .txt files with the coordinates of the curves that I want to plot, in a list such as file2.txt, file4.txt, ... file30.txt and I want to add ...
9
votes
1answer
2k views

TikZ \foreach loop evaluate variable using pgfmath function

I have problem with defining a new variable within the \foreach loop using the evaluate option using a pgfmath function: \documentclass{article} \usepackage{tikz} \begin{document} ...
6
votes
1answer
184 views

Determining tikz drawing style, depending on the values of two nested loop iterators

So the question is a tikz one! Assume that you are drawing things inside two nested foreach loops in tikz, and the iterator variables are \x and \y. What I'd like to obtain is to be able to specify a ...
5
votes
1answer
381 views

Syntax for smoothing a coordinate plot with the foreach command

Currently implementing the solution of Curve synthesis - Adding two curves to get another one. I would like to smooth out the resulting curve. The present code: % red line \path[red,name path=one] ...
7
votes
2answers
223 views

Using foreach loop in TikZ to plot at non-uniform locations

As a Teaching Assistant for a class, I am trying to draw a seating chart for the professor. The seating chart will have a photo of each student, the student's name, and where the student is sitting in ...
6
votes
1answer
584 views

tikz label coordinates using mathematical expression from foreach variables

\documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \x [count=\xi from 1] in {-3.0,-2.8,...,1.8} \draw[thin] (0,0) ++(\x,2) rectangle ++(0.2, 0.2) ...
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 ...
4
votes
2answers
215 views

Tikz: Using relative positioning and foreach variables

I want to generate a picture that replicates itself and slowy fades out. For that i plan to use a foreach statement and redraw the picture to its rigth. How can i use the foreach variable to position ...
4
votes
0answers
232 views

Drawing a gear with Tikz [duplicate]

I need some help to modify the \gear macro of this answer in order to be able to fill the drawn gear with a solid color. I've tried to move the \draw command outside the loop, but it does not work as ...