Is it possible to use \ifthenelse

  • Context:
  • Thread starter Thread starter MarkFL
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
MarkFL
Gold Member
MHB
Messages
13,284
Reaction score
12
Hello!

I was interested in using the \ifthenelse construct in one of my diagrams, and wanted to know how I would go about adding support for the "ifthen" package. :)
 
Physics news on Phys.org
MarkFL said:
Hello!

I was interested in using the \ifthenelse construct in one of my diagrams, and wanted to know how I would go about adding support for the "ifthen" package. :)

Apparently the ifthen package has to be added in the preamble (since it's not a tikzlibrary), after which it works out of the box:
\begin{tikzpicture}
%preamble \usepackage{ifthen}
\foreach \x in {0,...,4} {
\ifthenelse{\x=3}{}{\fill (\x,0) circle (0.1);}
}
\end{tikzpicture}
[latexs]\begin{tikzpicture}
%preamble \usepackage{ifthen}
\foreach \x in {0,...,4} {
\ifthenelse{\x=3}{}{\fill (\x,0) circle (0.1);}
}
\end{tikzpicture}[/latexs]
 
I like Serena said:
Apparently the ifthen package has to be added in the preamble (since it's not a tikzlibrary), after which it works out of the box:
\begin{tikzpicture}
%preamble \usepackage{ifthen}
\foreach \x in {0,...,4}{
\ifthenelse{\x=3}{}{\fill (\x,0) circle (0.1);}
}
\end{tikzpicture}
[latexs]\begin{tikzpicture}
%preamble \usepackage{ifthen}
\foreach \x in {0,...,4}{
\ifthenelse{\x=3}{}{\fill (\x,0) circle (0.1);}
}
\end{tikzpicture}[/latexs]

I would have sworn I tried that, but I'll give it another go...thanks for the prompt help! (Yes)

I'm working on elaborating on the diagram I posted in the TikZ Challenge thread to create a general purpose template for plotting direction fields, and I need conditionals to get the direction of the little slope lines correct so that they point in the right direction. :)