Questions tagged [tikzmath]
The tikzmath tag has no usage guidance.
45
questions
0
votes
1
answer
70
views
Reset tikzmath variable in for loop
I want to draw multiple curves (each with a different slope) using tikzmath coordinates:
\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=1,
width=\textwidth,
...
1
vote
0
answers
34
views
tikzmath produces an error when the trigonometric functions are used [duplicate]
Why does the following code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\tikzmath{
coordinate \v;
\v = (cos(pi),sin(pi));
}
\end{...
1
vote
1
answer
102
views
Syntax of \tikzmath{function....?
What is wrong with the syntax of the two \tikzmath function definitions function here?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath{function f(\x) { return sin(\x);
}
\...
0
votes
1
answer
49
views
tikzmath arithmetic calculations using predefined variables
I'm trying to do calculations in tikzmath using some predefined variables. Here's an example of what I have
\usepackage{tikz}
\usetikzlibrary{math}
\begin{tikzpicture}
\tikzmath{
real \ang = 30;
...
0
votes
1
answer
32
views
How to assign a value of the form (my node.east) to a coordinate variable inside the argument of a tikzmath command?
The PGF & TikZ manual for version 3.1.9a (the current version) has this to say about the coordinate keyword of the math TikZ library (p. 706):
coordinate 〈variable〉, 〈additional variables〉;
This ...
0
votes
2
answers
34
views
Problems with using \tikzmath to draw ellipses
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{patterns}
\usetikzlibrary{patterns.meta}
\usepackage{...
3
votes
2
answers
93
views
Dealing with recurrent sequences
I have the following code to calculate the approximations for arctan(1) recursively:
\documentclass[varwidth,border=5]{article}
\usepackage{tikz,pgfplots}
\usepackage{fp}
\usepackage{xfp}
\...
2
votes
0
answers
55
views
Maximum and argmaximum in Tikzmath [closed]
tikzmath are several math functions. However, I would like to find the maximum number in a given array and the index where the maximum occurs. How can I do this in tikzmath?
Could anyone provide a ...
0
votes
0
answers
55
views
Messing up data declared using tikzmath: is there a size limit?
For chemistry, I need to rewrite many periodic tables showing different kinds of data for each chemical element.
I'm trying to declare all values using \tikzmath in order to access the values easily, ...
4
votes
1
answer
202
views
Decimal places in fixed point arithmetic with negative numbers
I have the code:
\documentclass[tikz,border=5]{article}
\usepackage{tikz}
\usepackage{xfp}
\usepackage{amsmath}
\usetikzlibrary{math}
\usepackage{fp}
\usetikzlibrary{fixedpointarithmetic}
\begin{...
0
votes
0
answers
107
views
Dimension too large - Tikzmath
I have the following code:
\documentclass[tikz,border=5mm]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{xfp}
\usetikzlibrary{math}
\usepackage{etoolbox}
\usepackage{fp}
\...
1
vote
0
answers
301
views
Manual of tikzmath
I am a strong user of tikzmath to implement several things in the numeric calculus.
However, I miss of a complete manual of tikzmath (separate of tikz), where I can to find all its features, functions,...
10
votes
5
answers
3k
views
Tikzmath: use array
I'd like to use arrays in tikzmath. I'd like to be able to manually define an array, with the equivalent of the python code myarray = [1,0,0,1,1], and I also would like to be able to access it in ...
2
votes
1
answer
150
views
Tikz computes the wrong coordinates
I'm trying to calculate some coordinates to get an accurate tikz figure. I managed to do it by hardcoding some coordinates, but since I have to repeat the process for many of them, I thought it would ...
1
vote
1
answer
1k
views
Using math functions in a tikzmath coordinate
I am trying to execute the following code where I compute the coordinates using the TikZ math library and then I draw them in TikZ.
Why does it output error ! Package pgf Error: No shape named '2*cos(...
2
votes
1
answer
400
views
How can I set a tikz-node's anchor using a variable?
The following code works as expected.
\documentclass[tikz,margin=1em]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}[scale=3]
\draw (0,0) circle [radius=1cm];
\foreach \a in {0,...
3
votes
3
answers
90
views
Rectangular table with consecutive integers using foreach
I'd like to have a rectangular table with integers (like a lottery ticket), let's say 4x9, numbers from 1 to 36.
I assumed that it is easy with tikz, two foreach loops. Like this:
\foreach \i in {0,1,...
2
votes
2
answers
66
views
Draw arcs so they are facing each other, starting at a certain point
I am trying to draw two arc sectors whose origin is an arbitrary point. I feel like I am missing something here, because this should work, but, as you can see in the image below, the red arcs are ...
0
votes
1
answer
300
views
Use tikzmath in between connecting coordinates with the draw function
If I understand correctly, the \draw function allows one to connect points with lines, and then (if the lines come back to the same point) fill the outlined shape. If one uses the -- ( , ) command it ...
1
vote
1
answer
250
views
When to evaluate a custom math function in a `tikzpicture` environment using `pgfplots`
I want to draw a custom function using pgfplots, and add an annotation node:
\begin{tikzpicture}[
>=stealth,
evaluate={
function f(\x) {
return cos(2*\x);
};
...
1
vote
3
answers
282
views
How to place evenly spaced nodes in TikZ from (node1) to (node2)?
I have a relatively long and shallow rectangle, on the bottom of which I need to place some nodes. I don't want to manually fit coordinates, and naturally, I don't want to copy the same code several ...
2
votes
1
answer
249
views
For loop not working around tikzmath
I am trying to draw the dynamics of a discrete dynamical system using Tikz. I'd like to use a loop to do so, but for some reason it does not perform the \tkzmath operations inside the loop. Here's the ...
3
votes
1
answer
646
views
Can't use "if" in tikzmath - undefined control sequence "ifpgfmathfloatparseactive"
MWE (copied from TikZ manual):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\tikzmath{
int \x;
for \k in {0,10,...,350}{
if \k&...
4
votes
2
answers
1k
views
\text{ } subscript size in tikzmath macro is not correct
This question is related to this earlier TeX-SE question of mine
I would like to have a proper text subscript using the \text{} command. It does not seem to work with the tikzmath macros. Please ...
1
vote
2
answers
452
views
Creating tikz commands, automatically drawing labelled square
So I want to create a macro that I can use to automatically generate a rectangle in TikZ. I would like to specify text (an equation) that should be placed in the middle and automatically generate ...
2
votes
0
answers
53
views
In tikzmath the "random" puts ".0.0" if want negative random number [duplicate]
Here is a MWE:
\documentclass{article}
\usepackage{pgf}
\usepackage{pgfplots}
\usetikzlibrary{math}
\begin{document}
\tikzmath{
int \foo;
\foo = random(-16,10);
print {Foo value: \foo.};
}
\...
8
votes
5
answers
834
views
Test of integers? Or, round the number if the first two decimal numbers are sufficiently close to 0 or 1?
The following is a MWE, which explains my intention.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\tikzmath{
\integer = 4/2; \decimal = 5/3;
\integerB=1/3*3;
}
$\...
1
vote
1
answer
365
views
3D Piecewise Plot with varying bounds in Tikz/PGF
The function to be plotted reads as
In it, these constrains hold true:
If plotted it looks like
Please excuse the different symbols, I will explain: p/p_0 is equivalent to \Pi and \gamma is ...
2
votes
0
answers
103
views
Why do the three small triangles not coincide exactly? They are unexpectedly shifted (tikz math library recursive function calls) [duplicate]
It is probably some silly error on my part, but I am trying to understand why the three green triangles do not coincide exactly -- instead, they are unexpectedly shifted. (The original intent was to ...
1
vote
1
answer
3k
views
\input inside \newcommand and macro parameters
I would like to divide a list of parameters for a series of tikz graphics into a bunch of separate, named tex files.
Specifically: each parameter file should be loaded by an \input command which in ...
5
votes
2
answers
1k
views
Tikzmath, ERROR: Missing \endcsname inserted
I'm trying to use tikzmath to draw lines between a set of points, however I've an error ERROR: Missing \endcsname inserted. on the line \ni=\i+1;. Any idea why?
\documentclass{article}
\usepackage{...
1
vote
0
answers
434
views
Change element in pgf math array
I want to change the element of an pgf math array within a multido environment where a random element is incremented by 1:
\def\list{0,0,0,0,0,0,0,0,0,0,0}
\multido{\i=0+1}{20}{
\pgfmathsetmacro{\...
2
votes
3
answers
1k
views
Conditional tests on string variables in tikzmath library
Is it possible to test for strings in the tikzmath library? (E.g. if <variable>=<string expression> then foo)
I tried a naive test and it returned this error:
Package PGF Math Error: ...
1
vote
1
answer
108
views
tikzmath: strange replacement
I don't know why, but I tried to print some code in a tikzmath file, and the result is really strange, it looks like that tikzmath tries to substitute texts even if does not begin with a backslash... ...
4
votes
2
answers
223
views
Compound Pathway Problem with holes
The picture below is what I am trying to create.
I have asked a similar question before, and I got an excellent answer, but it's still not 100% what I am looking for. I know that I have to use \...
3
votes
0
answers
84
views
Conflict in the Key Values in Nested Tikz Enviroments
I am developing some Tikz commands with pgfkeys, and I want to use the commands that I developed earlier in my new commands. This creates nested Tikz and Tikz math enviroments as shown in the MWE ...
2
votes
1
answer
937
views
How to specify the units of a variable in \tikzmath or argument of a \newcommand that uses pgfkeys
I would like to specify the units of an argument of a \newcommand that uses pgfkeys and that goes into a \tikzmath enviroment as a variable as follows:
\documentclass[12pt]{article}
\usepackage{tikz}
...
5
votes
1
answer
1k
views
pgfplots on tikzmath function with conditionals returns an error
Plotting with pgfplots a function defined using the tikzmath function syntax does not seem to work.
The error message :
! Illegal unit of measure (pt inserted).
<to be read again>
...
7
votes
2
answers
1k
views
How do I draw on images embedded with \includeimage in TikZ with pixel accuracy?
I want to draw on an image which I embedded using \includeimage:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\...
1
vote
1
answer
64
views
splitting maths in two lines in a node
I have the following code:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{calc}
\tikzset{cross/.style={cross out, draw=black,ultra thick, ...
1
vote
1
answer
593
views
Error when compiling using tikzmath
I am trying to learn how to use Tikz and its library Tikzmath to make graphics. I am trying to practice by drawing a series of circles along a line.
My code is as follows:
\documentclass[tikz]{...
4
votes
2
answers
1k
views
leading zero in \foreach of a TikZ calendar
The calendar TikZ library creates for each day a node called (<name>-<year>-<month>-<day>). But there is a leading zero for <day> from 1 to 9, that is, to use the node of ...
9
votes
1
answer
649
views
Double rounded curves in Tikz
I am trying to do a graph with tikz, and I would like your help for some details and technicalities. I am trying to do something resembling the following
:
Here are my problems.
1) I am currently ...
2
votes
0
answers
3k
views
Unable to use tikzlibrary packages [closed]
UPDATE: Solved. See my comment below for the fix.
I've been trying for the life of me to figure out how to use the
math tikzlibrary (\usetikzlibrary{math}), and no code works. I fear that it has ...
12
votes
1
answer
955
views
Is print in TikZ's math, useless?
In the manual of TikZ 3.0.0, the section about the math library, we can read (p. 635):
Unlike the print keyword, the brace notation can be used in functions so that tikz path commands can be safely ...