{pgfmath} concerns the pgfmath library used for internal computations in TikZ-pgf but which is also available for other computations in (La)TeX.

learn more… | top users | synonyms

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 ...
5
votes
1answer
57 views

pgfplots “Dimension too large” returned when plotting rational function

I've been using pgfplots for graphing for a while, now, and have recently run into a situation where I need to graph rational functions. Most of these have worked out fine, but one has caused me to ...
10
votes
4answers
63 views

Checking for valid floating point number

I want to do the following: I am generating a report which can be set to be in imperial or metric units. All values are originally in metric units, so in the case of imperial units all values should ...
7
votes
3answers
81 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 ...
6
votes
1answer
37 views

How to add a \global before \pgfmathsetmacro?

It seems that one can't add \global before a \pgfmathsetmacro as that yields: You can't use a prefix with `\begingroup'. But that is the functionality I need here. I am trying to compute the ...
6
votes
2answers
61 views

Problem with \pgfmathparse and font style of array elements

There are probably other ways to do that, but I was happy I've found this code working just fine for my needs: \documentclass{article} \usepackage{tikz} \newcounter{grpcnt} \def\groups{grp1, grp2, ...
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? ...
2
votes
0answers
71 views

tikz externalize and pgfmath error

Using external and \pgfmathdeclarefunction at the same time results in ! Illegal parameter number in definition of \pgfmathfloat@expression. ! Package PGF Math Error: Could not parse input '' as a ...
3
votes
1answer
151 views

\pgfplotstabletypeset heatmap: logarithmic scale

I am trying to create my own rendition of this heatmap. My values range anywhere from 1 to 783764. I want to plot them as colors on a logarithmically (base10) scaled colormap. So the values' ...
2
votes
0answers
32 views

How to scale both data and error bars in pgfplots

I am able to scale the data using the y filter option in pgfplots plot object (like here How to scale existing coordinates data in pgfplots?). However the error bars are not rescaled as expected. Is ...
3
votes
1answer
63 views

pgfplots: `nan` in `meta expr` causes “Missing number” error

I want to draw a table/matrix of color-values, where some of the values are missing. Despite having tried using unbounded coords=jump (see this answer), I get the following error: ! Missing number, ...
4
votes
1answer
106 views

pgfplot number format: scientific notation on ticks, without factor 1

I have a pgfplot that is supposed to give me only a colorbar, no other plot. My code was inspired by this question. The logarithmic colorbar code was recycled from this answer and this answer. The ...
5
votes
4answers
440 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 ...
7
votes
1answer
248 views

Gaussian random numbers

The Tikz manual has all sorts of different options regarding math, but the following is the first version which actually worked. Is there a better way to do this? \documentclass{article} ...
13
votes
2answers
107 views

Making a table independent of pgf

I use pgfplotstable to generate tables to be included in online submission to journals. I would like to make my paper independant of pgfplotsable because compilation of the document is made online ...
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
1answer
83 views

Have a new seed in pgfmath more often

I'm using pgfmath in my code since I need some randomness and I want the seed used for the randomness to be updated each time I compile. I read that pgfmath is updating the seed every minute, which is ...
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
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 ...
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
355 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 ...
10
votes
1answer
411 views

How to scale existing coordinates data in pgfplots?

I have a plot with its data, for example \documentclass[]{article} \usepackage[]{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[] \addplot+[%multiply x data by a factor here, multiply y ...
6
votes
1answer
294 views

Tuples in LaTeX

I am learning to use TikZ to draw things in LaTeX. One of the things that TikZ seems to use everywhere for specifying coordinates is a tuple. For example, \begin{tikzpicture} \node[isosceles ...
3
votes
1answer
143 views

How do you use division in LaTeX to adjust parameters?

I would like to define a macro that draw a triangle nested in a triangle. I already have a triangle macro using TikZ that draws a nice triangle given a size. For simplicity, \tr{4} Will create a ...
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
490 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: ...
5
votes
1answer
103 views

Amsmath and tikz - conflict?

I have a problem with: \documentclass{minimal} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{amsmath} \usepackage{tikz} \begin{document} \pgfmathparse{ifthenelse(1<0, ...
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} ...
6
votes
1answer
97 views

Pgfmathresult approximation?

I need to do some simple calculations like these: \documentclass[a4paper,10pt]{article} \usepackage{tikz} \begin{document} \pgfmathparse{1*0.4}\pgfmathresult \pgfmathparse{2*0.4}\pgfmathresult ...
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 ...
5
votes
1answer
188 views

Package PGF Math Error: Sorry, an internal routine of the floating point unit

This type of error (! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number ...) arises when trying to use a predefined list for the ...
5
votes
1answer
160 views

How to preserve lenghts to use with \includegraphics scaling, when calculating them with pgf

This question is related to my earlier question here: How to define a macro that uses image width and height to define a variable for later use . There you can find a full MWE of the problematic code. ...
4
votes
1answer
179 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} ...
0
votes
0answers
24 views

Undefined control sequence error for \pgfkeys when using pgfmath package [duplicate]

Why does this MWE result in an error? \documentclass{article} \usepackage{pgfmath} \pagestyle{empty} \begin{document} \pgfmathparse{atan2(5,2)} \pgfmathresult \end{document} From what I've read ...
8
votes
1answer
95 views

“Argument of \pgfmath@@onquick has an extra }” when using pgfmathsetmacro or pgfmathtruncatemacro with &&-operator inside tabular

When I run the following code... \documentclass{article} \usepackage{tikz} \begin{document} \begin{tabular}{c} \pgfmathsetmacro\foo{(2<3) && (3<4)} \foo \end{tabular} \end{document} ...
7
votes
1answer
186 views

pgfmathprintnumber in bold and/or sans serif

I've set some pgfkeys such as precision=2 and use comma. Now I wonder how do I get the results of \pgfmathprintnumber{123.567} to be bold and/or sans serif? I thought this is easy, but everything ...
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 ...
7
votes
3answers
170 views

Adjusting command behavior based on argument type

I have a following command in my latex document: \newcommand{\ApplyGradient}[1]{ \pgfmathsetmacro{\PercentColor}{100.0*(#1+0.2)/1.3} \textcolor{black!\PercentColor}{#1}} ...
14
votes
1answer
513 views

Simple example of pgfmath

I'm trying a small educational example using pgfmath. I want to calculate the minimum of a list of numbers. More accurately, I have a list of (number,string)-pairs, and I want the minimum of all the ...
5
votes
1answer
71 views

Assign initial value to \pgfmathaccuma

I cannot assign zero initially to \pgfmathaccuma and \pgfmathaccumb. It gives this error: ! Missing number, treated as zero. Then I press s to skip. However, \pgfmathaccumb is always empty! I want ...