0
\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage[american]{babel}
\usepackage{libertine}
\newfontfamily\arabicfont[Script=Arabic,Scale=2]{Amiri}
\usepackage[fullvoc]{arabluatex}

\newcommand{\tamarbuta}{t\={a} marb\={u}\d{t}ah\xspace}
%\newcommand{\tamarbuta}{\arb{tA'a marbU.taT}\xspace}


\begin{document}

 The principle feminine form is the \tamarbuta.

\end{document}

In the above MWE suppose I have hundreds of similar macros to be used in the text. Further suppose I have not decided whether the macro should expand to transliteration form or the original Arabic form. How can I preserve both options so that upon choice one or the other option is executed?

(Obviously, the solution I am looking for is not to comment out "the other half" or vice versa if I happen to choose one option.)

blackened
  • 4,181
  • 1
    Do you want to decide that for each occurrence separately or globally? If globally, what you have in your MWE is already good enough: Just keep both definitions and comment out the one you don't want. Theoretically you could also use a bool (like in https://tex.stackexchange.com/q/33576/35864): \newif\ifalttransl and then \ifalttransl \newcommand{\tamarbuta}{A}\else \newcommand{\tamarbuta}{B}\fi and then you can select one or the other with \alttransltrue or \alttranslfalse. – moewe May 11 '18 at 07:06
  • @at moewe I think your solution is the answer I am looking for. Could you kindly turn into an answer please. (Are we allowed to have more than two options?) – blackened May 11 '18 at 07:35
  • TeXnician's answer also includes my suggestion, so why not accept their solution? – moewe May 11 '18 at 07:46

1 Answers1

3

Your question is not really clear, so here are two versions:

  • uncommented: a command that upon choice (use of *) prints one version or the other
  • commented: only one version will be defined depending on a switch. Then you'll always have only one text available (for this version the starred version has to be commented out).

Code:

\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage[american]{babel}
\usepackage{libertine}
\newfontfamily\arabicfont[Script=Arabic,Scale=2]{Amiri}
\usepackage[fullvoc]{arabluatex}

\usepackage{xspace}

\NewDocumentCommand{\tamarbuta}{s}
    {%
        \IfBooleanTF{#1}{%
            t\={a} marb\={u}\d{t}ah%
        }{%
            \arb{tA'a marbU.taT}%
        }%
        \xspace%
    }

%\newif\ifarabic
%\ifarabic
%   \newcommand{\tamarbuta}{\arb{tA'a marbU.taT}\xspace}
%\else
%   \newcommand{\tamarbuta}{t\={a} marb\={u}\d{t}ah\xspace}
%\fi


\begin{document}

 The principle feminine form is the \tamarbuta (\tamarbuta*).

\end{document}
TeXnician
  • 33,589
  • With respect to the commented answer: Are we allowed to have more than two options? – blackened May 11 '18 at 08:05
  • @blackened So you want a switch for more than two options? You could introduce other options (it's just if/else), but for a more sophisticated answer it would be better to ask another question. – TeXnician May 11 '18 at 08:14
  • 2
    Just for the record: arabluatex is able to output romanized Arabic. For instance \arb[trans]{tA' marbU.taT} prints tāʾ marbūṭah in a very straightforward way. See documentation sect. 7 on pages 33-38 for more information. – Robert Alessi May 11 '18 at 19:00