{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

2
votes
4answers
96 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
103 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} ...
0
votes
0answers
63 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
57 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: ...
8
votes
2answers
66 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
71 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 ...
10
votes
1answer
128 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}{ ...
0
votes
1answer
59 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
99 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
75 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 ...
8
votes
2answers
116 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} ...
6
votes
1answer
237 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
83 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
42 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, ...
4
votes
1answer
250 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
88 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
101 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
50 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} ...
3
votes
2answers
118 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
60 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
139 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
88 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
173 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
119 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
166 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
56 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 ...
4
votes
1answer
74 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 ...
4
votes
1answer
65 views

\edef\x trick and pgfmath

With the MWE below, I find the following trouble: within the figure* environment, I have three different \lstset instructions. The first and 3rd (commented out) work, the 2nd (as is) presents with ...
4
votes
1answer
98 views

Using every edge style to thick causes problems with pgfmathparse Mod

When using every edge/.append style = {thick}, Mod doesn't work as intended. Not sure, if the problem is what I am infering or is something else. For example, consider \documentclass{beamer} ...
0
votes
1answer
70 views

PGF Math error with blank node in forrest [duplicate]

\documentclass[12pt]{article} \usepackage{forest} \usepackage{gb4e,cgloss} \forestset{ sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom{}}}, ...
4
votes
1answer
74 views

Multiple uses of pgfpositionnodelater

I'm trying to generate and measure multiple nodes before placing them. Currently I'm using the following macros: % some helper / wrapper commands around \pgfplacenodelater % #1 = identifier for ...
5
votes
2answers
338 views

Need to plot a function in coordinate system

I would like to plot a rational function in LaTeX. I tried different ways with Tikz or pgfplots... nothing works. There are many different ways. Often there are problems with poles / asymptotes etc. ...
0
votes
1answer
44 views

Typeset pgfmath number in text mode

Some of the figures I make with pgfplots use pgfmath to calculate the tick positions for the extrema of a function, with code similar to the one given here. However, these numbers seem to always be ...
1
vote
0answers
44 views

downgrade pgfmath

This is the first time I do not receive any answers to my problem with pgfmath, and I would like to proceed, so I ask whether and how I can downgrade it? tikz/pgf upgrade and decorations As I ...
4
votes
1answer
49 views

TikZ: Move points towards center

I want to move a set of points towards the center of my figure, but I want the distance to depend inversely on the relative distance to the center. Thus, for instance move a point at (-2,-3) to ( -2 - ...
4
votes
2answers
97 views

Using the macro generated by \pgfmathprintnumberto in a \pgfmathparse or \SI

To demonstrate, here's a MWE: \documentclass[a4paper,titlepage]{article} \usepackage{pgf} \usepackage{siunitx} \begin{document} \pgfmathparse{1 + 1} ...
8
votes
1answer
393 views

Declaring sinc in tikz

I am trying to declare the sinc-function for usage in tikz. I tried two different ways: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{math} \begin{document} \begin{tikzpicture} ...
1
vote
0answers
91 views

Macro passing problem with pgfmath

As a continuation of thread 2010/2014 versions difference: I am trying to decorate program listings with highlighted lines, numbered balls, etc. In 2010, I used a macro which does not work any more ...
1
vote
0answers
75 views

2010/2014 versions difference [closed]

Recently, finally I did refresh my really old 2010 version of Latex to 2014, (removed the old version and installed with non-custom settings the new one) to get rid off a strange error. That error ...
3
votes
1answer
101 views

number formatting macro using xparse and pgfmathprintnumber not working for one option

I am trying to write a macro that prints numbers with a couple of options. The macro takes one optional argument that is the precision of the output and a starred version that attaches a unit to the ...
3
votes
3answers
475 views

Draw several horizontal lines using tikz

I would like to draw 5 horizontal lines, each of length 0.5cm and separated by 0.2cm. I have the following code, however, instead of getting 5 individual lines, I get one long continous line. What ...
3
votes
1answer
89 views

Parse numerical value from glossaries variable

Can I parse the text returned from \gls*{...} and get latex to recognize it as a numerical variable so that I can use it in a calculation? This calculation could be done using calculator, fp, calc or ...
11
votes
2answers
298 views

Prevent expression evaluation for some values in TikZ

I need to plot a function that presents some kind of removable singularity, but I cannot split the plot into two intervals, because I'm setting the domain programmatically and it can happen that the ...
5
votes
1answer
124 views

Problems with pgfmath

I drew a parabola graphic y = 0.5 - a x^2 which crosses the x axis at the "roots" points 0.75 and -0.75 and has a bend at coordinate (0, 0.5). And I want to mark a point on the parabola, which has a ...
2
votes
2answers
519 views

Tikz intersection of lines with unnamed points?

This works: \draw (0,0) coordinate (A); \draw (1,1) coordinate (B); \draw (1,0) coordinate (C); \draw (0,1) coordinate (D); \coordinate (X) at (intersection of A--B and C--D); but this doesn't: ...
2
votes
1answer
79 views

How do I assess the length of text within a pgffor \foreach loop [duplicate]

I would like to be able to write something like the following: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newlength\aelengtha \newlength\aelengthb \newlength\aelengthc ...
5
votes
1answer
245 views

pgfmathparse inside tikz child doesn't work

Consider the following MWE: \documentclass{article} \usepackage{pgf, tikz} \begin{document} \begin{tikzpicture} \node {} child foreach \i in {1,2,3} {node {$\i$}}; \end{tikzpicture} \end{document} ...
2
votes
0answers
387 views

“Undefined control sequence \pgfkeys” when loading pgfmath [closed]

Compiling David Carlisle's answer to this question Going through permutations of nouns and verbs with \input{pgfutil-common} \input{pgfmath.code} added as in the answer to Is it possible to load ...
6
votes
3answers
165 views

Correct use of \pgfmathaddtocount \pgfmathsetcount inside a \foreach cycle

I think the picture give the general idea and also i fell like i can smell the solution but definitely can't grasp it... I think that the counter may help me because i guess it allow to increment by ...
1
vote
1answer
277 views

TikZ bounding box too big

I'm fairly new to LaTeX and I'm trying to make a homework template that uses figures generated in LaTeX but when I use TikZ I get a bounding box that is way too large. What is the easiest way to ...