4

I need to create parametrized variable \mycolor like in this example. The variable \mycolor defined colour based on an argument. I need to compare #1 with values 1, 2 and so forth, but how to use if else statement in latex? Google gives result about various algorithmic packages.

ashim
  • 1,783

1 Answers1

5

Your question is far from clear however

\newcommand\mycolor[1]{%
\ifcase#1%
red%
\or
yellow%
\else
green%
\fi}


\color{\mycolor{2}} xxx

makes green text. (0=red 1=yellow everything else green)

David Carlisle
  • 757,742