{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

8
votes
1answer
360 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
172 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
615 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 ...
12
votes
1answer
891 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
309 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
182 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
95 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 ...
6
votes
1answer
773 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
138 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
169 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
142 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 ...
4
votes
1answer
424 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
252 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
240 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
335 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
108 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} ...
8
votes
1answer
291 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
276 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
176 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 ...
32
votes
3answers
775 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
178 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
801 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
84 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 ...
3
votes
2answers
316 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 ...
7
votes
1answer
840 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
1k 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
162 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} ...
6
votes
1answer
367 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 ...
10
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} ...
9
votes
2answers
255 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
651 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
758 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
490 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
120 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
286 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
282 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
327 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
294 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
330 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
255 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
150 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
115 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
153 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 ...
16
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
200 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
141 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} % ...
1
vote
1answer
423 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
391 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 ...