plain IF structure with one def-ed token and one literalifthenelse with inequalities and expressions, using pgfmathparseChecking a command with equal and then using that command for another command?Getting started with latex and conditional typesetHow test value of a command with `ifthenelse` and `equal`?Conditionals used in a new environment of detection of how many lines of quotation and with the selection of a language in XeLaTeXhelp with nomenclature groups and ifthenelse

How does IBM's 53-bit quantum computer compare to classical ones for cryptanalytic tasks?

What do you do if you have developments on your paper during the long peer review process?

Why did UK NHS pay for homeopathic treatments?

Is it right to extend flaps only in the white arc?

Would Taiwan and China's dispute be solved if Taiwan gave up being the Republic of China?

I reverse the source code, you negate the input!

Title Change now and Wage Increase Later

Cut a cake into 3 equal portions with only a knife

To what extent is it worthwhile to report check fraud / refund scams?

What is this utensil for?

Social leper versus social leopard

Which place in our solar system is mostly fit for terraforming?

In a folk jam session, when asked which key my non-transposing chromatic instrument (like a violin) is in, what do I answer?

Can the U.S. president make military decisions without consulting anyone?

Is this Portent-like spell balanced?

How to manage expenditure when billing cycles and paycheck cycles are not aligned?

Can a broken/split chain be reassembled?

How do pilots align the HUD with their eyeballs?

What is the need of methods like GET and POST in the HTTP protocol?

How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?

Examples of "unsuccessful" theories with afterlives

2000s Animated TV show where teenagers could physically go into a virtual world

Strange Sticky Substance on Digital Camera

Worms crawling under skin



plain IF structure with one def-ed token and one literal


ifthenelse with inequalities and expressions, using pgfmathparseChecking a command with equal and then using that command for another command?Getting started with latex and conditional typesetHow test value of a command with `ifthenelse` and `equal`?Conditionals used in a new environment of detection of how many lines of quotation and with the selection of a language in XeLaTeXhelp with nomenclature groups and ifthenelse






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















In some hand-me-down tex i inherited, a control sequence is used as a variable, for instance:



defaccessflavorats


it is used to generate postfixes on included tex files (called, i.e., image01_ats) and the like.



I want to use it in a conditional structure, i. e. something like



ifaccessflavor ats
This text is only shown if the Flavor of Access is 'ats'.
fi


I tried a a lot of variations, including various brackets, escape sequences and macros, but i cannot get it to work. Mostly, not even an error message appears. The online examples i found either deal with a more specific IF, like ifodd, ifx, etc., or more (seemingly) complex cases like testing two macros for identity.



Can somebody clear up the usage for me?










share|improve this question


























  • I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

    – TeXnician
    Apr 15 at 14:57

















4















In some hand-me-down tex i inherited, a control sequence is used as a variable, for instance:



defaccessflavorats


it is used to generate postfixes on included tex files (called, i.e., image01_ats) and the like.



I want to use it in a conditional structure, i. e. something like



ifaccessflavor ats
This text is only shown if the Flavor of Access is 'ats'.
fi


I tried a a lot of variations, including various brackets, escape sequences and macros, but i cannot get it to work. Mostly, not even an error message appears. The online examples i found either deal with a more specific IF, like ifodd, ifx, etc., or more (seemingly) complex cases like testing two macros for identity.



Can somebody clear up the usage for me?










share|improve this question


























  • I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

    – TeXnician
    Apr 15 at 14:57













4












4








4








In some hand-me-down tex i inherited, a control sequence is used as a variable, for instance:



defaccessflavorats


it is used to generate postfixes on included tex files (called, i.e., image01_ats) and the like.



I want to use it in a conditional structure, i. e. something like



ifaccessflavor ats
This text is only shown if the Flavor of Access is 'ats'.
fi


I tried a a lot of variations, including various brackets, escape sequences and macros, but i cannot get it to work. Mostly, not even an error message appears. The online examples i found either deal with a more specific IF, like ifodd, ifx, etc., or more (seemingly) complex cases like testing two macros for identity.



Can somebody clear up the usage for me?










share|improve this question
















In some hand-me-down tex i inherited, a control sequence is used as a variable, for instance:



defaccessflavorats


it is used to generate postfixes on included tex files (called, i.e., image01_ats) and the like.



I want to use it in a conditional structure, i. e. something like



ifaccessflavor ats
This text is only shown if the Flavor of Access is 'ats'.
fi


I tried a a lot of variations, including various brackets, escape sequences and macros, but i cannot get it to work. Mostly, not even an error message appears. The online examples i found either deal with a more specific IF, like ifodd, ifx, etc., or more (seemingly) complex cases like testing two macros for identity.



Can somebody clear up the usage for me?







ifthenelse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 at 15:18









Mensch

49.7k10 gold badges55 silver badges182 bronze badges




49.7k10 gold badges55 silver badges182 bronze badges










asked Apr 15 at 14:54









bukwyrmbukwyrm

1212 bronze badges




1212 bronze badges















  • I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

    – TeXnician
    Apr 15 at 14:57

















  • I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

    – TeXnician
    Apr 15 at 14:57
















I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

– TeXnician
Apr 15 at 14:57





I can recommend the multiaudience package which allows you to separate some parts of your text for different "audiences" and provides higher-level switches. As part of this, you can use its CurrentAudience variable to get the audience you are currently writing for (e.g. for file names).

– TeXnician
Apr 15 at 14:57










2 Answers
2






active

oldest

votes


















3
















documentclassarticle
defatscomparetokenats
newcommanddomytest%
ifxatscomparetokenaccessflavor MATCHES atselse DOES NOT MATCH atsfi

begindocument
defaccessflavorats
domytest

defaccessflavorpdq
domytest
enddocument


enter image description here






share|improve this answer

























  • Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

    – bukwyrm
    Apr 15 at 15:22












  • @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

    – Steven B. Segletes
    Apr 15 at 15:50


















2
















If you want to maintain the if...else...fi structure, you can use



documentclassarticle
usepackagepdftexcmds

makeatletter
newcommandflavor[1]%
TTfi
ifnumpdf@strcmp#1accessflavor=z@

makeatother

begindocument

defaccessflavorats

Shown

ifflavorats
This text is only shown if the Flavor of Access is `ats'.
fi

defaccessflavornotats

Not shown

ifflavorats
This text is only shown if the Flavor of Access is `ats'.
fi

enddocument


The usage of pdftexcmds is to obtain engine independence, so the code works with pdftex, luatex and xetex.



The trick is that if expands tokens.



Note that this can be used inside other conditionals.



enter image description here






share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484974%2fplain-if-structure-with-one-def-ed-token-and-one-literal%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3
















    documentclassarticle
    defatscomparetokenats
    newcommanddomytest%
    ifxatscomparetokenaccessflavor MATCHES atselse DOES NOT MATCH atsfi

    begindocument
    defaccessflavorats
    domytest

    defaccessflavorpdq
    domytest
    enddocument


    enter image description here






    share|improve this answer

























    • Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

      – bukwyrm
      Apr 15 at 15:22












    • @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

      – Steven B. Segletes
      Apr 15 at 15:50















    3
















    documentclassarticle
    defatscomparetokenats
    newcommanddomytest%
    ifxatscomparetokenaccessflavor MATCHES atselse DOES NOT MATCH atsfi

    begindocument
    defaccessflavorats
    domytest

    defaccessflavorpdq
    domytest
    enddocument


    enter image description here






    share|improve this answer

























    • Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

      – bukwyrm
      Apr 15 at 15:22












    • @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

      – Steven B. Segletes
      Apr 15 at 15:50













    3














    3










    3









    documentclassarticle
    defatscomparetokenats
    newcommanddomytest%
    ifxatscomparetokenaccessflavor MATCHES atselse DOES NOT MATCH atsfi

    begindocument
    defaccessflavorats
    domytest

    defaccessflavorpdq
    domytest
    enddocument


    enter image description here






    share|improve this answer













    documentclassarticle
    defatscomparetokenats
    newcommanddomytest%
    ifxatscomparetokenaccessflavor MATCHES atselse DOES NOT MATCH atsfi

    begindocument
    defaccessflavorats
    domytest

    defaccessflavorpdq
    domytest
    enddocument


    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 15 at 15:01









    Steven B. SegletesSteven B. Segletes

    170k9 gold badges216 silver badges443 bronze badges




    170k9 gold badges216 silver badges443 bronze badges















    • Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

      – bukwyrm
      Apr 15 at 15:22












    • @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

      – Steven B. Segletes
      Apr 15 at 15:50

















    • Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

      – bukwyrm
      Apr 15 at 15:22












    • @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

      – Steven B. Segletes
      Apr 15 at 15:50
















    Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

    – bukwyrm
    Apr 15 at 15:22






    Thank you! Can you explain what is going on? If i understand it correctly, you def-ed atscomparetoken so that the ifx could work on two tokens - is there a reason you packed the whole thing into a command? Also, do you know why one needs the string as an expansion inside a token (for the ifx case it is clear, but why dies if not work?)

    – bukwyrm
    Apr 15 at 15:22














    @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

    – Steven B. Segletes
    Apr 15 at 15:50





    @bukwyrm Correct, the ifx works on two tokens, and the comparison is whether the substitution text (one level of expansion) for the two tokens matches or not. The problem with trying to do this with if is that if fully expands and then compares the first two tokens; thus, ifaccessflavor ats expands to if atsats and a is compared to t, with the remaining sats extraneous.

    – Steven B. Segletes
    Apr 15 at 15:50













    2
















    If you want to maintain the if...else...fi structure, you can use



    documentclassarticle
    usepackagepdftexcmds

    makeatletter
    newcommandflavor[1]%
    TTfi
    ifnumpdf@strcmp#1accessflavor=z@

    makeatother

    begindocument

    defaccessflavorats

    Shown

    ifflavorats
    This text is only shown if the Flavor of Access is `ats'.
    fi

    defaccessflavornotats

    Not shown

    ifflavorats
    This text is only shown if the Flavor of Access is `ats'.
    fi

    enddocument


    The usage of pdftexcmds is to obtain engine independence, so the code works with pdftex, luatex and xetex.



    The trick is that if expands tokens.



    Note that this can be used inside other conditionals.



    enter image description here






    share|improve this answer





























      2
















      If you want to maintain the if...else...fi structure, you can use



      documentclassarticle
      usepackagepdftexcmds

      makeatletter
      newcommandflavor[1]%
      TTfi
      ifnumpdf@strcmp#1accessflavor=z@

      makeatother

      begindocument

      defaccessflavorats

      Shown

      ifflavorats
      This text is only shown if the Flavor of Access is `ats'.
      fi

      defaccessflavornotats

      Not shown

      ifflavorats
      This text is only shown if the Flavor of Access is `ats'.
      fi

      enddocument


      The usage of pdftexcmds is to obtain engine independence, so the code works with pdftex, luatex and xetex.



      The trick is that if expands tokens.



      Note that this can be used inside other conditionals.



      enter image description here






      share|improve this answer



























        2














        2










        2









        If you want to maintain the if...else...fi structure, you can use



        documentclassarticle
        usepackagepdftexcmds

        makeatletter
        newcommandflavor[1]%
        TTfi
        ifnumpdf@strcmp#1accessflavor=z@

        makeatother

        begindocument

        defaccessflavorats

        Shown

        ifflavorats
        This text is only shown if the Flavor of Access is `ats'.
        fi

        defaccessflavornotats

        Not shown

        ifflavorats
        This text is only shown if the Flavor of Access is `ats'.
        fi

        enddocument


        The usage of pdftexcmds is to obtain engine independence, so the code works with pdftex, luatex and xetex.



        The trick is that if expands tokens.



        Note that this can be used inside other conditionals.



        enter image description here






        share|improve this answer













        If you want to maintain the if...else...fi structure, you can use



        documentclassarticle
        usepackagepdftexcmds

        makeatletter
        newcommandflavor[1]%
        TTfi
        ifnumpdf@strcmp#1accessflavor=z@

        makeatother

        begindocument

        defaccessflavorats

        Shown

        ifflavorats
        This text is only shown if the Flavor of Access is `ats'.
        fi

        defaccessflavornotats

        Not shown

        ifflavorats
        This text is only shown if the Flavor of Access is `ats'.
        fi

        enddocument


        The usage of pdftexcmds is to obtain engine independence, so the code works with pdftex, luatex and xetex.



        The trick is that if expands tokens.



        Note that this can be used inside other conditionals.



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 15 at 15:29









        egregegreg

        770k91 gold badges2011 silver badges3367 bronze badges




        770k91 gold badges2011 silver badges3367 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484974%2fplain-if-structure-with-one-def-ed-token-and-one-literal%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?