Dave94705
2015-04-13 15:15:06 UTC
I am not getting anything like I expect using either the "if" or the "\pgfmathifthenelse" commands within my tikz code. I want to branch and actually execute some general block of code, rather than a simple assignment of color, if condition A is true and execute another block if it is not true.
This code:
\documentclass{article}
%\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
% \pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
Quickly produces lots of circles indicating that the if is totally ignored.
------------
\documentclass{article}
%\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
% if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
\pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
freezes up within (MikTeX's PDFTeXify) at "[Loading MPS to PDF converter <version 2006.09.02>.]" and never (~20 minutes later) gets beyond that.
-----------------
Including the graphics package:
\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
% if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
\pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
freezes up with "ABD: EveryShipout initializing macros" just after the "Loading ...." from immediately above
-------
Basically, I want to be able to conditionally branch for the execution of sizable chunks of code within tikz. There must be a way, but I don't seem to be getting it. I have skimmed the manual numerous times, but cannot see how to do. Any help or hints would be useful. Thanks, ds
This code:
\documentclass{article}
%\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
% \pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
Quickly produces lots of circles indicating that the if is totally ignored.
------------
\documentclass{article}
%\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
% if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
\pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
freezes up within (MikTeX's PDFTeXify) at "[Loading MPS to PDF converter <version 2006.09.02>.]" and never (~20 minutes later) gets beyond that.
-----------------
Including the graphics package:
\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {90,89,...,-90} { % change 89 to 80 or 45 for speed
% if (\x==105) then \draw (\x/2 - 40, 0) circle [radius=2pt];
\pgfmathifthenelse{\x==105}{\draw (\x/2 - 40, 0) circle [radius=2pt];}{}
}
\end{tikzpicture}
\end{document}
freezes up with "ABD: EveryShipout initializing macros" just after the "Loading ...." from immediately above
-------
Basically, I want to be able to conditionally branch for the execution of sizable chunks of code within tikz. There must be a way, but I don't seem to be getting it. I have skimmed the manual numerous times, but cannot see how to do. Any help or hints would be useful. Thanks, ds