plain IF structure with one def-ed token and one literal Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)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

Baking rewards as operations

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

First paper to introduce the "principal-agent problem"

Did pre-Columbian Americans know the spherical shape of the Earth?

NIntegrate on a solution of a matrix ODE

Short story about astronauts fertilizing soil with their own bodies

Is there a verb for listening stealthily?

Where and when has Thucydides been studied?

Can two people see the same photon?

How many time has Arya actually used Needle?

Random body shuffle every night—can we still function?

Why can't fire hurt Daenerys but it did to Jon Snow in season 1?

How do you write "wild blueberries flavored"?

Is this Kuo-toa homebrew race balanced?

Twin's vs. Twins'

Is this Half-dragon Quaggoth boss monster balanced?

2018 MacBook Pro won't let me install macOS High Sierra 10.13 from USB installer

Vertical ranges of Column Plots in 12

As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?

Does the transliteration of 'Dravidian' exist in Hindu scripture? Does 'Dravida' refer to a Geographical area or an ethnic group?

Marquee sign letters

Does the universe have a fixed centre of mass?

In musical terms, what properties are varied by the human voice to produce different words / syllables?



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



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)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










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









Kurt

41.8k950164




41.8k950164










asked Apr 15 at 14:54









bukwyrmbukwyrm

1212




1212












  • 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/3.0/"u003ecc by-sa 3.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

    163k9207419




    163k9207419












    • 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

        736k8919353261




        736k8919353261



























            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

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company