1
vote
1answer
31 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
60 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
73 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
34 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
133 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} ...
2
votes
0answers
66 views

Getting undefined control sequence even the command is defined

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 ...
4
votes
1answer
93 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. ...
4
votes
1answer
149 views

Using modulo operation to draw graph

I have a graph that consists of x and y from Z/11. Is it possible to programmatically draw the lines that have a slope of 2? Like from (0,0) to (5,10) and (6,12) would become (6,1) because of modulo ...
7
votes
3answers
114 views

Is there a simple way of improving the precision of pgfmath for trig functions?

I wanted to build a table of trig values using pgfmath. However, the precision is a bit off. Is there a way to improve this within TikZ? This is related to a similar question I just posted: Is ...
2
votes
1answer
77 views

Pointing to a node with calculated name, why do I get to the east, not to the center?

It seems like I'm doing something wrong when using foreach variables to indicate node numbers. The two foreach loops are anchoring the paths to the east of each node. Why does this happen? ...
5
votes
4answers
463 views

Defining a variable in terms of another variable

This is a very elementary question, I hope it is still OK to ask it here. I'd like to do the following \documentclass{article} \usepackage{tikz} \begin{tikzpicture} \def \x {2} ...
4
votes
1answer
63 views

Conflict between eplain urls and pgf(math)

I tried to insert a hyperlink with xetex and eplain, and here is what happens. \input eplain \enablehyperlinks \input pgfmath \href{http://www.google.com}{google} \bye prints this weird error in ...
0
votes
0answers
59 views

draw a piecewise function using PGF/TikZ [duplicate]

How can I draw this piecewise function using PGF/TikZ? f(x) = { x if 0<= x <1, 3-x if 1<=x<=2 }
5
votes
1answer
116 views

Pass a list through pgfkey

I'm declaring a new shape [which looks like an Integrated Circuit]. One of the options I want to provide for this shape should be a list of positive integers with arbitrary length [which configures ...
4
votes
1answer
121 views

Addition doesn't work properly with some numbers in TikZ/PGF

I have a problem with very simple calculations in TikZ/PGF. After displaying many calculations properly i ecountered the problem, that pgfmathadd returns 5.40001, if i want to add 1.6 and 3.8, witch i ...
31
votes
3answers
1k views

Programming Conway's Game of Life in LaTeX

My aim is to program Conway's Game of Life in LaTeX, and make the output into an animated PDF. I intend to use PGF/TikZ for this, especially pgfmath, but I'm stuck at the moment because I need to ...
5
votes
3answers
244 views

Why must the independent variable of a function to be plotted be a macro in TikZ?

Consider the following code (taken from Jake's answer) and focus on the variable of the function to be plotted. \documentclass[border=5pt,tikz]{standalone} \begin{document} \begin{tikzpicture} ...
6
votes
1answer
180 views

evaluate a string like `sin(x)+3` with `x` given

I defined a macro that gets as input a string like sin(x)+3, a starting x and an ending x, which is plotted using \addplot from PGFplots. Now I want to evaluate this function for x equal to the ...
11
votes
2answers
289 views

\pgfmath and \foreach in TikZ

I am quite new to TikZ. I have the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{chains} \begin{document} \begin{tikzpicture}[start chain=circle placed ...
9
votes
2answers
220 views

Calculating Beamer presentation progress excluding appendix

Problem description In trying to calculate the progress of a Beamer presentation, one can use \pgfmathtruncatemacro{\prog}{100*(\insertpagenumber)/(\insertdocumentendpage)} where \prog tracks the ...
8
votes
1answer
325 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
162 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
512 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 ...
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 ...
5
votes
1answer
690 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: ...
4
votes
1answer
154 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} ...
4
votes
1answer
353 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 ...
4
votes
1answer
289 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} ...
4
votes
1answer
265 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
155 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
735 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
1answer
759 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} ...
5
votes
3answers
910 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 ...
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
244 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. ...
5
votes
1answer
475 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 ...
5
votes
1answer
274 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
275 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 ...
5
votes
3answers
278 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 ...
7
votes
2answers
248 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 ...
4
votes
1answer
111 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 ...
1
vote
1answer
381 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 ...
8
votes
1answer
625 views

How to prevent small values from being plotted with nodes near coords?

I'm trying to finalize my first pgfplots chart. I've managed to get is almost the way I would like it to be with thanks to all examples I found here. The last thing I can't seem to figure out is how ...
13
votes
3answers
2k views

\pgfmathsetmacro - dimension too large (biggest value allowed?)

I want to import some data with parameters to parametrize some plots. After importing a table, I assign specific variables of the table to a placeholder by using \pgfplotstablegetelem. And it works ...
10
votes
1answer
2k views

pgfplots and calculations; without fpu 'dimension too large', with fpu 'Illegal unit of measure (pt inserted)'

I'm trying to multiply some numbers that will end up in the legend of a plot. I can't get it to work: If I naively try \pgfmathmultiply, I get a dimension too large error, with the code in MWE 1 ...
14
votes
3answers
644 views

How to find the length of a PGF array?

A few of my macros currently require the user to pass the length of an array along with the array itself. It would be nice if the length could be calculated for them, as the user in question (myself) ...
3
votes
2answers
417 views

Can one pass a pgf array to a pgf math function?

I'd like to define: anglearray(\A,\I,\L) = array(\A,Mod(\I,\L)) + 360*floor((\I+0.1)/\L); but I get strange errors about "! Missing number, treated as zero." and the "array" part appears to ...
4
votes
2answers
1k views

pgf-tikz problem with 'declare function'

I need to make a plot of a non-linear functions. To get familiar with the 'declare function' capability of pgf-tikz, I tried the following code: \documentclass[10pt]{article} \usepackage{amsmath} ...
6
votes
1answer
692 views

User-defined math functions with pgf

I'm trying to use user-defined math functions with pgf to make a plot. The plot will consist of several straight lines given by a function of three arguments. (I know there are easier ways to do this, ...