7
votes
1answer
198 views

Tikz binomial distribution

I'm trying to plot the pmf of the binomial distribution for particular values of N and p. For example, when N=10 and p=0.5: \documentclass{article} \usepackage{amsmath} \usepackage{pgfplots} ...
3
votes
1answer
82 views

two variables foreach loop problem

I want to draw a pulse train on which I write some information like the corresponding angle, etc... But I think I've got a problem with the two variables foreach loop because I can't even compile ...
8
votes
1answer
80 views

drawing path in foreach loop with pgfsetmacro

I have N points on a circle, I want to draw the intersection of the convex hulls of all sets of N-k consecutive points. The points are not evenly spaced. The values of N and k (and the actual angles ...
5
votes
2answers
94 views

How to use \x from \foreach loop in the parameters of \draw in tikz

In order to make it simple, I want to draw concentric circles fading out with something like \foreach \x in {1,1.5,...,4} \draw[color=black!{100-10*\x}!white] (0,0) circle (\x); The problem is I ...
2
votes
1answer
75 views

Calculate label angle from a value list

As a beginner of tex and tikz i stuck on array handling together with foreach. I would like to draw two circle with text along its circumference. \documentclass[tikz]{standalone} ...
9
votes
3answers
269 views

How to tell TikZ to first compute and then display a variable?

I want TikZ to first compute and then display the value of a variable. The question is, for sake of simplicity, based on this concrete example from TeXample.net: \documentclass{article} ...
6
votes
0answers
64 views

tikz foreach loops: is there an equivalent of metapost's step?

I apologise if I'm using and searching with incorrect terminology. This seems an obvious question (to me) so I'm surprised I've not found anything (and so assume I'm missing something). In metapost, ...
1
vote
1answer
63 views

\pgfdeclareshape: how to define anchors in a loop?

I think my question is quite similar to this and this, however I didn't manage to modify the provided solutions to fit my problem. In the following MWE I am trying to define 8 pin anchors in a ...
0
votes
1answer
59 views

How can I connect centers of nodes defined using let in a foreach loop?

I want to create a star polygon using a \foreach loop to make nodes for the vertices and another \foreach loop connecting, say, every 4th node. \documentclass[12pt]{amsart} \usepackage{tikz} ...
2
votes
0answers
67 views

Passing an array type argument for new command

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 ...
0
votes
0answers
16 views

How to debug the “Argument of \XC@definec@lor has an extra }” error in Foreach statement? [duplicate]

First, I draw three nodes each of which has three parts. Everything is OK. The code and the image are as follows. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[]{tikz} ...
7
votes
2answers
186 views

How can I draw an arrowhead only at the end of a path drawn with \foreach?

I want to define a command for drawing some special polygonal lines with pgf/tikz. In these polygonal lines, the line styles are of alternating change. The following is my latex code: ...
4
votes
2answers
152 views

Piecewise linear plot with custom grid

I try to plot a piecewise linear interpolation of a function w on a grid \xn={x1,x2,...,xN} using tikz. I tried using a foreach loop and store the grid as a vector to do that, but it doesn't seem to ...
3
votes
1answer
136 views

My personal TikZ template to be easily changed

Every time I need to plot a simple function (eg. a parabola), I use a self-made TikZ template that is: \documentclass{minimal} \usepackage{pgfplots} \pgfplotsset{/pgf/number format/use ...
5
votes
1answer
125 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
181 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
68 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
581 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
118 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
143 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 % ...
6
votes
1answer
121 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] ...
8
votes
2answers
212 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
182 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
141 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
82 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? ...
2
votes
1answer
44 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 ...
5
votes
1answer
121 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
261 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, ...
5
votes
2answers
178 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
89 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 ...
7
votes
2answers
216 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 ...
5
votes
1answer
356 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> ...
7
votes
1answer
200 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
622 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
313 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
323 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
216 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
166 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} ...
4
votes
1answer
975 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
233 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
113 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
99 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
210 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
325 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
302 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
334 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
304 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
158 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
41 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
334 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} ...