I'm trying to write some conditional TikZ styles. This has been tried here before, but I think never in a completely satisfying way. My try is this:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{drawif/.style={\ifnum 1=1 draw\else fill\fi}}
\tikz{\node[drawif] {Test};}
\end{document}
Instead of 1=1, insert a meaningful expression. When compiling, this gives a lot of errors:
! Missing = inserted for \ifnum.
}
l.7 \tikz{\node[drawif]
{Test};}
! Missing number, treated as zero.
}
l.7 \tikz{\node[drawif]
{Test};}
! Argument of \pgfkeys@@normal has an extra }.
\par
l.7 \tikz{\node[drawif] {Test};}
Runaway argument?
\pgfkeys@mainstop \else \pgfkeys@case@two \fi \fi \fi \pgfkeys@parse \ETC.
! Paragraph ended before \pgfkeys@@normal was complete.
etc. What's going on?
\tikzsetcommand or using.estyle– Bordaigorl Dec 02 '14 at 15:55.codeinstead of.style. What happens here is thattikztried to parse your code as tikz styles and gets all confused – Bordaigorl Dec 02 '14 at 15:56