{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
2answers
239 views

Undefined control sequence \pgfmath@

Why does the following code give me this error message? Error ERROR: Undefined control sequence. --- TeX said --- \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ l.28 \draw ...
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} ...
10
votes
5answers
2k views

Erf function in LaTeX

Is there a way to easily compute the erf function (or the cumulative distribution function of the normal law) in LaTeX? Currently, I use pgf to make computation, but I did not find a way to compute ...
5
votes
3answers
690 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
140 views

Is it possible to store \pgfmathresult in a pgfkey?

I would like to perform a calculation using \pgfmathparse and then store \pgfmathresult as the value of a pgfkey. \documentclass{article} \usepackage{tikz} \begin{document} ...
5
votes
1answer
289 views

Omit zeros before the decimal point and convert scientific notation in siunitx/pgfmath

I'm trying to automatically format numbers in a way that doesn't convert say .8 to 0.8 while at the same time scientific notation is converted to exponent-free notation. siunitx seems to be able to do ...
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. ...
4
votes
1answer
511 views

Plotting functions with parameters from an external file using gnuplot/pgfplots/pgfplotstable

If I have a table, how can I get the table values and use them as parameters for plotting in pgfplots in gnuplot? In particular, how can multiple curves be plotted with the same functional form from ...
7
votes
3answers
641 views

\uline within a pgfmath expression produces an error

Why does using \uline within a pgfmath expression result in an error? \documentclass{article} \usepackage[normalem]{ulem} \usepackage{tikz} \begin{document} \pgfmathparse{width("\uline{blabla}")} ...
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 ...
1
vote
0answers
110 views

Mel scale conversion in pgfmath, decimal point problem [closed]

I am trying to use pgfmath to convert frequencies in hertz to the mel scale. I'm trying to implement a formula for which I have a Java source and which I have previously implemented with success in ...
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 ...
6
votes
2answers
294 views

Plot x=3 in PGFPlots

I just started to use pgfplots and I'm trying to plot the line x=3 (a line parallel to the y axis where x is 3). I've tried to find an answer on the net, but all the examples always show how to ploy ...
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 ...
6
votes
1answer
284 views

Programming with pgf arrays : how to create an array?

I am trying to do some automatic drawing in tikz. The point is I want to be able to provide the minimal quantity of information to my macro, and still have it work. More precisely (but without ...
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 ...
2
votes
1answer
126 views

Use result from pgfmath with xifthen

I try to use the results of pgfmath calculations with cnttest from xifthen, but it fails: \documentclass{article} \usepackage{pgf,xifthen} \begin{document} \pgfmathparse{42+77}% ...
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 ...
15
votes
6answers
1k views

Random quadratic equation

I would like to produce quadratic equation with integer coefficients. Here's my code using pgfmath. \documentclass{article} \usepackage{tikz} \pgfmathsetseed{\pdfuniformdeviate 10000000} ...
3
votes
1answer
156 views

fixed leading 0's with pgfmath

I want to calculate a time being printed using pgfmath. I have some code similiar to this: \pgfmathparse{int(mod(\x,60))}\pgfmathresult O'clock but if the result is between 0 and 9 my time being ...
1
vote
1answer
137 views

datatool and pgfmath option [closed]

Compiling this file \documentclass{article} %\usepackage[math=fp]{datatool} \usepackage[math=pgfmath]{datatool} \DTLloaddb{scores}{sample-student-records.csv} % ...
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 ...
12
votes
1answer
367 views

Why is there no pgfmath macro that expands directly to the result?

Is there a specific reason that there is no default macro (e.g. \pgfmath{<expression>}) that directly expands to the result of the evaluated <expression>? It always strikes me as ...
8
votes
3answers
203 views

pgfmath expression containing a \newtoks defined via a \def

This must be another of those expansion related issues as I don't know why the following \def\MaxValueOfTok{8}% \newtoks{\SomeTokDefinedViaDef} \SomeTokDefinedViaDef={\MaxValueOfTok} ...
4
votes
2answers
245 views

How to build macros for vector-matrix operators?

Can anybody build macros for doing the following vector operations? Or are there already such macros? For example, 1) Example data: \def\a{(5,3,0)} \def\b{(5,1,6)} ...
9
votes
1answer
555 views

pgfplot: use pgfmathdeclarefunction defined function within coordinate

This code snippet defines a simple function using \pgfmathdeclarefunction (e.g. f()) and \pgfmathparse. I would like to use the defined function f() within other coordinate, e.g. (0.2, f(0.2)) vs. ...
7
votes
1answer
141 views

Why can't I use max() here?

When I make presentations (with beamer), I like to have a bar along the bottom showing progress through the presentation visually. The interesting bit of the code below is the division on the ...
6
votes
1answer
153 views

How can I inhibit expansion through several layers of \edef?

I'm using a macro I've defined based on some suggestions here to automate the creation of tables. For example something like \newcommand{\clearrows}{\let\matrixcontent\empty} ...
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 ...
9
votes
1answer
191 views

Unexpected results from pgfmath functions with numbers with leading 0

The pgfmath functions give me unexpected results when used on numbers with leading zeros. Are the output in the example below expected for 0011 and 0021? \documentclass{article} \usepackage{tikz} ...
5
votes
1answer
581 views

“Missing number” error using `\pgfmathsetmacro` with the `ifthenelse` operator

I am trying to use logical functions in pgfmath and getting unexpected errors. It seems to be related to the use of \pgfmathsetmacro, which according to my understanding should be equivalent to ...
5
votes
1answer
658 views

How to enforce printing the decimal part in pgfmath macros?

I have the opposite problem to this question. I want the decimal parts of an integer printed for consistency's sake. I already tried specifying the precision but without success. See below. ...
2
votes
0answers
52 views

custom function in pgf doesn't behave consistently [duplicate]

Possible Duplicate: Is plotting exponential graphs a known source of bugs in TikZ? I want to use a custom function in pgf plots and in text, like in this example: ...
3
votes
2answers
185 views

From postscript through pgfmath

I don't understand the next syntax also I would like (if possible) a traduction of the next function with pgfmath /fct {dup 1 gt {pop 90}{dup 1 neg lt {pop 90 neg}{asin} ifelse} ifelse} def
8
votes
1answer
454 views

Using != in \pgfmathparse

In section 63.1 Operators of the pgf manual pgfmanual.pdf I see the claim that x != y returns 1 if x ≠ y, 0 otherwise. Unfortunately, I can't get that to work: \documentclass{article} ...
6
votes
1answer
1k views

pgfplot consistent number format

I am trying to make a the number format in my pgfplots the same, as in the rest of my document. I am normally using the \num from the siunitx package to typeset numbers, and would like to use it in my ...
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
575 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: ! ...