Euler and minus signMaking a shorter minusTo Imply a Dash and not Minus Sign in Math ModePlus-minus sign in...

Manager has noticed coworker's excessive breaks. Should I warn him?

Why Is Image Exporting At Larger Dimensions Than In Illustrator File?

Did the characters in Moving Pictures not know about cameras like Twoflower's?

What is the reason behind this musical reference to Pinocchio in the Close Encounters main theme?

Euler and minus sign

TikZtree with asymmetric siblings

Why do we interpret the accelerated expansion of the universe as the proof for the existence of dark energy?

How many copper coins fit inside a cubic foot?

Aligning Systems of Equations

Do these large-scale, human power-plant-tending robots from the Matrix movies have a name, in-universe or out?

How to achieve physical gender equality?

In the Lost in Space intro why was Dr. Smith actor listed as a special guest star?

Why are "square law" devices important?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

When distributing a Linux kernel driver as source code, what's the difference between Proprietary and GPL license?

Is Screenshot Time-tracking Common?

Identical projects by students at two different colleges: still plagiarism?

How bad is a Computer Science course that doesn't teach Design Patterns?

Why write a book when there's a movie in my head?

How to typeset a small black square as a binary operator?

What does "don't have a baby" imply or mean in this sentence?

How do I avoid the "chosen hero" feeling?

What does it mean when an external ID field follows a DML Statement?

How Create a list of the first 10,000 digits of Pi and sum it?



Euler and minus sign


Making a shorter minusTo Imply a Dash and not Minus Sign in Math ModePlus-minus sign in the continued fractionIncorrect spacing after minus sign with combination of amsmath and hyperrefThicker line for minus sign and plus signSubscript like math but without the minus signHphantom of minus sign in math modeWider space between minus sign and number when surrounded by vertsHorizontally misalligned sub-/superscripts in fractions when using 'minus' signUsing big( causes extra space around minus sign













5















I'm trying to define a macro to typeset Eulers complex e-power with or without a minus sign in its argument. I would like the macro to automatically detect if its argument starts with a -. I have the following MWE which uses and optional argument:



documentclass[a4paper,12pt,fleqn]{article}

defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
defimunit{mathrm{imaginaryunit}} % ... in upright math
defce{mathrm{e}} % the constant e, upright of course
makeatletter
defepowim{@ifnextchar[{epowimi}{epowimi[]}} % e to-the-power-of imaginary unit
defepowimi[#1]#2{ce^{#1ifimaginaryunit jrelax,fiimunit#2}} % e to-the-power-of imaginary unit
makeatother

begin{document}

begin{equation}
epowim{alpha}qquad epowim[-]{alpha} qquad ce^{-imunitalpha}
end{equation}

end{document}


So I would like a macro that detects if its argument starts with a -:



epowim{-alpha}


should detect the - and place it before the imaginary unit instead of placing it after the imaginary unit.



So the question is if it can be done and how.










share|improve this question





























    5















    I'm trying to define a macro to typeset Eulers complex e-power with or without a minus sign in its argument. I would like the macro to automatically detect if its argument starts with a -. I have the following MWE which uses and optional argument:



    documentclass[a4paper,12pt,fleqn]{article}

    defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
    defimunit{mathrm{imaginaryunit}} % ... in upright math
    defce{mathrm{e}} % the constant e, upright of course
    makeatletter
    defepowim{@ifnextchar[{epowimi}{epowimi[]}} % e to-the-power-of imaginary unit
    defepowimi[#1]#2{ce^{#1ifimaginaryunit jrelax,fiimunit#2}} % e to-the-power-of imaginary unit
    makeatother

    begin{document}

    begin{equation}
    epowim{alpha}qquad epowim[-]{alpha} qquad ce^{-imunitalpha}
    end{equation}

    end{document}


    So I would like a macro that detects if its argument starts with a -:



    epowim{-alpha}


    should detect the - and place it before the imaginary unit instead of placing it after the imaginary unit.



    So the question is if it can be done and how.










    share|improve this question



























      5












      5








      5


      0






      I'm trying to define a macro to typeset Eulers complex e-power with or without a minus sign in its argument. I would like the macro to automatically detect if its argument starts with a -. I have the following MWE which uses and optional argument:



      documentclass[a4paper,12pt,fleqn]{article}

      defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
      defimunit{mathrm{imaginaryunit}} % ... in upright math
      defce{mathrm{e}} % the constant e, upright of course
      makeatletter
      defepowim{@ifnextchar[{epowimi}{epowimi[]}} % e to-the-power-of imaginary unit
      defepowimi[#1]#2{ce^{#1ifimaginaryunit jrelax,fiimunit#2}} % e to-the-power-of imaginary unit
      makeatother

      begin{document}

      begin{equation}
      epowim{alpha}qquad epowim[-]{alpha} qquad ce^{-imunitalpha}
      end{equation}

      end{document}


      So I would like a macro that detects if its argument starts with a -:



      epowim{-alpha}


      should detect the - and place it before the imaginary unit instead of placing it after the imaginary unit.



      So the question is if it can be done and how.










      share|improve this question
















      I'm trying to define a macro to typeset Eulers complex e-power with or without a minus sign in its argument. I would like the macro to automatically detect if its argument starts with a -. I have the following MWE which uses and optional argument:



      documentclass[a4paper,12pt,fleqn]{article}

      defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
      defimunit{mathrm{imaginaryunit}} % ... in upright math
      defce{mathrm{e}} % the constant e, upright of course
      makeatletter
      defepowim{@ifnextchar[{epowimi}{epowimi[]}} % e to-the-power-of imaginary unit
      defepowimi[#1]#2{ce^{#1ifimaginaryunit jrelax,fiimunit#2}} % e to-the-power-of imaginary unit
      makeatother

      begin{document}

      begin{equation}
      epowim{alpha}qquad epowim[-]{alpha} qquad ce^{-imunitalpha}
      end{equation}

      end{document}


      So I would like a macro that detects if its argument starts with a -:



      epowim{-alpha}


      should detect the - and place it before the imaginary unit instead of placing it after the imaginary unit.



      So the question is if it can be done and how.







      math-mode optional-arguments






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 hours ago







      Jesse op den Brouw

















      asked 3 hours ago









      Jesse op den BrouwJesse op den Brouw

      522119




      522119






















          2 Answers
          2






          active

          oldest

          votes


















          4














          Something like this?



          documentclass[a4paper,12pt,fleqn]{article}
          defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
          defimunit{mathrm{imaginaryunit}} % ... in upright math
          defce{mathrm{e}} % the constant e, upright of course
          newcommandepowim[1]{ce^{epowimaux#1endep}}
          defepowimaux#1#2endep{ifx-#1relax-imunitelse,imunit#1fi#2}
          begin{document}
          begin{equation}
          epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
          end{equation}
          [
          epowim{x+t}quadepowim{-x+t}
          ]
          end{document}


          enter image description here






          share|improve this answer





















          • 1





            Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

            – Jesse op den Brouw
            3 hours ago













          • @JesseopdenBrouw Thanks. And feel free to adapt to your need.

            – Steven B. Segletes
            3 hours ago











          • @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

            – Steven B. Segletes
            2 hours ago











          • I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

            – egreg
            29 mins ago



















          0














          Avoid def, your life will be easier.



          Since you seem to know about @ifnextchar:



          documentclass[a4paper,12pt,fleqn]{article}

          % the imaginary unit, j for engineers and i for the rest of the world
          newcommandimaginaryunit{j}
          % in upright type as engineers do; also Euler's constant
          newcommandimunit{mathrm{imaginaryunit}}
          newcommandce{mathrm{e}}

          newcommand{fiximunit}{ifimaginaryunit j,fi}

          makeatletter
          newcommand{epowim}[1]{ce^{epowim@#1}}
          newcommand{epowim@}{@ifnextchar-{epowim@@}{epowim@@{fiximunit}}}
          newcommand{epowim@@}[1]{#1imunit}
          makeatother

          begin{document}

          begin{equation}
          epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
          qquad epowim{} qquad epowim{-}
          end{equation}

          end{document}


          Explanation: @ifnextchar- uses the next argument if - is found, the successive one otherwise, but without removing -. So if - is called the result will be



          epowim@@-alpha


          which passes - as argument to epowim@@. Otherwise epowim@@ is called with fiximunit as argument.



          This would not fail with epowim{} or epowim{-} to typeset ej and e−j respectively.



          A perhaps simpler implementation with xparse:



          documentclass[a4paper,12pt,fleqn]{article}

          usepackage{xparse}

          % the imaginary unit, j for engineers and i for the rest of the world
          newcommandimaginaryunit{j}
          % in upright type as engineers do; also Euler's constant
          newcommandimunit{mathrm{imaginaryunit}}
          newcommandce{mathrm{e}}

          newcommand{fiximunit}{ifimaginaryunit j,fi}

          NewDocumentCommand{epowim}{m}{ce^{powim#1}}
          NewDocumentCommand{powim}{t-}{IfBooleanTF{#1}{-imunit}{fiximunitimunit}}

          begin{document}

          begin{equation}
          epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
          qquad epowim{} qquad epowim{-}
          end{equation}

          end{document}


          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%2f476045%2feuler-and-minus-sign%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









            4














            Something like this?



            documentclass[a4paper,12pt,fleqn]{article}
            defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
            defimunit{mathrm{imaginaryunit}} % ... in upright math
            defce{mathrm{e}} % the constant e, upright of course
            newcommandepowim[1]{ce^{epowimaux#1endep}}
            defepowimaux#1#2endep{ifx-#1relax-imunitelse,imunit#1fi#2}
            begin{document}
            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            end{equation}
            [
            epowim{x+t}quadepowim{-x+t}
            ]
            end{document}


            enter image description here






            share|improve this answer





















            • 1





              Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

              – Jesse op den Brouw
              3 hours ago













            • @JesseopdenBrouw Thanks. And feel free to adapt to your need.

              – Steven B. Segletes
              3 hours ago











            • @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

              – Steven B. Segletes
              2 hours ago











            • I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

              – egreg
              29 mins ago
















            4














            Something like this?



            documentclass[a4paper,12pt,fleqn]{article}
            defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
            defimunit{mathrm{imaginaryunit}} % ... in upright math
            defce{mathrm{e}} % the constant e, upright of course
            newcommandepowim[1]{ce^{epowimaux#1endep}}
            defepowimaux#1#2endep{ifx-#1relax-imunitelse,imunit#1fi#2}
            begin{document}
            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            end{equation}
            [
            epowim{x+t}quadepowim{-x+t}
            ]
            end{document}


            enter image description here






            share|improve this answer





















            • 1





              Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

              – Jesse op den Brouw
              3 hours ago













            • @JesseopdenBrouw Thanks. And feel free to adapt to your need.

              – Steven B. Segletes
              3 hours ago











            • @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

              – Steven B. Segletes
              2 hours ago











            • I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

              – egreg
              29 mins ago














            4












            4








            4







            Something like this?



            documentclass[a4paper,12pt,fleqn]{article}
            defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
            defimunit{mathrm{imaginaryunit}} % ... in upright math
            defce{mathrm{e}} % the constant e, upright of course
            newcommandepowim[1]{ce^{epowimaux#1endep}}
            defepowimaux#1#2endep{ifx-#1relax-imunitelse,imunit#1fi#2}
            begin{document}
            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            end{equation}
            [
            epowim{x+t}quadepowim{-x+t}
            ]
            end{document}


            enter image description here






            share|improve this answer















            Something like this?



            documentclass[a4paper,12pt,fleqn]{article}
            defimaginaryunit{j} % the imaginary unit, i for mathematician and theoretical physicist, j for the rest of the world.
            defimunit{mathrm{imaginaryunit}} % ... in upright math
            defce{mathrm{e}} % the constant e, upright of course
            newcommandepowim[1]{ce^{epowimaux#1endep}}
            defepowimaux#1#2endep{ifx-#1relax-imunitelse,imunit#1fi#2}
            begin{document}
            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            end{equation}
            [
            epowim{x+t}quadepowim{-x+t}
            ]
            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 3 hours ago

























            answered 3 hours ago









            Steven B. SegletesSteven B. Segletes

            156k9201411




            156k9201411








            • 1





              Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

              – Jesse op den Brouw
              3 hours ago













            • @JesseopdenBrouw Thanks. And feel free to adapt to your need.

              – Steven B. Segletes
              3 hours ago











            • @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

              – Steven B. Segletes
              2 hours ago











            • I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

              – egreg
              29 mins ago














            • 1





              Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

              – Jesse op den Brouw
              3 hours ago













            • @JesseopdenBrouw Thanks. And feel free to adapt to your need.

              – Steven B. Segletes
              3 hours ago











            • @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

              – Steven B. Segletes
              2 hours ago











            • I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

              – egreg
              29 mins ago








            1




            1





            Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

            – Jesse op den Brouw
            3 hours ago







            Exactly what i need. I changed the definition to defepowimaux#1#2endep{ifx-#1relax-imunitelseifimaginaryunit jrelax,fiimunit#1fi#2} to compensate for the fact that the j is too close to the e but not when using i as imaginary unit

            – Jesse op den Brouw
            3 hours ago















            @JesseopdenBrouw Thanks. And feel free to adapt to your need.

            – Steven B. Segletes
            3 hours ago





            @JesseopdenBrouw Thanks. And feel free to adapt to your need.

            – Steven B. Segletes
            3 hours ago













            @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

            – Steven B. Segletes
            2 hours ago





            @JesseopdenBrouw I might only suggest using if jimaginaryunit rather than ifimaginaryunit j. Or better still, expandafterifximaginaryunit j

            – Steven B. Segletes
            2 hours ago













            I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

            – egreg
            29 mins ago





            I see nothing wrong in ifimaginaryunit j, provided imaginaryunit is either i or j. Oh, and did you try epowim{-}? ;-)

            – egreg
            29 mins ago











            0














            Avoid def, your life will be easier.



            Since you seem to know about @ifnextchar:



            documentclass[a4paper,12pt,fleqn]{article}

            % the imaginary unit, j for engineers and i for the rest of the world
            newcommandimaginaryunit{j}
            % in upright type as engineers do; also Euler's constant
            newcommandimunit{mathrm{imaginaryunit}}
            newcommandce{mathrm{e}}

            newcommand{fiximunit}{ifimaginaryunit j,fi}

            makeatletter
            newcommand{epowim}[1]{ce^{epowim@#1}}
            newcommand{epowim@}{@ifnextchar-{epowim@@}{epowim@@{fiximunit}}}
            newcommand{epowim@@}[1]{#1imunit}
            makeatother

            begin{document}

            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            qquad epowim{} qquad epowim{-}
            end{equation}

            end{document}


            Explanation: @ifnextchar- uses the next argument if - is found, the successive one otherwise, but without removing -. So if - is called the result will be



            epowim@@-alpha


            which passes - as argument to epowim@@. Otherwise epowim@@ is called with fiximunit as argument.



            This would not fail with epowim{} or epowim{-} to typeset ej and e−j respectively.



            A perhaps simpler implementation with xparse:



            documentclass[a4paper,12pt,fleqn]{article}

            usepackage{xparse}

            % the imaginary unit, j for engineers and i for the rest of the world
            newcommandimaginaryunit{j}
            % in upright type as engineers do; also Euler's constant
            newcommandimunit{mathrm{imaginaryunit}}
            newcommandce{mathrm{e}}

            newcommand{fiximunit}{ifimaginaryunit j,fi}

            NewDocumentCommand{epowim}{m}{ce^{powim#1}}
            NewDocumentCommand{powim}{t-}{IfBooleanTF{#1}{-imunit}{fiximunitimunit}}

            begin{document}

            begin{equation}
            epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
            qquad epowim{} qquad epowim{-}
            end{equation}

            end{document}


            enter image description here






            share|improve this answer






























              0














              Avoid def, your life will be easier.



              Since you seem to know about @ifnextchar:



              documentclass[a4paper,12pt,fleqn]{article}

              % the imaginary unit, j for engineers and i for the rest of the world
              newcommandimaginaryunit{j}
              % in upright type as engineers do; also Euler's constant
              newcommandimunit{mathrm{imaginaryunit}}
              newcommandce{mathrm{e}}

              newcommand{fiximunit}{ifimaginaryunit j,fi}

              makeatletter
              newcommand{epowim}[1]{ce^{epowim@#1}}
              newcommand{epowim@}{@ifnextchar-{epowim@@}{epowim@@{fiximunit}}}
              newcommand{epowim@@}[1]{#1imunit}
              makeatother

              begin{document}

              begin{equation}
              epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
              qquad epowim{} qquad epowim{-}
              end{equation}

              end{document}


              Explanation: @ifnextchar- uses the next argument if - is found, the successive one otherwise, but without removing -. So if - is called the result will be



              epowim@@-alpha


              which passes - as argument to epowim@@. Otherwise epowim@@ is called with fiximunit as argument.



              This would not fail with epowim{} or epowim{-} to typeset ej and e−j respectively.



              A perhaps simpler implementation with xparse:



              documentclass[a4paper,12pt,fleqn]{article}

              usepackage{xparse}

              % the imaginary unit, j for engineers and i for the rest of the world
              newcommandimaginaryunit{j}
              % in upright type as engineers do; also Euler's constant
              newcommandimunit{mathrm{imaginaryunit}}
              newcommandce{mathrm{e}}

              newcommand{fiximunit}{ifimaginaryunit j,fi}

              NewDocumentCommand{epowim}{m}{ce^{powim#1}}
              NewDocumentCommand{powim}{t-}{IfBooleanTF{#1}{-imunit}{fiximunitimunit}}

              begin{document}

              begin{equation}
              epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
              qquad epowim{} qquad epowim{-}
              end{equation}

              end{document}


              enter image description here






              share|improve this answer




























                0












                0








                0







                Avoid def, your life will be easier.



                Since you seem to know about @ifnextchar:



                documentclass[a4paper,12pt,fleqn]{article}

                % the imaginary unit, j for engineers and i for the rest of the world
                newcommandimaginaryunit{j}
                % in upright type as engineers do; also Euler's constant
                newcommandimunit{mathrm{imaginaryunit}}
                newcommandce{mathrm{e}}

                newcommand{fiximunit}{ifimaginaryunit j,fi}

                makeatletter
                newcommand{epowim}[1]{ce^{epowim@#1}}
                newcommand{epowim@}{@ifnextchar-{epowim@@}{epowim@@{fiximunit}}}
                newcommand{epowim@@}[1]{#1imunit}
                makeatother

                begin{document}

                begin{equation}
                epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
                qquad epowim{} qquad epowim{-}
                end{equation}

                end{document}


                Explanation: @ifnextchar- uses the next argument if - is found, the successive one otherwise, but without removing -. So if - is called the result will be



                epowim@@-alpha


                which passes - as argument to epowim@@. Otherwise epowim@@ is called with fiximunit as argument.



                This would not fail with epowim{} or epowim{-} to typeset ej and e−j respectively.



                A perhaps simpler implementation with xparse:



                documentclass[a4paper,12pt,fleqn]{article}

                usepackage{xparse}

                % the imaginary unit, j for engineers and i for the rest of the world
                newcommandimaginaryunit{j}
                % in upright type as engineers do; also Euler's constant
                newcommandimunit{mathrm{imaginaryunit}}
                newcommandce{mathrm{e}}

                newcommand{fiximunit}{ifimaginaryunit j,fi}

                NewDocumentCommand{epowim}{m}{ce^{powim#1}}
                NewDocumentCommand{powim}{t-}{IfBooleanTF{#1}{-imunit}{fiximunitimunit}}

                begin{document}

                begin{equation}
                epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
                qquad epowim{} qquad epowim{-}
                end{equation}

                end{document}


                enter image description here






                share|improve this answer















                Avoid def, your life will be easier.



                Since you seem to know about @ifnextchar:



                documentclass[a4paper,12pt,fleqn]{article}

                % the imaginary unit, j for engineers and i for the rest of the world
                newcommandimaginaryunit{j}
                % in upright type as engineers do; also Euler's constant
                newcommandimunit{mathrm{imaginaryunit}}
                newcommandce{mathrm{e}}

                newcommand{fiximunit}{ifimaginaryunit j,fi}

                makeatletter
                newcommand{epowim}[1]{ce^{epowim@#1}}
                newcommand{epowim@}{@ifnextchar-{epowim@@}{epowim@@{fiximunit}}}
                newcommand{epowim@@}[1]{#1imunit}
                makeatother

                begin{document}

                begin{equation}
                epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
                qquad epowim{} qquad epowim{-}
                end{equation}

                end{document}


                Explanation: @ifnextchar- uses the next argument if - is found, the successive one otherwise, but without removing -. So if - is called the result will be



                epowim@@-alpha


                which passes - as argument to epowim@@. Otherwise epowim@@ is called with fiximunit as argument.



                This would not fail with epowim{} or epowim{-} to typeset ej and e−j respectively.



                A perhaps simpler implementation with xparse:



                documentclass[a4paper,12pt,fleqn]{article}

                usepackage{xparse}

                % the imaginary unit, j for engineers and i for the rest of the world
                newcommandimaginaryunit{j}
                % in upright type as engineers do; also Euler's constant
                newcommandimunit{mathrm{imaginaryunit}}
                newcommandce{mathrm{e}}

                newcommand{fiximunit}{ifimaginaryunit j,fi}

                NewDocumentCommand{epowim}{m}{ce^{powim#1}}
                NewDocumentCommand{powim}{t-}{IfBooleanTF{#1}{-imunit}{fiximunitimunit}}

                begin{document}

                begin{equation}
                epowim{alpha}qquad epowim{-alpha} qquad ce^{-imunitalpha}
                qquad epowim{} qquad epowim{-}
                end{equation}

                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 28 mins ago

























                answered 1 hour ago









                egregegreg

                721k8719113210




                721k8719113210






























                    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%2f476045%2feuler-and-minus-sign%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

                    Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

                    Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

                    How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...