4
votes
1answer
105 views

Using modulo operation to draw graph

I have a graph that consists of x and y from Z/11. Is it possible to programmatically draw the lines that have a slope of 2? Like from (0,0) to (5,10) and (6,12) would become (6,1) because of modulo ...
7
votes
3answers
83 views

Is there a simple way of improving the precision of pgfmath for trig functions?

I wanted to build a table of trig values using pgfmath. However, the precision is a bit off. Is there a way to improve this within TikZ? This is related to a similar question I just posted: Is ...
2
votes
1answer
71 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? ...
5
votes
4answers
441 views

Defining a variable in terms of another variable

This is a very elementary question, I hope it is still OK to ask it here. I'd like to do the following \documentclass{article} \usepackage{tikz} \begin{tikzpicture} \def \x {2} ...
4
votes
1answer
46 views

Conflict between eplain urls and pgf(math)

I tried to insert a hyperlink with xetex and eplain, and here is what happens. \input eplain \enablehyperlinks \input pgfmath \href{http://www.google.com}{google} \bye prints this weird error in ...
0
votes
0answers
58 views

draw a piecewise function using PGF/TikZ [duplicate]

How can I draw this piecewise function using PGF/TikZ? f(x) = { x if 0<= x <1, 3-x if 1<=x<=2 }
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 ...
4
votes
1answer
102 views

Addition doesn't work properly with some numbers in TikZ/PGF

I have a problem with very simple calculations in TikZ/PGF. After displaying many calculations properly i ecountered the problem, that pgfmathadd returns 5.40001, if i want to add 1.6 and 3.8, witch i ...
30
votes
3answers
1k views

Programming Conway's Game of Life in LaTeX

My aim is to program Conway's Game of Life in LaTeX, and make the output into an animated PDF. I intend to use PGF/TikZ for this, especially pgfmath, but I'm stuck at the moment because I need to ...
5
votes
3answers
230 views

Why must the independent variable of a function to be plotted be a macro in TikZ?

Consider the following code (taken from Jake's answer) and focus on the variable of the function to be plotted. \documentclass[border=5pt,tikz]{standalone} \begin{document} \begin{tikzpicture} ...
6
votes
1answer
155 views

evaluate a string like `sin(x)+3` with `x` given

I defined a macro that gets as input a string like sin(x)+3, a starting x and an ending x, which is plotted using \addplot from PGFplots. Now I want to evaluate this function for x equal to the ...
4
votes
0answers
46 views

Strange behaviour of tikz plot function [duplicate]

Remarks I'm trying to visualize the difference between an adiabatic curve and an isothermic curve, where the first on follows the equation x^(-5/3) and the latter obeys 1/x. But when I'm trying to ...
11
votes
2answers
217 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 ...
9
votes
2answers
192 views

Calculating Beamer presentation progress excluding appendix

Problem description In trying to calculate the progress of a Beamer presentation, one can use \pgfmathtruncatemacro{\prog}{100*(\insertpagenumber)/(\insertdocumentendpage)} where \prog tracks the ...
7
votes
1answer
246 views

Using pgfmath declared function in pgfplots/tikz commands

The commented rows of the following code give me errors. It seems that functions declared with \pgfmathdeclarefunction do not work with tikz commands... \documentclass{standalone} ...
6
votes
1answer
143 views

When using decorations, how can I calculate with \pgfdecoratedpathlength?

I would like to draw a picture with tikz and use 'decorations' to show a single pulse on a line. Correct: A -- B As you may see my code won't work for more than one segment ( A--C--B ). ...
7
votes
2answers
357 views

Increasing precision in \pgfmathsetmacro

I would like to use \pgfmathprintnumber[/pgf/number format/frac]{\var} where \var is a variable set by \pgfmathsetmacro and I'm having similar difficulties as in this and this question. I'm aware ...
2
votes
0answers
94 views

Programmatically converting an integer into bits with graphical output [duplicate]

I just stumbled upon this interesting question about "how to automatically draw tree diagrams of prime factorization with LaTeX" and it rang a bell. I 'd like to create a command that displays the ...
5
votes
1answer
492 views

How do I get \pgfmathparse to create value rounded to one decimal place?

I'm trying to place a grid over an image to help me place other object where I want on the image. But, I'm having difficulty getting tikz to show coordinates as I wish. Here's my MWE: ...
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
247 views

tikz array indexing

I'm trying to generate glyph plot. The idea is that I've a list of elements with 4 values (0.0 .. 1.0) that represent the value of a particular characteristic. My goal is to connect those points but I ...
4
votes
1answer
181 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} ...
4
votes
1answer
240 views

tikz extending spring with constant number of segments

Is there as simple way to create a pdf animation with tikz of an oscillating mass attached to a spring which extends and compresses as the mass oscillates. The number of "spring elements" should be ...
3
votes
2answers
144 views

Making a specific cell of a dynamically generated tikz matrix BOLD

I want to make specific cells of a dynamically generated tikz matrix bold. I have tried many things: \bfseries, \mathbf, \textbf, \bf, using assume math mode=false in \pgfmathprintnumberto ... Here ...
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 ...
6
votes
1answer
567 views

Computing value using pgfmath for use in coordinates?

Why can't I use the outcome of using pgfmath in a TikZ coordinate? Here is a (minimal) example that does not work: \documentclass[11pt]{article} \usepackage{tikz} \begin{document} ...
5
votes
3answers
692 views

Using mathematical function in PGF/TikZ

I want to use ProbXpos for example to position tic marks and to position line ends. It seems to calculate as I intend, but how can I use the calculated value? The example below prints a sample result ...
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} ...
8
votes
2answers
215 views

Confusion regarding strings and numbers in tikz

I'm using a macro that uses \StrBetween from xstring It seems to be working great. However, when I try to use a value that it returns as a coordinate in a tikz picture, I get a confusing error. ...
5
votes
1answer
439 views

Syntax error using PGF math function in coordinate

I would like to avoid setting too many of the values for the following picture too rigidly. For example, I would like to be able to set the position of point A and forever after that be able to ...
5
votes
1answer
236 views

Referencing a Vertex that has Math Typesetting inside it to make an Edge

I want to create math font inside of my vertex circles, AND draw edges between them. How I typically create network graphs is as follows: \usepackage{tkz-graph} \begin{tikzpicture} ...
9
votes
1answer
251 views

Macros and pgfmath within put in picture environment

I am trying to put some TikZ pictures into a Beamer slide to enhance readability. The position of the TikZ pictures on the slide will depend on how much text comes before. Since there will be many ...
5
votes
3answers
256 views

Correct way of test blank element in array

I'm trying to test whether an element in a defined list (array) is "empty." I tried using the \empty macro, or putting white spaces inside the quote, but nothing seems to work. I'm testing the ...
7
votes
2answers
232 views

How to keep hue from going beyond 300° in xcolor/pgf? (Doing math in pgfplotstable)

Ok, this is probably an incredibly trivial question for anyone who knows more about xcolor or pgf or TikZ or whatever really. I tried to use a hue scale for a heat map/color matrix with values ...
4
votes
1answer
105 views

Why does pgffor not calculate correctly?

I have the following problem: I want to draw some moiree effects in tikz. This seems to be no problem. I did it without any error (two circles of trapezia). Now the two rings should be moved a bit. I ...
8
votes
1answer
147 views

Arcs not being properly drawn for some special coordinates

While attempting to draw some geometry diagrams in TikZ, I was having problems drawing an arc to mark off an angle. The arc kept falling too short and would not intersect both rays of the angle. (It ...
0
votes
1answer
299 views

hyperref conflicts with todonotes and chemfig packages

I'm using TexLive 2012 from the openSUSE buildservice publishing repository, and a document that would compile with TeXLive 2011 now effects error messages such as: Package PGF Math Error: The ...
8
votes
1answer
550 views

How to prevent small values from being plotted with nodes near coords?

I'm trying to finalize my first pgfplots chart. I've managed to get is almost the way I would like it to be with thanks to all examples I found here. The last thing I can't seem to figure out is how ...
11
votes
3answers
2k views

\pgfmathsetmacro - dimension too large (biggest value allowed?)

I want to import some data with parameters to parametrize some plots. After importing a table, I assign specific variables of the table to a placeholder by using \pgfplotstablegetelem. And it works ...
10
votes
1answer
2k views

pgfplots and calculations; without fpu 'dimension too large', with fpu 'Illegal unit of measure (pt inserted)'

I'm trying to multiply some numbers that will end up in the legend of a plot. I can't get it to work: If I naively try \pgfmathmultiply, I get a dimension too large error, with the code in MWE 1 ...
13
votes
3answers
576 views

How to find the length of a PGF array?

A few of my macros currently require the user to pass the length of an array along with the array itself. It would be nice if the length could be calculated for them, as the user in question (myself) ...
3
votes
2answers
398 views

Can one pass a pgf array to a pgf math function?

I'd like to define: anglearray(\A,\I,\L) = array(\A,Mod(\I,\L)) + 360*floor((\I+0.1)/\L); but I get strange errors about "! Missing number, treated as zero." and the "array" part appears to ...
4
votes
2answers
1k views

pgf-tikz problem with 'declare function'

I need to make a plot of a non-linear functions. To get familiar with the 'declare function' capability of pgf-tikz, I tried the following code: \documentclass[10pt]{article} \usepackage{amsmath} ...
6
votes
1answer
654 views

User-defined math functions with pgf

I'm trying to use user-defined math functions with pgf to make a plot. The plot will consist of several straight lines given by a function of three arguments. (I know there are easier ways to do this, ...
3
votes
1answer
296 views

Incorrect evaluation of expression? [duplicate]

Possible Duplicate: How can I work around this TikZ bug? I am plotting points on function f(x)=1-x^2/2+x^4/16. Obviously f(x)=-f(x), but PGF does not think so. \documentclass{minimal} ...
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
534 views

TikZ, foreach and sum

I'm trying to create a list of rectangles of various sizes, starting at the end of the previous rectangle. I'm using a foreach loop with a TeX length, but I don't get the result I want, and I really ...
6
votes
3answers
2k views

Print integer without fraction part

In a Tikz Figure, I'm doing some computation and want to print results as label of nodes. The problem is that I only need the integer part of the number to print. I tried with round() function. It ...
2
votes
1answer
631 views

Using an array element to specify end iteration point in TikZ “\foreach”?

Is it possible to access an array and use one of its elements to specify the last iteration point in a TikZ \foreach? I've tried with the code below but I keep getting a compilation error: ! ...
6
votes
1answer
3k views

Using the commands \pgfmathparse and \pgfmathresult

How do I use the commands \pgfmathparse {tan (pi/3 r)} \pgfmathresult to draw the green line in the figure below? \begin{tikzpicture}[>=latex,scale=2] \draw circle (1); \draw[->] (-1.2,0) -- ...