# Global Conditional

I'm writing a set of notes for my students on trigonometry. At present, they have not met radians, which comes next year. I would like to use the same set of notes for them, but this year, give them the notes using degrees, with next years in radians. At present, I have am using (with the ifthen) package:

\newcommand{\hsc}[1]
{
\ifnum#1=0
$0^{\circ}\leq x\leq 90^{\circ}$
\else
$0\leq x\leq\frac{\pi}{2}$
\fi
}
\newcommand{\dom}[1]
{
\ifnum#1=0
$0^{\circ}\leq x\leq 360^{\circ}$
\else
$0\leq x\leq 2\pi$
\fi
}


This works well in each line I need to change, but is there a way I can insert a switch in the preamble so that these changes are made globally?

-
You might find this discussion helpful: tex.stackexchange.com/questions/5894/… –  Paul Stanley Apr 20 at 8:46

Instead of an optional argument in your commands, use a boolean declaration:

\documentclass{article}
\newif\ifdegrees
\degreestrue
\def\hsc{\ifdegrees\ensuremath{0^{\circ}\leq x\leq 90^{\circ}}
\else\ensuremath{0\leq x\leq\frac{\pi}{2}}\fi}
\def\dom{\ifdegrees\ensuremath{0^{\circ}\leq x\leq 360^{\circ}}
\else\ensuremath{0\leq x\leq 2\pi}\fi}

\begin{document}
\hsc, \dom

\degreesfalse
\hsc, \dom
\end{document}


-
I don't think you should be using \ensuremath here. See tex.stackexchange.com/questions/34830/…. –  Jubobs Apr 20 at 9:38
I use \ensuremath because, in my opinion, these commands must be used in math mode, but the original definition from user10082 requires text mode. –  Robert Fuster Apr 20 at 11:19

Define a conditional and an \ANG command with two arguments; the first is used for radians, the second one for degrees; you can also define as many abbreviations as you want.

Note that in a “real” document you wouldn't switch between \radianstrue or \radiansfalse. Or maybe you'd want to; in that case some trick can be devised for allowing a “local” choice.

\documentclass{article}

\newcommand{\Aright}{\ANG{\pi/2}{90}}
\newcommand{\Aoctant}{\ANG{\pi/4}{45}}

\begin{document}

$\ANG{0}{0}\le\alpha\le\ANG{2\pi}{360}$

Half right angle is $\Aoctant$.

\radianstrue % just for showing the effect

$\ANG{0}{0}\le\alpha\le\ANG{2\pi}{360}$

Half right angle is $\Aoctant$.

\end{document}


-

I am using the etoolbox package, which uses an easier syntax, in my point of view

\documentclass{scrbook}

\usepackage{etoolbox}

%\usepackage{ifthen}

\newcommand{\hsc}{
$0^{\circ}\leq x\leq 90^{\circ}$
}{

$0\leq x\leq\frac{\pi}{2}$
}

\newcommand{\dom}{%

$0^{\circ}\leq x\leq 360^{\circ}$
}{
$0\leq x\leq 2\pi$
} % End of use radians
}

\begin{document}

\hsc
\dom

Now using degrees \par

One may object the conditional inside of the commands, leading to continous queries about the state of the variable \UseRadians each time the commands are called, but the advance is to be able to switch into the relevant mode any time.