# Passing multiple arguments to an \ifthenelse routine

I have recently discovered LaTeX, trying to experiment wiht it to prepare a complicated industrial document (laboratory test instructions). A typical set of instructions contains a long sequence of standard tests (each identified by a numbering system). Since some tests are repeated a number of times in a test sequence, I have created a system shown in the attached sample, where a single instruction such as \TestDetails{107} calls the necessary instructions for test 107. However none of the routines describing the tests have arguments. I am now facing the problem to introduce options in some of the tests (ie test 107 is to be performed in condition A at some point of the sequence, and condition B at another point, which would require changes in the instructions..) Is this possible with the ifthenelse option taken? if not, what would be the recommended approach?

\documentclass[a4paper, 11pt]{report} % Mode production
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc} % Usual fonts
\usepackage{ifthen} % Use of logic tests
%----------------------------------------------
\newcommand{\SandAndDust}[0]{%
Some text for sand and dust test.
} %

\newcommand{\VoltageProof}[0]{%
Some text for voltage proof text.
} %

\newcommand{\TestDetails}[1]{%
\ifthenelse{\equal{#1}{100}}{\SandAndDust}{}%
\ifthenelse{\equal{#1}{107}}{\VoltageProof}{}%
}%

\begin{document}

\TestDetails{100}

\TestDetails{107}

\end{document}

-

You can work with LaTeX3. There you can use the function \prg_case_int:nnn which also allows computing.

\documentclass[a4paper, 11pt]{report} % Mode production
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc} % Usual fonts
\newcommand{\SandAndDust}[0]{%
Some text for sand and dust test.
} %

\newcommand{\VoltageProof}[0]{%
Some text for voltage proof text.
} %

\usepackage{xparse,expl3}
\ExplSyntaxOn
\NewDocumentCommand { \TestDetails } { m }
{
\prg_case_int:nnn {#1}
{
{100} { \SandAndDust }
{107} { \VoltageProof }
}
{
not~in~list
}
}
\begin{document}
\TestDetails{100}\par
\TestDetails{107}\par
\TestDetails{100+7}\par
\TestDetails{103}
\end{document}

-
Thanks a lot. Does this solution require that for instance, two parallel variants of a primary command be prepared? Such as: \newcommand{\SandAndDustA}[0]{% Some text for sand and dust test option A.} and similar for option B. If confirmed, this might be more difficult to maintain, since any change of the core instructiosn would have to be duplicated for both options A and B. However I need to study, as I had never heard of Latex 3, and even less of such syntax. } % – Yves Feb 7 '12 at 19:27
@Yves: No. You can type what you want. It's important to know that the LaTeX3-Syntax ignores all white space except ~. – Marco Daniel Feb 7 '12 at 19:32

If I understand your requirement correctly I think you only need a slight change in what you have, something like the following produces

Some text for sand and dust test.

Some text for voltage proof text.

Some text for voltage proof text in Condition A.

Some text for voltage proof text  in Condition B.


modified example:

\documentclass[a4paper, 11pt]{report} % Mode production
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc} % Usual fonts
\usepackage{ifthen} % Use of logic tests
%----------------------------------------------
\newcommand{\SandAndDust}[0]{%
Some text for sand and dust test.
}

\newcommand{\VoltageProof}[1][]{%
Some text for voltage proof text%
\ifthenelse{\equal{#1}{}}{}{ in Condition #1}.}

\newcommand{\TestDetails}[2][]{%
\ifthenelse{\equal{#2}{100}}{\SandAndDust}{}%
\ifthenelse{\equal{#2}{107}}{\VoltageProof[#1]}{}%
}

\begin{document}

\TestDetails{100}

\TestDetails{107}

\TestDetails[A]{107}

\TestDetails[B]{107}

\end{document}

-
Thanks. Yes this is exactly the situation: Typically some details changes such as "unmated condition" or "mated condition" or the applicable voltage value, different if a test is performed after a particular test....I had not figured out the possibility of this solution.... – Yves Feb 7 '12 at 21:12
\documentclass{report}
\newcommand\SandAndDust{Some text for sand and dust test.}
\newcommand\VoltageProof{Some text for voltage proof text.}
\newcommand\TestDetails[1]{%
\ifnum100=#1 \SandAndDust\else\ifnum107=#1 \VoltageProof
\else Something else\fi\fi}%

\begin{document}
\TestDetails{100}

\TestDetails{107}

\TestDetails{1}
\end{document}

-