why this newcommand doesn't work in align environment?












4















I'm trying to use the 'newcommand' in the environment 'align', for that I created the 'newcommand' rbel that is an 'arrow' with a 'n' below It.
I put all the packages that I'm using.



     documentclass[A4,12pt]{article}
usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
usepackage{abraces}
usepackage{upgreek}
usepackage{mathrsfs}
usepackage{dsfont}
usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
usepackage{dsfont,float}
usepackage{color}
newcommand{rbel}{
mbox{;rightarrow_{hspace*{-0.3cm}{small n}};~}
}
begin{document}
begin{align}
theta_n>1, quad
dfrac{1}{theta_n^2} rbel 0
end{align}
end{document}


That gives these messages



"Missing } inserted. end{align}"
"Missing cr inserted. end{align}"
"Missing $ inserted. end{align}"
"Extra }, or forgotten $. end{align}"









share|improve this question









New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

    – Ulrich Diez
    13 hours ago








  • 2





    For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

    – Ulrich Diez
    13 hours ago











  • This is not causing your issue but with your preamble the dsfont package is loaded twice.

    – Ulrich Diez
    13 hours ago













  • There is also mathmbox from mathtools.

    – John Kormylo
    12 hours ago
















4















I'm trying to use the 'newcommand' in the environment 'align', for that I created the 'newcommand' rbel that is an 'arrow' with a 'n' below It.
I put all the packages that I'm using.



     documentclass[A4,12pt]{article}
usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
usepackage{abraces}
usepackage{upgreek}
usepackage{mathrsfs}
usepackage{dsfont}
usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
usepackage{dsfont,float}
usepackage{color}
newcommand{rbel}{
mbox{;rightarrow_{hspace*{-0.3cm}{small n}};~}
}
begin{document}
begin{align}
theta_n>1, quad
dfrac{1}{theta_n^2} rbel 0
end{align}
end{document}


That gives these messages



"Missing } inserted. end{align}"
"Missing cr inserted. end{align}"
"Missing $ inserted. end{align}"
"Extra }, or forgotten $. end{align}"









share|improve this question









New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

    – Ulrich Diez
    13 hours ago








  • 2





    For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

    – Ulrich Diez
    13 hours ago











  • This is not causing your issue but with your preamble the dsfont package is loaded twice.

    – Ulrich Diez
    13 hours ago













  • There is also mathmbox from mathtools.

    – John Kormylo
    12 hours ago














4












4








4








I'm trying to use the 'newcommand' in the environment 'align', for that I created the 'newcommand' rbel that is an 'arrow' with a 'n' below It.
I put all the packages that I'm using.



     documentclass[A4,12pt]{article}
usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
usepackage{abraces}
usepackage{upgreek}
usepackage{mathrsfs}
usepackage{dsfont}
usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
usepackage{dsfont,float}
usepackage{color}
newcommand{rbel}{
mbox{;rightarrow_{hspace*{-0.3cm}{small n}};~}
}
begin{document}
begin{align}
theta_n>1, quad
dfrac{1}{theta_n^2} rbel 0
end{align}
end{document}


That gives these messages



"Missing } inserted. end{align}"
"Missing cr inserted. end{align}"
"Missing $ inserted. end{align}"
"Extra }, or forgotten $. end{align}"









share|improve this question









New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm trying to use the 'newcommand' in the environment 'align', for that I created the 'newcommand' rbel that is an 'arrow' with a 'n' below It.
I put all the packages that I'm using.



     documentclass[A4,12pt]{article}
usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
usepackage{abraces}
usepackage{upgreek}
usepackage{mathrsfs}
usepackage{dsfont}
usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
usepackage{dsfont,float}
usepackage{color}
newcommand{rbel}{
mbox{;rightarrow_{hspace*{-0.3cm}{small n}};~}
}
begin{document}
begin{align}
theta_n>1, quad
dfrac{1}{theta_n^2} rbel 0
end{align}
end{document}


That gives these messages



"Missing } inserted. end{align}"
"Missing cr inserted. end{align}"
"Missing $ inserted. end{align}"
"Extra }, or forgotten $. end{align}"






math-mode macros equations errors environments






share|improve this question









New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 13 hours ago









Bernard

169k773198




169k773198






New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 13 hours ago









JirJir

213




213




New contributor




Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Jir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

    – Ulrich Diez
    13 hours ago








  • 2





    For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

    – Ulrich Diez
    13 hours ago











  • This is not causing your issue but with your preamble the dsfont package is loaded twice.

    – Ulrich Diez
    13 hours ago













  • There is also mathmbox from mathtools.

    – John Kormylo
    12 hours ago














  • 1





    Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

    – Ulrich Diez
    13 hours ago








  • 2





    For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

    – Ulrich Diez
    13 hours ago











  • This is not causing your issue but with your preamble the dsfont package is loaded twice.

    – Ulrich Diez
    13 hours ago













  • There is also mathmbox from mathtools.

    – John Kormylo
    12 hours ago








1




1





Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

– Ulrich Diez
13 hours ago







Your rbel-command contains an mbox. Even in math-mode the content of mboxes isn't in math-mode any more as mboxes switch to text-mode...

– Ulrich Diez
13 hours ago






2




2





For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

– Ulrich Diez
13 hours ago





For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the mbox: newcommand{rbel}{{;rightarrow_{hspace*{-0.3cm}{small n}};~}}

– Ulrich Diez
13 hours ago













This is not causing your issue but with your preamble the dsfont package is loaded twice.

– Ulrich Diez
13 hours ago







This is not causing your issue but with your preamble the dsfont package is loaded twice.

– Ulrich Diez
13 hours ago















There is also mathmbox from mathtools.

– John Kormylo
12 hours ago





There is also mathmbox from mathtools.

– John Kormylo
12 hours ago










3 Answers
3






active

oldest

votes


















4














It seems you want an arrow with “n” underneath:



documentclass[a4paper,12pt]{article}
usepackage{amsmath}

newcommand{rbel}{xrightarrow[n]{}}

begin{document}

[
theta_n>1, quad dfrac{1}{theta_n^2} rbel 0
]

end{document}


The error is because you're exiting from math mode when in mbox.



I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.



enter image description here






share|improve this answer































    3














    It works if the mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and small is ignored in math mode.



    documentclass[12pt]{article}
    usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
    usepackage[english]{babel}
    usepackage[utf8]{inputenc}
    usepackage[T1]{fontenc}
    usepackage{graphicx}
    usepackage{abraces}
    usepackage{upgreek}
    usepackage{mathrsfs}
    usepackage{dsfont}
    usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
    usepackage{dsfont,float}
    usepackage{color}
    newcommand{rbel}{
    ensuremath{;rightarrow_{hspace*{-0.3cm}{n}};~}
    }
    begin{document}
    begin{align}
    theta_n>1, quad
    dfrac{1}{theta_n^2} rbel 0
    end{align}
    end{document}





    share|improve this answer








    New contributor




    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




























      0














      Another simple solution for your question using tikz-cd. You can observe from the picture that n is more near at the arrow of same dimension of the lenght of xrightarrow.



      enter image description here



      Here there is the MWE:



      documentclass[12pt]{article}
      usepackage{mathtools,tikz-cd}
      begin{document}
      [
      theta_n>1, quad begin{tikzcd}[column sep=.4cm]
      dfrac{1}{theta_n^2} arrow[r, "n"'] & 0
      end{tikzcd}
      ]
      end{document}





      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
        });


        }
        });






        Jir is a new contributor. Be nice, and check out our Code of Conduct.










        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474069%2fwhy-this-newcommand-doesnt-work-in-align-environment%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4














        It seems you want an arrow with “n” underneath:



        documentclass[a4paper,12pt]{article}
        usepackage{amsmath}

        newcommand{rbel}{xrightarrow[n]{}}

        begin{document}

        [
        theta_n>1, quad dfrac{1}{theta_n^2} rbel 0
        ]

        end{document}


        The error is because you're exiting from math mode when in mbox.



        I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.



        enter image description here






        share|improve this answer




























          4














          It seems you want an arrow with “n” underneath:



          documentclass[a4paper,12pt]{article}
          usepackage{amsmath}

          newcommand{rbel}{xrightarrow[n]{}}

          begin{document}

          [
          theta_n>1, quad dfrac{1}{theta_n^2} rbel 0
          ]

          end{document}


          The error is because you're exiting from math mode when in mbox.



          I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.



          enter image description here






          share|improve this answer


























            4












            4








            4







            It seems you want an arrow with “n” underneath:



            documentclass[a4paper,12pt]{article}
            usepackage{amsmath}

            newcommand{rbel}{xrightarrow[n]{}}

            begin{document}

            [
            theta_n>1, quad dfrac{1}{theta_n^2} rbel 0
            ]

            end{document}


            The error is because you're exiting from math mode when in mbox.



            I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.



            enter image description here






            share|improve this answer













            It seems you want an arrow with “n” underneath:



            documentclass[a4paper,12pt]{article}
            usepackage{amsmath}

            newcommand{rbel}{xrightarrow[n]{}}

            begin{document}

            [
            theta_n>1, quad dfrac{1}{theta_n^2} rbel 0
            ]

            end{document}


            The error is because you're exiting from math mode when in mbox.



            I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 13 hours ago









            egregegreg

            718k8719053202




            718k8719053202























                3














                It works if the mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and small is ignored in math mode.



                documentclass[12pt]{article}
                usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
                usepackage[english]{babel}
                usepackage[utf8]{inputenc}
                usepackage[T1]{fontenc}
                usepackage{graphicx}
                usepackage{abraces}
                usepackage{upgreek}
                usepackage{mathrsfs}
                usepackage{dsfont}
                usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
                usepackage{dsfont,float}
                usepackage{color}
                newcommand{rbel}{
                ensuremath{;rightarrow_{hspace*{-0.3cm}{n}};~}
                }
                begin{document}
                begin{align}
                theta_n>1, quad
                dfrac{1}{theta_n^2} rbel 0
                end{align}
                end{document}





                share|improve this answer








                New contributor




                jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.

























                  3














                  It works if the mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and small is ignored in math mode.



                  documentclass[12pt]{article}
                  usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
                  usepackage[english]{babel}
                  usepackage[utf8]{inputenc}
                  usepackage[T1]{fontenc}
                  usepackage{graphicx}
                  usepackage{abraces}
                  usepackage{upgreek}
                  usepackage{mathrsfs}
                  usepackage{dsfont}
                  usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
                  usepackage{dsfont,float}
                  usepackage{color}
                  newcommand{rbel}{
                  ensuremath{;rightarrow_{hspace*{-0.3cm}{n}};~}
                  }
                  begin{document}
                  begin{align}
                  theta_n>1, quad
                  dfrac{1}{theta_n^2} rbel 0
                  end{align}
                  end{document}





                  share|improve this answer








                  New contributor




                  jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.























                    3












                    3








                    3







                    It works if the mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and small is ignored in math mode.



                    documentclass[12pt]{article}
                    usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
                    usepackage[english]{babel}
                    usepackage[utf8]{inputenc}
                    usepackage[T1]{fontenc}
                    usepackage{graphicx}
                    usepackage{abraces}
                    usepackage{upgreek}
                    usepackage{mathrsfs}
                    usepackage{dsfont}
                    usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
                    usepackage{dsfont,float}
                    usepackage{color}
                    newcommand{rbel}{
                    ensuremath{;rightarrow_{hspace*{-0.3cm}{n}};~}
                    }
                    begin{document}
                    begin{align}
                    theta_n>1, quad
                    dfrac{1}{theta_n^2} rbel 0
                    end{align}
                    end{document}





                    share|improve this answer








                    New contributor




                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.










                    It works if the mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and small is ignored in math mode.



                    documentclass[12pt]{article}
                    usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
                    usepackage[english]{babel}
                    usepackage[utf8]{inputenc}
                    usepackage[T1]{fontenc}
                    usepackage{graphicx}
                    usepackage{abraces}
                    usepackage{upgreek}
                    usepackage{mathrsfs}
                    usepackage{dsfont}
                    usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
                    usepackage{dsfont,float}
                    usepackage{color}
                    newcommand{rbel}{
                    ensuremath{;rightarrow_{hspace*{-0.3cm}{n}};~}
                    }
                    begin{document}
                    begin{align}
                    theta_n>1, quad
                    dfrac{1}{theta_n^2} rbel 0
                    end{align}
                    end{document}






                    share|improve this answer








                    New contributor




                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    share|improve this answer



                    share|improve this answer






                    New contributor




                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    answered 13 hours ago









                    jihajiha

                    634




                    634




                    New contributor




                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





                    New contributor





                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    jiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.























                        0














                        Another simple solution for your question using tikz-cd. You can observe from the picture that n is more near at the arrow of same dimension of the lenght of xrightarrow.



                        enter image description here



                        Here there is the MWE:



                        documentclass[12pt]{article}
                        usepackage{mathtools,tikz-cd}
                        begin{document}
                        [
                        theta_n>1, quad begin{tikzcd}[column sep=.4cm]
                        dfrac{1}{theta_n^2} arrow[r, "n"'] & 0
                        end{tikzcd}
                        ]
                        end{document}





                        share|improve this answer






























                          0














                          Another simple solution for your question using tikz-cd. You can observe from the picture that n is more near at the arrow of same dimension of the lenght of xrightarrow.



                          enter image description here



                          Here there is the MWE:



                          documentclass[12pt]{article}
                          usepackage{mathtools,tikz-cd}
                          begin{document}
                          [
                          theta_n>1, quad begin{tikzcd}[column sep=.4cm]
                          dfrac{1}{theta_n^2} arrow[r, "n"'] & 0
                          end{tikzcd}
                          ]
                          end{document}





                          share|improve this answer




























                            0












                            0








                            0







                            Another simple solution for your question using tikz-cd. You can observe from the picture that n is more near at the arrow of same dimension of the lenght of xrightarrow.



                            enter image description here



                            Here there is the MWE:



                            documentclass[12pt]{article}
                            usepackage{mathtools,tikz-cd}
                            begin{document}
                            [
                            theta_n>1, quad begin{tikzcd}[column sep=.4cm]
                            dfrac{1}{theta_n^2} arrow[r, "n"'] & 0
                            end{tikzcd}
                            ]
                            end{document}





                            share|improve this answer















                            Another simple solution for your question using tikz-cd. You can observe from the picture that n is more near at the arrow of same dimension of the lenght of xrightarrow.



                            enter image description here



                            Here there is the MWE:



                            documentclass[12pt]{article}
                            usepackage{mathtools,tikz-cd}
                            begin{document}
                            [
                            theta_n>1, quad begin{tikzcd}[column sep=.4cm]
                            dfrac{1}{theta_n^2} arrow[r, "n"'] & 0
                            end{tikzcd}
                            ]
                            end{document}






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 8 hours ago

























                            answered 9 hours ago









                            SebastianoSebastiano

                            9,88041858




                            9,88041858






















                                Jir is a new contributor. Be nice, and check out our Code of Conduct.










                                draft saved

                                draft discarded


















                                Jir is a new contributor. Be nice, and check out our Code of Conduct.













                                Jir is a new contributor. Be nice, and check out our Code of Conduct.












                                Jir is a new contributor. Be nice, and check out our Code of Conduct.
















                                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%2f474069%2fwhy-this-newcommand-doesnt-work-in-align-environment%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

                                "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                Alcedinidae

                                Origin of the phrase “under your belt”?