{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

3
votes
0answers
35 views

\pgfmathparse returns a phantom .0.0

\documentclass{minimal} \usepackage{tikz} \begin{document} \pgfmathparse{random(-5,5)} \pgfmathresult \end{document} Works, but I have a .0.0 that not supposed to be here.
5
votes
4answers
264 views

Calculations in minimum width

I'm trying something like this: \begin{tikzpicture}[x=1cm,y=1cm] \newcommand{\mw}[1]{#1+1} \node [minimum width=\mw{1} cm] {}; \end{tikzpicture} My problem is that this is expanded to 1pt + ...
5
votes
1answer
57 views

Automatic cell colouring using cellcolor: Undefined Control Sequence

I am trying to produce a table, using tabularx, where the cells are coloured automatically depending upon their value. I want to use the \cellcolor command as it will fill the whole cell, rather than ...
1
vote
2answers
63 views

Ifthenelse variable equality

Last week I made simple coordinate transformation in order to define \tdplotsetcoord in Cartesian coord. system. My work and support of exp. user can be viewed in this topic. The code looks as ...
10
votes
3answers
276 views

Tikz: how to plot arcsec and arccos?

It is easy to plot arctan and arccot, but got inverse sec and csc functions, It seems difficult. Can anyone do it?
0
votes
1answer
63 views

Combination Function with Factorial - Not correct result - Pgfplots

\begin{tikzpicture} \begin{axis}[ axis lines = left, xlabel = $Number of Elements$, ylabel = {$Combinations=\frac{(n)!}{(n-r)!(r!)}$}, ] %Axis \addplot [ domain=2:10, samples=100, color=red, ] ...
4
votes
1answer
76 views

Difference between \pgfmatharray{\a}{0}, \pgfmathparse{\a[0]}, and \pgfmathparse{array(\a, 0)}

There are at least 4 different (in code a-d) ways to access items in lists/arrays. Out of curiosity I wanted to see what happens with different combinations. I selected 6 different (in code A-F) input ...
4
votes
1answer
42 views

Setting result from pgfmathifthenelse as variable

So I'm trying to set a variable using the value of another variable. Basically something like below: \pgfmathsetmacro{\newVar}{\pgfmathifthenelse{\oldVar==0}{(\x/2)}{\x}} But no matter what I do I ...
5
votes
2answers
143 views

how to determine piecewise constant function representing binary data

I like to define function which represent binary data, but i stuck in this rather simple task ... my NWME is: \documentclass[tikz,border=3mm]{standalone} \begin{document} ...
5
votes
2answers
53 views

How to define pgfmath local variables?

When using pfgmathsetmacro in commands (defined by \newcommand) we have a problem of locality of variables. For instance if you design two functions \newcommand\f[4]{% ...
4
votes
1answer
200 views

A TeX translation of old C code - Evaluating elements of an array *inside* a foreach loop

I'm trying to translate a conceptually simple part of an algorithm, from the original source for the R-engine (written in C) to TeX. This shouldn't take more than some logic trees and for/while loops. ...
6
votes
0answers
133 views

error using pgfsysdriver with tex4ht, only shows up with texlive 2014, ok with texlive 2013

Update: Thanks to the comments below. Using the link by Michal below, it appears this is a known bug but the fix was not in 2014. Doing the change as pointed out in the link below, seems to have fixed ...
2
votes
0answers
54 views

Barchart, Boxplot Data Table PGF Math Errors from mixed format inline data

My code for a horizontal bar chart with a summarizing boxplot is coming together, but I still have a nagging PGF Math problem if I try to plot the boxplot values, which are commented out at the bottom ...
1
vote
1answer
70 views

Problem with algorithm in pgfmath

I coded an algorithm from R with pgfmath: \documentclass{article} \usepackage{tikz} \usetikzlibrary{fpu} \makeatletter \pgfmathdeclarefunction{qnorm}{4}{% \begingroup ...
11
votes
3answers
281 views

Compute denominator and numerator of irreducible fraction from arbitrary fraction

I would like to reduce each fraction i/n to its irreproducible form (and let's assume i is less than n) and displayed not as a \frac fraction but like it is used e.g. in the frame numbers used in ...
0
votes
0answers
34 views

Pgfmath array problem

I have a problem with pgfmath array : it work if defined outside pgfkeys, doesn't work inside. What is the problem ? \documentclass[tikz]{standalone} \usetikzlibrary{calc} ...
2
votes
0answers
76 views

Getting undefined control sequence even the command is defined

I want to add a command to pgfgantt package that draw vertical line at a specified date (like the one for the today line). Here's what' I want to get (green line) : So I looked to pgfgantt.sty to ...
3
votes
1answer
93 views

Extracted coordinates have wrong value

I am unable to get the right coordinate values for (A) and (B) in the following axis. Did I misunderstand some conversion step or is it because of the data? Picture MWE \documentclass[ a4paper ...
4
votes
1answer
100 views

Compute the elevation of a coordinate in TikZ

I'm wracking my brains over a seemingly simple problem. Given a coordinate, I would like to do some computation with its components. More specifically, I want to compute the elevation of a point. ...
6
votes
1answer
65 views

pgf math is not returning the correct results

I have in \pgfmathsetmacros some stored variables. I checked that math on Mathematica when the plotted points came back wrong. \pm\infp is approx \pm 1.51022 and \pm\infn is approx \pm 0.46823. ...
4
votes
1answer
160 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
249 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
93 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
120 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 ...
7
votes
1answer
71 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
77 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
80 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
98 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
209 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
90 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
106 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
164 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
474 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
63 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
59 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 }
5
votes
1answer
120 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
124 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
285 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
127 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 ...
31
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
120 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
250 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
187 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 ...
11
votes
2answers
306 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
223 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 ...
8
votes
1answer
347 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
168 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
559 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 ...
11
votes
1answer
800 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
305 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 ...