Skip to main content

Questions tagged [pgfmath]

{pgfmath} concerns the pgfmath library used for internal computations in TikZ-pgf but which is also available for other computations in (La)TeX.

Filter by
Sorted by
Tagged with
1 vote
1 answer
53 views

How do I draw a Brownian motion inside an axis environment?

I want to draw a standard Brownian motion from time 0 to 1. Building up on this answer, I've tried the following: \documentclass{article} \usepackage{pgfplots, tikz} \pgfplotsset{compat = newest} \...
0xbadf00d's user avatar
  • 523
0 votes
0 answers
12 views

Improve an addition worksheet using xlop

I have the following worksheet, \documentclass{article} \usepackage{amsmath} \usepackage{mathtools} \usepackage{enumitem} \usepackage{tikz} \usepackage{xlop} \newcommand*{\DifficultyOne}{999}% \...
Paul A's user avatar
  • 1,117
0 votes
2 answers
103 views

Command for a comma-separated list of 'Nchoose' numbers from '1,2,...,Nmax' numbers

I found a code here from @John Kormylo that chooses \Nchoose numbers from 1,2,...,\Nmax numbers and give it out as comma-separatet \mylist. Question: How could I make a command from this, like \...
cis's user avatar
  • 8,922
2 votes
2 answers
66 views

Evaluation inside StrGobbleRight

I'm running into a problem with a list of IfSubStr that will be separated by commas and spaces. I don't want the final substring to have that comma and space, so I thought StrGobbleRight(2) would be ...
Rolling Seduction's user avatar
2 votes
1 answer
82 views

bigintcalc: using a result in further calculations

I have a \newcommand that calcs for predefined variables Hint: I use bigintcalc.sty for huge numbers; and pgfmath to define variables (and maybe other calculations). I would like to have the ...
cis's user avatar
  • 8,922
1 vote
3 answers
84 views

\pgfmathveclen{x}{y}

i need the length between Y and Z later. I hoped that would work, but doesn't. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} % Koordinaten \coordinate (A) at (...
Patrick's user avatar
  • 149
1 vote
0 answers
46 views

Sums and products with tikzmath

I have numbered variables like \tikzmath{ \x{1}=2; \x{2}=3; \x{3}=7; \x{4}=43; \x{5}=1806; ..... and many more .... } which are all integer numbers. I need to calc some sums and products of them; ...
cis's user avatar
  • 8,922
1 vote
1 answer
26 views

TikZ: calc and use a product of n number

I have a code to calc a product of n numbers with pgfmath and foreach as a macro \Prod. But if I say \pgfmathtsetmacro\N{1+\Prod} I get an error. What do I have to do? \documentclass[]{book} \...
cis's user avatar
  • 8,922
0 votes
0 answers
82 views

pgfmathsetmacro, pgfmarthparse, pgfmathresult to define command with calculation

I am quite new to using tikz and the pgf package in general, and I'm having a hard time understanding how/when to use pgfmathsetmacro, pgfmathparse and pgfmathresult. I have the following problem: I ...
Pedro Montanari's user avatar
0 votes
1 answer
38 views

pgfmathsetcounter to unprecise

I want to use the following commman \newcommand{\Gewicht}[2]{ \pgfkeys{/pgf/number format/.cd, precision=8} Volumen des Bauteils nach CAD: \SI{#1}{\cm^3}\\ Dichte: \SI{#2}{\kg\per\cm^3}\\ ...
FN-2187's user avatar
0 votes
1 answer
78 views

`Illegal unit of measure (pt inserted)` despite measurement calculations?

After following the tips in this answer by @JasperHabricht, I'm trying to improve the following macro, but all I get is Illegal unit of measure (pt inserted), despite the measurement calculations ...
psygo's user avatar
  • 438
0 votes
2 answers
82 views

Blank tikz figure in a pdf file

This could be a very problematic post so sorry in advance. I am trying to draw a figure using tikz for a manuscript and when I used it, the first time it worked very well. But now I have added some ...
Waxler's user avatar
  • 860
1 vote
0 answers
49 views

How to graph a series defined function like $\sigma_{n=0}^\infty (-1)^nx^n$? [closed]

I want to graph, for example, this function: $\sigma_{n=0}^\infty (-1)^nx^n$.
amanullah nabavi's user avatar
1 vote
0 answers
50 views

Hide preliminary computations of tikz path macro, return last line only

I want to use a macro \foo that defines a path depending on the macro parameters and finally use it inside tikzpictures as follows: \draw[thick] \foo{5}{6}; If I have something like \providecommand{\...
Linus Romer's user avatar
1 vote
2 answers
81 views

How to get rid of floating points while using \foreach

my question is quite simple, i want to construct a nuumberline for a homework and came up with the following code: \begin{tikzpicture} \draw(0,0)--(16,0); \foreach \x/\y in {0/0,1.6/0.2,...,16.2/2.1} \...
Daerker's user avatar
  • 13
1 vote
1 answer
43 views

Conditional nodes near coords in pgfplots

I have a matrix plot with nan meta values. Now I want to print only the nodes near coords which are not nan but somehow I cannot figure out how to do that. Here is a MWE: \documentclass[tikz, border=...
ValenStein's user avatar
1 vote
0 answers
48 views

Is \sp a reserved word in TikZ math library?

I was running a \tikzmath function as shown below: \documentclass[border=1cm]{standalone} \usepackage{tikz} \usetikzlibrary {math} \usetikzlibrary{calc} % required for coordinate calculations \begin{...
Leon Chang's user avatar
2 votes
0 answers
33 views

Is it possible to access the cached value of \pgfarrowlength rather than recalculating it for purposes other than reusing an arrow tip in PGF/TikZ?

Is it possible to access the cached value of \pgfarrowlength rather than recalculating it for purposes other than reusing an arrow tip in PGF/TikZ? I am trying to calculate the width (i.e. length) of ...
cfr's user avatar
  • 208k
1 vote
0 answers
55 views

Progress bars stuck in pgfgantt

I'm experiencing some unexpected behaviour with progress bars in a little-endian format ganttchart environment. For example, with the MWE below: \documentclass[crop]{standalone} \usepackage{tikz} \...
William Barker's user avatar
9 votes
1 answer
194 views

Calculating things with TikZ/pgf versus calculating things with l3fp

pgfmanual.pdf, VII Utilities, Repeating Things: The Foreach Statement, says: \foreach \x in {0,0.1,...,0.5} {\x, } yields 0, 0.1, 0.20001, 0.30002, 0.40002, and warns about rounding-errors causing ...
user avatar
0 votes
1 answer
33 views

Executing a for loop inside PGF axis when #1 is in use

\foreach does not work inside PGF, so the alternative seems to be \pgfplotsinvokeforeach. My issue is that I want to define my own macros that will be inserted into the axis environment, something ...
Greg Zitelli's user avatar
3 votes
2 answers
288 views

tikz foreach floor function

It seems that in a tikz-foreach-loop mathematical expressions are not evaluated correctly: \documentclass{minimal} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \c [count=\i] in {0,...
Brauer Suzuki's user avatar
3 votes
1 answer
67 views

pgfmath rounding error?

I am doing a specific pgfmath calculation involving logs and trig functions. Pgfmath evaluates: log10(-cot(97.1)) = -0.90466. My calculator gives the "true" answer of −0.904633, which is ...
user2744010's user avatar
0 votes
0 answers
37 views

Calculations involving pgfkeys?

I've begun using pgfkeys to set a bunch of custom variables. I'm also using pgfmath to do some calculations. I understand how to set and call the variables, but the manual is mind boggling to me, ...
user182238's user avatar
1 vote
1 answer
37 views

Incomplete \iffalse error with pgfmathparse in a caption

I am calculating a value with pgfmathparse, pgfmathroundto and pgfmathresult. It works all fine in normal text mode, but when I call the command in a caption, I get an "Incomplete \iffalse; all ...
asbjos's user avatar
  • 43
1 vote
0 answers
46 views

Automatic calculation of error bars based on data in a bar chart

I would like to draw a bar chart using PGFPlots with error bars that are automatically calculated from the data. Here is a slightly simplified version of what I am attempting: Suppose you have two ...
bp99's user avatar
  • 605
0 votes
1 answer
74 views

How to color a coordinate under a function condition

I would like to change the color of some points in a plot if its Euclidean distance to a cluster centroid coordinate is smaller or greater than to the other cluster centroid. I have made different ...
pablo's user avatar
  • 551
3 votes
1 answer
62 views

pgfmathdeclarelist undefined control sequence error with item 33

I regularely use lists defined with pgfmath and encountered an error if one of the list items is "33" but not " 33" or "32".... Please find below a minimal example to ...
laurent's user avatar
  • 41
3 votes
1 answer
63 views

Asinh scale in pgfplots with small parameters

I have recently asked a question about introducing an asinh scale in pgfplots. While the solution given in there does implement an asinh scale, when I tried to implement it in my particular case I've ...
Níckolas Alves's user avatar
0 votes
1 answer
66 views

How to multply an scalar with a defined variable (\def) in Tikz

I currently have the following working code: \begin{tikzpicture} \def\myr{7} \def\mytheta{45} \def\myphi{50} \def\px{{\myr*sin(\mytheta)*cos(\myphi)}} \def\py{{\...
Peluche's user avatar
  • 613
2 votes
1 answer
112 views

tikz externalize works on some figures but not on others

Trying to speed up the compilation of a book I'm writing, I learned about the "externalize" feature of tikz. However, there are some figures it bombs out on with the error ! Package tikz ...
Sander's user avatar
  • 23
1 vote
2 answers
43 views

polyglossia breaks pgf math (cont.)

I found that polyglossia with setlanguage to german breaks pgfmath. I read several hints on this and ended up with the following code: \documentclass{article} \usepackage{polyglossia} \...
elijahbaley's user avatar
0 votes
2 answers
44 views

Naming a pgfmath macro depending on an element of a comma separated list

I want to create a new command, that has more than 9 arguments. Therefore, i am using \NewDocumentComannd and comma separated lists. With this new command i use \pgfmathsetmacro, too. A simplified (...
usuallyiamhungry's user avatar
4 votes
1 answer
127 views

Dynamically generate values in matrix and calculate using them

I am using the following code to generate a matrix filled with random values. I would like to use this matrix to explain how a convolution is applied to an image (specifically the mean), so that's ...
Dexterous's user avatar
3 votes
3 answers
74 views

\clist_item and \pgfmathsetmacro causing an error

My main aim was to be able to use more than 9 arguments when defining a new command. Therefore i am using the following code: \documentclass[12pt]{article} \usepackage{pgfmath} \usepackage{xparse} \...
usuallyiamhungry's user avatar
1 vote
1 answer
119 views

How to draw geometric Brownian motions in tikz/pgf

I am trying to replicate this excellent answer which explains how to draw Brownian motions in TiKZ: \newcommand{\Lathrop}[6]{% points, advance, rand factor, options, end label, truncate from point ...
qarabala's user avatar
  • 202
4 votes
1 answer
52 views

At the end of the table, I would like the number of times that "yes" appears

My question is about using counters. I would like the number of "yes" to appear at the bottom of the table. I don't know how to use counters. \begin{tikzpicture}[scale=0.65] \scriptsize \...
ValGab's user avatar
  • 49
1 vote
1 answer
93 views

Plotting saw-tooth functions with varying heights

I am preparing a note on example of an everywhere continuous nowhere differentiable function. The construction involves a saw-tooth function, viz., h in the following way: I want to plot the ...
Subhajit Paul's user avatar
5 votes
1 answer
274 views

Access cryptographic secure random generator

I am writing my Master's Thesis in cryptography at the moment. The main part deals with randomness; therefore, I wanted to make a little Tikz picture in the introduction to show an example of ...
Titanlord's user avatar
  • 541
0 votes
1 answer
80 views

Pgfmath's height() fails with: Package PGF Math Error: Unknown function `H' (in 'height("H")')

The following code works as expected \documentclass{standalone} \usepackage{tikz} \usepackage{pgfmath} \usetikzlibrary{ calc, } \begin{document} \begin{tikzpicture} \pgfmathsetlengthmacro{\...
Flow's user avatar
  • 1,017
0 votes
1 answer
99 views

How to read values interms of milli(m), femto(f), micro(u) into float values

I have a .csv file, which contains values interms of milli(m), femto(f) and micro(u)etc. which I want to process it as float value inside pgfmathparse \begin{filecontents*}{mycsv.csv} Device, betaeff, ...
Raja's user avatar
  • 450
0 votes
0 answers
81 views

Graph of an advanced function (hard level)

I have to do on overleaf the graph of this function: fo is =1. "w" is the variable and it's=angle/T so we don't need to know T. The final graph is: N.B. When w=0 G(w) it's = Tfo because we ...
FrancescoF96's user avatar
4 votes
1 answer
251 views

Strange syntax in pgfplot

I want to display propagation of a signal, obtained as addition of 2. It works as I want writing: \documentclass{standalone} \usepackage[usenames,svgnames]{xcolor} \usepackage{siunitx} \usepackage{...
Hérisson Didier's user avatar
1 vote
2 answers
114 views

Unable to reuse variable using \pgfmathsetmacro

\documentclass{article} \usepackage{tikz} \begin{document} \newcommand\routine[1] { \pgfmathsetmacro\temp{0} \foreach[parse=true][remember=\temp] \i in {1,...,#1} { \pgfmathsetmacro\...
acter2932's user avatar
4 votes
1 answer
398 views

Are TIKZ and PGF the same thing or not?

When learning how to use tikz I've seen many guides and example using commands that begin with pgfmath and they used the two package names interchangeably so I assumed they refer to the same thing. ...
tham3098's user avatar
0 votes
2 answers
102 views

Defined an array but it is treated like an ordinary string

I defined an array that contains 4 integers. I accessed the 3rd element, modified the last element then accessed it. However instead of doing array operations latex simply replaces every instance of \...
nver9871's user avatar
1 vote
1 answer
46 views

Trouble with gaussian

Taking this example, I build my gaussian bell \documentclass[12pt]{article} \usepackage{tikz} \usetikzlibrary{arrows.meta} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \pgfmathdeclarefunction{gauss}...
user3713179's user avatar
11 votes
4 answers
1k views

How to calculate numbers bigger than 16383 in tikz? [duplicate]

I was trying to output the positive integer powers of 2 starting from 2^10=1024. I was met with a Dimension too large error. When I force compiled, every number from 2^14=16384 was output as 16383. My ...
ded4943's user avatar
  • 111
1 vote
3 answers
98 views

tikz - pgfmathresult prints nothing

I am trying to use a foreach statement to print the powers of 2. I start by defining n as 2 then I print n and multiply it by 2 10 times. The code does compile without errors but the only number I see ...
suf2630's user avatar
  • 11
5 votes
2 answers
438 views

How to remove tikz node?

This codes places the english alphabet from a to y in a 5 by 5 square and then removes s in (3,3) from view by imposing a white square on it. Is there a way to properly delete a node instead of ...
esse47162's user avatar

1
2 3 4 5
12