{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

12
votes
3answers
331 views

How to Generate Random Negative Integer?

I am trying to create a worksheet constituted of random numbers so that kids can practice integer operations. E.g. 3+-9=? 2x(-5)=? 18/-3=? Etc. How do I do this? Here is what I've tried so far. ...
2
votes
0answers
36 views

Parsing input for table automatically generated from csv file

I have a .csv file which looks like: {one},{two},{three} 11/07/2014,14:49:54,(100,100) 2,2,2 I have some code which creates a table from the .csv file. \documentclass{article} \usepackage{...
2
votes
0answers
37 views

Tikz plot of a (log-) normal quantile function and inverse error function

I want to plot the lognormal and normal quantile functions in tikz. To fix notation, let's refer to https://en.wikipedia.org/wiki/Normal_distribution, which gives the quantile of the normal ...
11
votes
3answers
315 views

Precision in numeric calculations

When using pgfmathsetmacro with very small of high exponents, it doesn't work. The example below exits by complaining a division by zero. Is there any way to increase the precision that this works or ...
3
votes
1answer
21 views

Computing minimum width based on style arg

I have successfully defined a "block" that I can instantiate in various sizes, with annotations at its sides. However, I would like to set the minimum width to sqrt(#2), while keeping the label as #2....
6
votes
1answer
88 views

pgfplotstableread + addplot table: scale column for re-use

I get output files from a code and I want to display the output file with pgfplots. I want to create several different plots with the same files. Therefore, I read them in a macro with pgfplotstable. ...
1
vote
0answers
24 views

pgfplotstable: trouble reading data from file with leading zero

when i create a table within the process of LaTeX, i am able to access the items, for example in a loop. If i read a table from a file with "\pgfplotstableread" then it refuses to read in values with ...
4
votes
1answer
76 views

avoid logarithm of zero in pgfmathparse conditional assignment

How can i avoid the error message ! Package PGF Math Error: I cannot calculate the logarithm of '0' (in ' 0>1 ? ln(0) : 0'). in the following code? If possible, i want to evaluate the statement ...
1
vote
0answers
36 views

PGFmathprint fraction precision problem

I try to make this table using pgf number typesetting but have a precision problem. From the manual : If you still experience stability problems, use \usepackage{fp} in your preamble. The frac ...
2
votes
1answer
57 views

Undefined control sequence \pgfmath@ in \node with text height or text depth

The below file gives this error when compiled with pdflatex (from TeX Live 2015). How do I fix it, and what have I done wrong? Error \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ l.27 .....
3
votes
1answer
26 views

Misterious “dimension too large” error in pgfplot when using width

Look at the following MWE: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots}\pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture}[] \begin{axis}[ width=14cm, ...
1
vote
0answers
23 views

error function graph [duplicate]

Is there a simple way to plot the error function in latex? Something like the graph shown in the wikipedia page would be great. The function doesn't seem to exist in pgfmath. https://en.wikipedia.org/...
1
vote
1answer
20 views

2D array with floats

The following code is working for integers in \myArray, but not for floats. How can I make this code working for floats? \documentclass[a4paper]{article} \usepackage{tikz} \begin{document} \begin{...
1
vote
0answers
85 views

Animation with sinusoidally moving arrows

I am trying to create an animation using animateinline and it's my first. This is the frame layout: http://i67.tinypic.com/bfj7s2.jpg Below is my code so far. I can't figure out how to get the sine ...
1
vote
0answers
22 views

Fill column with random numbers using datatool and PGF

Consider the following csv file: column1,column2 line1, line2, I want to fill column2 with random numbers, preferably using PGF (simply because I already know a bit about PGF, but I am open to ...
5
votes
1answer
138 views

rounding to one decimal woes…

I have a problem with rounding --- I have seen How do I get \pgfmathparse to create value rounded to one decimal place? but still I can't obtain the result I need. See this MWE: \usepackage[utf8]{...
4
votes
3answers
300 views

How to increment variable by using same variable?

How can I increment variable from the same variable? \pgfmathsetmacro\S{5}; \pgfmathsetmacro\S{\S + 1};% not working How can I work around this? I need counters which I use as line coordinates ...
4
votes
0answers
54 views

pgfplots: math expressions of variables in axis style

I would like to use a calculated value of pgf variable exp(\pgfplots@data@xmin) This is a concrete example what I need \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \...
3
votes
0answers
55 views

Remove the first and last values of xtick and ytick

I use the following code to create a tufte-like range plot as suggested here: Tufte like axis with pgfplots \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \makeatletter ...
3
votes
2answers
87 views

Constructing arcs using \pgfpatharctoprecomputed

I am having trouble producing an arc from a well-defined ellipse using \pgfpatharctoprecomputed. My code is: \documentclass[tikz,convert={outfile=\jobname.svg}]{standalone} \usepackage{tikz} \...
1
vote
1answer
52 views

pgfmathdeclarefunction with savebox and tikzexternalize: tikzpicture optimized away

Having solved my previous problem involving \savebox and \tikzexternalizeI am already facing the next one. I would like to use a function that I have defined either in or after the preamble with \...
10
votes
4answers
358 views

What is the difference between points, coordinates, and anchors in TikZ/PGF and how can I deal with them?

I should note that I am already familiar with TikZ and am I am looking for technical answers, as if TikZ weren't technical enough. This question boils does to the following question, what is the ...
5
votes
3answers
184 views

serious scientific calculating with small numbers, using different methods

I got stuck in a problem with pgfmath module. When trying to calculate the following functions values the result that gets printed out is always zero. I guess the problem is an underflow of pgfmaths ...
2
votes
4answers
103 views

Programming a step function- part2

Based on a macro given by egreg in this question: Programming a step function I obtain a program which tests in which interval is a number \alpha, between the numbers bone, btwo, bthree, bfour. I use ...
3
votes
2answers
160 views

Dimension too large with \pgfmathsetmacro

I want to define varafterglowepsdown, varafterglowa and varafterglowb and use them in a tikz function like this: \newcommand{\varafterglowepsdown}{0.0001} \pgfmathsetmacro{\varafterglowb}{ln(\...
0
votes
0answers
91 views

Real-time editor(whiteboard) using Latex Editor

After studying tex for more then 3 weeks, I am still wondering, how can I create a real-time editor(whiteboard) to prepare notes with complex structure. Suppose I am having dictionary of latex symbols ...
4
votes
1answer
288 views

\pgfmathprintnumber and pre-defined styles

In text mode I would like to use \pgfmathprintnumber to print numbers in an uniform style. The style used shall be defined in the preamble of the document. See the following MWE: \documentclass{...
8
votes
2answers
72 views

Applying and doing math on two functions read from a file using pgf

I'm trying to read two functions of x from a file, and then get the result of f(8) / g(8) using pgfmathparse. Here is a minimal (not) working example: \begin{filecontents}{data.dat} f(x) g(x) x ...
4
votes
0answers
79 views

Problem with decorations in a small TikZ picture

When working on yesterday's update on my answer to the december challenge (a dcorated tree), I encountered a problem: if I choose the picture's dimensions to small, then it fails with Dimension ...
9
votes
1answer
220 views

pgfmathsetmacro issue in foreach

I am trying to use \pgfmathsetmacro inside a foreach loop to connect nodes which are adjacent and named according to position as follows: \foreach \src in {0,...,\T}{ \pgfmathsetmacro{\dest}{\src+...
0
votes
1answer
73 views

Exponent with more than 1 digit [duplicate]

How can i format an exponent with more than one digit? For example i want $10^20$ and latex gives me 10^2 and 0.
2
votes
3answers
179 views

Evaluate binomial coefficient with \pgfmathtruncatemacro

How is it possible to evaluate complex formulas like \binom{2^{4}-3}{2^3} with \pgfmathtruncatemacro ? I want this to evaluate to 1287. What already works: \begin{tikzpicture} \foreach \l ...
5
votes
1answer
117 views

Why does pgfmaths's ifthenelse evaluate both expressions?

Consider having to compute some value using an operation that might not be defined for certain values, like e.g. the tangent function. To avoid raising exceptions, I tried using pgfmath's ifthenelse(&...
8
votes
2answers
167 views

tikz node name and calculation

I can't find out why the following code : \documentclass[border=0mm]{standalone} \usepackage{tikz} \usetikzlibrary{positioning,shapes.multipart, fit,backgrounds,calc} \begin{document} \begin{...
6
votes
1answer
288 views

Place node at local maxima or minima of graph

Though there is an upvoted answer - the question is NOT answered. It turned out, that without smooth the resulting figure gets produced and looks alright, but the error remains. How to get rid of ...
4
votes
0answers
132 views

Calculate x-coordinate for given y-value by interpolating data from pgfplotstable

I have a text file data.txt with the following content: -2 -2 +1 +0 +1 +3 +2 +4 +2 I read it with \pgfplotstableread{data.txt}\data and then plot the second column by the first column with \...
1
vote
1answer
71 views

siunitx produces number too big error with large numbers

minimal (non)-working example: \documentclass{article} \usepackage{siunitx} \usepackage{pgfplotstable} \usepackage{filecontents} \pgfplotstableset{ header=true, trim cells=true, col sep=comma, ...
5
votes
1answer
471 views

Multiple \pgfmathparse and \pgfmathresult

Is it possible to use more than one \pgfmathparse and pgfmathresult in a single macro? In this MWE, I try to use two of each. It did not quite work. The fraction on top should say 10/3, not 0.3/3. ...
3
votes
1answer
147 views

Tikz inside a proof and enumerate environment

I am having a problem getting a tikz graph to correctly sit below the a) part of the problem in the solution: My code is as follows: \documentclass[12pt,leqno]{article} \usepackage{amsmath, amsfonts, ...
1
vote
2answers
114 views

How to multiply string?

\usepackage{tikz} \usepackage{xstring} \begin{document} \newcommand{\nG}[3]{ \node[opacity = 0, text opacity = 1, minimum size = 10mm] at (#1, #2){#3}; } \newcommand{\writeSep}[4]{ \foreach \x in ...
2
votes
1answer
92 views

Pgfmath misbehaving when reading negative values from table in Pgfplots

I am astonished that when I attempt to square a number read from a table with pgfplots, the result has the same sign. Consider this: \documentclass{standalone} \usepackage{pgfplots} \usepackage{...
3
votes
2answers
256 views

`Missing = inserted for \ifnum` when using addplot

I'm trying to plot a normalized sinc function with PGFPlots/TikZ. As this is somewhat tricky because of the limiting value at 0, I used a suggestion provided by percusse. Here's a minimal example (...
1
vote
0answers
75 views

How to plot a function without functional equation (mu-sigma-space/portfoliotheory)

I was wondering if there is a easy way (some native function) for interpolation of points, i.e. to connect some few given points by a curve (approximation of a function). I have some concrete formulas ...
4
votes
1answer
180 views

pgfmath and doing some simple calculations using a variable

I'm creating addition worksheets for little oompa loompas. It works using: \documentclass{article} \usepackage{geometry} \geometry{letterpaper, portrait, margin=1.5cm, tmargin=2.5cm } \...
6
votes
1answer
113 views

Plotting piecewise function using declare function

I am trying to plot a piecewise defined function, but somehow I don't manage to get it right. See below. I use the following code \begin{tikzpicture}[ declare function={ func(\x)=(\x >8/10) * (...
6
votes
1answer
237 views

How to calculate geometric functions of tikz coordinates?

I have two points in tikz (m1 and m4) and would like to calculate the angle of the line defined by these two points and the horizontal line. The math would be atan( (x2-x1) / (y2-y2) ), and I tried ...
3
votes
1answer
168 views

Runaway argument using int() function in pgfplots

The MWE below yields Runaway argument? 3\pgfflt@EOI \ifpgfmathfloatparsenumberpendingperiod \pgfmathfloat@a@Mtok \ETC. ./TeX-SE.tex:29: Paragraph ended before \pgfflt@readlowlevelfloat was complete. &...
3
votes
1answer
216 views

List of strings for tikzpicture

at first my MWE: \documentclass{article} \usepackage{tikz} \begin{document} \def\johnlist{{ala},{bla},{cla}} % \def\johnlist{2,3,5,7} %This instead of the line above works... \begin{tikzpicture} \...
1
vote
1answer
81 views

how to save and reuse values between two tikz pictures

I have two pictures in the first, I calculate the angle of a vector, I wish reuse this value in the second figure. How can I save this value from one figure to another. The first picture \begin{...
4
votes
1answer
79 views

pgfpositionnodelater with nested \tikz environments (Issue with PGF 2.1 -> 3.0 upgrade)

I'm trying to use \pgfpositionnodelater to create and measure nodes before placing them. (Their size influences where they should be placed) This works fine until I try to use \pgfpositionnode later ...