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

Can a non-EU citizen traveling with me come with me through the EU passport line?

Were Kohanim forbidden from serving in King David's army?

"Seemed to had" is it correct?

Letter Boxed validator

Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?

Did Xerox really develop the first LAN?

Why does Python start at index -1 when indexing a list from the end?

What happens to sewage if there is no river near by?

How to motivate offshore teams and trust them to deliver?

I am not a queen, who am I?

Dominant seventh chord in the major scale contains diminished triad of the seventh?

Should I discuss the type of campaign with my players?

Is the argument below valid?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Why is black pepper both grey and black?

iPhone Wallpaper?

Gastric acid as a weapon

Output the ŋarâþ crîþ alphabet song without using (m)any letters

What LEGO pieces have "real-world" functionality?

What is the musical term for a note that continously plays through a melody?

How to do this path/lattice with tikz

How do I keep my slimes from escaping their pens?

How much radiation do nuclear physics experiments expose researchers to nowadays?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?



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



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm 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
    15 hours ago















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
    15 hours ago













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 15 hours ago









Kurt

41.2k950164




41.2k950164










asked 15 hours ago









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
    15 hours ago

















  • 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
    15 hours ago
















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
15 hours ago





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
15 hours ago










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
    15 hours ago












  • @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
    14 hours ago


















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
      15 hours ago












    • @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
      14 hours ago















    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
      15 hours ago












    • @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
      14 hours ago













    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 15 hours ago









    Steven B. SegletesSteven B. Segletes

    162k9206418




    162k9206418












    • 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
      15 hours ago












    • @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
      14 hours ago

















    • 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
      15 hours ago












    • @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
      14 hours ago
















    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
    15 hours ago






    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
    15 hours ago














    @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
    14 hours ago





    @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
    14 hours ago











    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 15 hours ago









        egregegreg

        734k8919333257




        734k8919333257



























            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







            -ifthenelse

            Popular posts from this blog

            Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

            My Life (Mary J. Blige album) Contents Background Critical reception Accolades Commercial performance Track listing Personnel Charts Certifications See also References External links Navigation menu"1. Mary J Blige, My Life - The 50 Best R&B albums of the '90s""American album certifications – Mary J. Blige – My Life""Mary J. Blige's My Life LP (1994) revisited with co-producer Chucky Thompson | Return To The Classics"the original"Key Tracks: Mary J. Blige's My Life""My Life – Mary J. Blige""Worth The Wait""My Life""Forget '411,' Mary J., Better Call 911""Spins"My Life AccoladesThe 500 Greatest Albums of All TimeTime's All-TIME 100 Albums"Top RPM Albums: Issue chartid""Dutchcharts.nl – Mary J. Blige – My Life""Mary J. Blige | Artist | Official Charts""Mary J. Blige Chart History (Billboard 200)""Mary J. Blige Chart History (Top R&B/Hip-Hop Albums)""Canadian album certifications – Mary J Blige – My Life""British album certifications – Mary J Blige – My Life""American album certifications – Mary J Blige – My Life"My LifeMy Life accoladesee

            Frič See also Navigation menuinternal link