{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
1answer
42 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
84 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
40 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
63 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
50 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
63 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
30 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
63 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
154 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
21 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
29 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
43 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
62 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} ...
6
votes
1answer
184 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
62 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
71 views

2010/2014 versions difference [on hold]

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
35 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
248 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
67 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 ...
10
votes
2answers
202 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
84 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
227 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
60 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
192 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
184 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
146 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
183 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 ...
2
votes
2answers
290 views

How can I make a simple graph with grids using pgfplots?

I want it to look like this: Preferably with comments so I can learn how to make my own!
5
votes
3answers
455 views

How to make an open circle in a number line?

This is a follow up question to Labeled Number Line My question is how can I make an open circle (to indicate an open interval) using Gonzalo Medina's answer.
2
votes
1answer
48 views

Using skip (glue) with pgfmath (truncating plus/minus parts from a glue length)?

Consider the following MWE: \documentclass{article} \usepackage{tikz} \newlength{\tlen} \newlength{\tlenB} \begin{document} \setlength{\tlen}{2cm} \typeout{check 1, tlen is: \the\tlen} ...
5
votes
1answer
159 views

Problem parsing product `2\x` with `TiKZ 3.0`

I was used to write 2\x to obtain the product 2*x but today I've found this is not correct anymore in TiKZ. Next code \documentclass[tikz,border=2mm]{standalone} \begin{document} ...
6
votes
1answer
114 views

\pgfmathparse returns a phantom .0.0

\documentclass{minimal} \usepackage{tikz} \begin{document} \pgfmathparse{random(-5,5)} \pgfmathresult \end{document} Works, but I have a .0.0 that not supposed to be here.
5
votes
4answers
312 views

Calculations in minimum width

I'm trying something like this: \begin{tikzpicture}[x=1cm,y=1cm] \newcommand{\mw}[1]{#1+1} \node [minimum width=\mw{1} cm] {}; \end{tikzpicture} My problem is that this is expanded to 1pt + ...
5
votes
1answer
314 views

Automatic cell colouring using cellcolor: Undefined Control Sequence

I am trying to produce a table, using tabularx, where the cells are coloured automatically depending upon their value. I want to use the \cellcolor command as it will fill the whole cell, rather than ...
1
vote
2answers
249 views

Ifthenelse variable equality

Last week I made simple coordinate transformation in order to define \tdplotsetcoord in Cartesian coord. system. My work and support of exp. user can be viewed in this topic. The code looks as ...
10
votes
3answers
1k views

Tikz: how to plot arcsec and arccos?

It is easy to plot arctan and arccot, but got inverse sec and csc functions, It seems difficult. Can anyone do it?
0
votes
1answer
195 views

Combination Function with Factorial - Not correct result - Pgfplots

\begin{tikzpicture} \begin{axis}[ axis lines = left, xlabel = $Number of Elements$, ylabel = {$Combinations=\frac{(n)!}{(n-r)!(r!)}$}, ] %Axis \addplot [ domain=2:10, samples=100, color=red, ] ...
4
votes
1answer
127 views

Difference between \pgfmatharray{\a}{0}, \pgfmathparse{\a[0]}, and \pgfmathparse{array(\a, 0)}

There are at least 4 different (in code a-d) ways to access items in lists/arrays. Out of curiosity I wanted to see what happens with different combinations. I selected 6 different (in code A-F) input ...
4
votes
1answer
108 views

Setting result from pgfmathifthenelse as variable

So I'm trying to set a variable using the value of another variable. Basically something like below: \pgfmathsetmacro{\newVar}{\pgfmathifthenelse{\oldVar==0}{(\x/2)}{\x}} But no matter what I do I ...
5
votes
2answers
218 views

how to determine piecewise constant function representing binary data

I like to define function which represent binary data, but i stuck in this rather simple task ... my NWME is: \documentclass[tikz,border=3mm]{standalone} \begin{document} ...
5
votes
2answers
166 views

How to define pgfmath local variables?

When using pfgmathsetmacro in commands (defined by \newcommand) we have a problem of locality of variables. For instance if you design two functions \newcommand\f[4]{% ...
4
votes
1answer
228 views

A TeX translation of old C code - Evaluating elements of an array *inside* a foreach loop

I'm trying to translate a conceptually simple part of an algorithm, from the original source for the R-engine (written in C) to TeX. This shouldn't take more than some logic trees and for/while loops. ...
11
votes
1answer
728 views

error using pgfsysdriver with tex4ht, only shows up with texlive 2014, ok with texlive 2013

Update: Thanks to the comments below. Using the link by Michal below, it appears this is a known bug but the fix was not in 2014. Doing the change as pointed out in the link below, seems to have fixed ...
3
votes
0answers
141 views

Barchart, Boxplot Data Table PGF Math Errors from mixed format inline data

My code for a horizontal bar chart with a summarizing boxplot is coming together, but I still have a nagging PGF Math problem if I try to plot the boxplot values, which are commented out at the bottom ...
1
vote
1answer
131 views

Problem with algorithm in pgfmath

I coded an algorithm from R with pgfmath: \documentclass{article} \usepackage{tikz} \usetikzlibrary{fpu} \makeatletter \pgfmathdeclarefunction{qnorm}{4}{% \begingroup ...
11
votes
3answers
435 views

Compute denominator and numerator of irreducible fraction from arbitrary fraction

I would like to reduce each fraction i/n to its irreproducible form (and let's assume i is less than n) and displayed not as a \frac fraction but like it is used e.g. in the frame numbers used in ...
3
votes
1answer
71 views

Pgfmath array problem

I have a problem with pgfmath array : it work if defined outside pgfkeys, doesn't work inside. What is the problem ? \documentclass[tikz]{standalone} \usetikzlibrary{calc} ...
4
votes
1answer
336 views

How to draw a vertical line at a specified date in a Gantt chart?

I want to add a command to pgfgantt package that draw vertical line at a specified date (like the one for the today line). Here's what' I want to get (green line) : So I looked to pgfgantt.sty to ...
3
votes
1answer
146 views

Extracted coordinates have wrong value

I am unable to get the right coordinate values for (A) and (B) in the following axis. Did I misunderstand some conversion step or is it because of the data? Picture MWE \documentclass[ a4paper ...
6
votes
2answers
183 views

Compute the elevation of a coordinate in TikZ

I'm wracking my brains over a seemingly simple problem. Given a coordinate, I would like to do some computation with its components. More specifically, I want to compute the elevation of a point. ...