Tagged Questions
10
votes
2answers
141 views
How to detect if option provided via \tikzset
I would like to be able to detect if a particular option has been provided via a \tikzset and issue a message based on that.
The MWE yields:
But once the conditional works (just a comment for ...
6
votes
3answers
143 views
How to “demux” several aspects from a `\foreach` variable with `\ifstrequal`?
How can I "demux" several features from a mode specification given in a \foreach?
I would like to use a \foreach to draw several nodes in a TikZ picture. The loop will specify a mode for each ...
8
votes
1answer
389 views
How to use mod operation in latex with tikz
I need something similar to
\ifnum \j mod 2 = 0
rest of a number, but do not know how to do this
in line 22.
\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
...
9
votes
3answers
429 views
Choosing styles conditionally in TikZ
I want to create a series of images that visualise a recursion tree as walked on by an algorithm. That means that different styles are applied to nodes depending on the step the algorithm is in, such ...
11
votes
1answer
170 views
How can I check if the current code is inside a tikzpicture?
I read the answer for this question (inside a environment) but I would like to know if there is something more specific. LaTeX keeps the current environment in the macro \@currenvir but how do the ...
4
votes
2answers
153 views
How to check if a macro expands to something greater than a constant?
Suppose I have a loop:
\begin{tikzpicture}
\foreach \frm \in {1,...,6}{ \only<\frm>{
% if \frm > 4: set \x to 1, 0 otherwise
\node (foo) at (10+5*\x,7) {hello};
}}
...
6
votes
2answers
1k views
TikZ: conditional nodes inside \foreach
I want to use a \foreach construct to generate several pairs of nodes, except for one of them I want to do something different. This is what I tried:
\begin{tikzpicture}[dot/.style={fill,circle,inner ...
3
votes
2answers
119 views
How to test if a macro has the shape of a coordinate from TikZ?
How can I know if a macro contains a coordinate, that is, in the sense of having the shape of a coordinate num,num.
What I want to do is to know if a given macro, \pos, has the shape (in sense of ...
6
votes
2answers
421 views
How do I create an algorithmic Tikz code to obtain a list of numbers which is conditionaly defined by a recurence relation?
Suppose, our initials are $a_{1,0}=0$, $a_{1,1}=1$ and $a_{1,j}=0$ for $j<0$. For given an integer $n$, define
$$a_{i,j}=\begin{cases} a_{i-1,\frac{j}{2}} & \text{ if $j$ is even},\\
...
23
votes
2answers
928 views
Parametrize shading in table through TikZ
I wanted to do some shading in a table according to its values. For example, if you see the table below:
a b c d
a 90 10 0 0
b 0 80 10 10
c 0 0 95 5
d 0 10 5 85
I want to ...
27
votes
1answer
278 views
How can I know if a node is already defined?
I think I've seen this question before, but I can't find it. The problem is simple; before I assign a name to a node I would like to know if the name is already used.
I think when a node is created ...
2
votes
1answer
729 views
How to add a condition in \tikzset?
I am trying to make some modification on the answer of Andrew Stacey of my previous question "A macro of drawing a rectangle with several parameters in TikZ".
The current code is the following:
...
8
votes
1answer
1k views
\ifnum and pgfmath: error
In the following example I want to use \ifnum to compare two numbers computed by pgfmath, for simplicity I use simply 1 and 2 in the example below. Compiling this code gives me the error:
ERROR: ...
10
votes
1answer
360 views
Using ifthenelse for crop marks with tikz
How do I use to insert ifthenelse crop marks in Tikz. I want
ifthenelse{\printcrop=true}{\draw(0,0) -- ++(0,1);}{}
That is, if yes, make a drawing, else but do nothing.
And yet, where I can choose ...
5
votes
1answer
232 views
Using \IfNoValueTF within a TikZ style specification.
In an answer to Flushing PGF commands and local variable Matthew had suggested using \IfNoValueTF within a TikZ \node specification to determine the text. This solution works great for me.
However, ...
5
votes
1answer
553 views
Conditional using non-integer numbers
I am trying to generate fractals using affine transformations.
I need to generate a random number in the interval (0,1),
and depending on the value of this random number choose a
function to ...
6
votes
1answer
1k views
Using ifthenelse in pgfmath
Following questions on constructing functions on the forum, I tried to build some myself. I can't seem to get the ifthenelse function in TikZ/PGF to work. Here is an example:
...
3
votes
1answer
288 views
TikZ. Is there a way to alternate path to be drawn basing on some condition?
What I want is to connect nodes by stepped (horizontal-vertical-horizontal, hvh) path if they have different y-coordinate, and by straight line if they are on the same level.
Costruction of the only ...
7
votes
2answers
4k views
Tikz/Pgf if statements
I'm having trouble writing if statements, I can find next to no documentation on them and what I want to do seems quite simple.
I'm using the orbitals pgf/tikz example from here, and I'd like to ...