You check the boolean switch once in the preamble and make the definition, which is not changed later.
It would work as expected if you would make the test later, such as:
\BeforeBeginEnvironment{ExampleVerbatim}{\ifbool{tightspace}{}{\begin{spacing}{0.5}}}%
\AfterEndEnvironment{ExampleVerbatim}{\ifbool{tightspace}{}{\end{spacing}}}%
However, I would make the spacing value a variable instead. And I guess you meant your tightspace check the other way round as in the original code.
Welcome! Are you looking for iseven
?
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\def\bigdot{5pt}
\def\littledot{1pt}
\foreach \x in {0,...,5}{
\draw (\x,0) circle [radius={iseven(\x)?\bigdot:\littledot}];
}
\end{tikzpicture}
\end{document}

In your code you are asking to make the circles for which int(\x/2)
is zero big. These are the circles at \x=0
and \x=1
, and this is what you get. However, if you want to have "the first, third and fifth dots to be larger" in a list {0,...,5}
then you can make the dots larger for which \x
is even.
ADDENDUM: As for the different question raised in the comments, you can use mod
, as suggested by AlexG, or Mod
, which always returns nonnegative values and helps you to avoid confusion (at least I occasionally wasted a lot of time because I was using mod
). Both versions are described on p. 1033 of pgfmanual v3.1.5. As above, I prefer the non-deprecated syntax
circle[radius=<radius>]
over the older, deprecated syntax
circle(<radius>)
so the proposal for the question in the comments could be
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\path (0,0) node[circle,inner sep=5cm] (c){};
\def\bigdot{5pt}
\def\littledot{1pt}
\foreach \x in {0,...,359}{
\draw (c.\x) circle [radius={Mod(\x,5)==0?\bigdot:\littledot}];
}
\end{tikzpicture}
\end{document}
Note also that if you use \documentclass[tikz]{standalone}
then tikz
gets automatically loaded, so \usepackage{tikz}
is unnecessary. Also, I generally do not really like \def
s but if you want to use them, use them locally, i.e. inside the tikzpicture
, as above. Yet personally I'd use something like
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={rsmall=1;rbig=5;}]
\path (0,0) node[circle,inner sep=5cm] (c){};
\foreach \x in {0,...,359}{
\draw (c.\x) circle [radius={(Mod(\x,5)==0?rbig:rsmall)*1pt}];
}
\end{tikzpicture}
\end{document}
Best Answer
The approach you're following is not correct. The best thing is to change
preamble.tex
intopreamble.sty
and use options.File
preamble.sty
File test.tex (
foo
enabled)File test.tex (
foo
disabled)