Missing space with DeclarePairedDelimiter











up vote
6
down vote

favorite












I’m trying to define an abs command for absolute values using DeclarePairedDelimiter from the mathtools package, but I’m running into some spacing issues.



I’d normall write sup_n abs{a_n} defined by DeclarePairedDelimiter{abs}{lvert}{rvert}.
But then there is some space missing.



Actual output.



I would instead expect the following output, which I get using sup_n |a_n|.



Expected output



With sup_n {abs{a_n}} this issue does not appear, but I find this additional pair of curly braces too cumbersome.
I also tried some variations, but both versions of abs seem to have the same issue.



documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}
DeclarePairedDelimiter{abs}{lvert}{rvert}
DeclarePairedDelimiter{altabs}{|}{|}

begin{document}
[
sup_n |a_n| quad % expected output
sup_n abs{a_n} quad
sup_n {abs{a_n}} quad % expected output
sup_n lvert a_n rvert quad
sup_n altabs{a_n} quad
sup_n {altabs{a_n}} % expected output
]
end{document}


Complete output



Where is this problem coming from, and how can I get DeclarePairedDelimiter to give the right spacing?










share|improve this question


















  • 3




    The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
    – egreg
    Nov 26 at 11:33








  • 1




    In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
    – daleif
    Nov 26 at 11:56










  • I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
    – Jendrik Stelzner
    Nov 26 at 12:19















up vote
6
down vote

favorite












I’m trying to define an abs command for absolute values using DeclarePairedDelimiter from the mathtools package, but I’m running into some spacing issues.



I’d normall write sup_n abs{a_n} defined by DeclarePairedDelimiter{abs}{lvert}{rvert}.
But then there is some space missing.



Actual output.



I would instead expect the following output, which I get using sup_n |a_n|.



Expected output



With sup_n {abs{a_n}} this issue does not appear, but I find this additional pair of curly braces too cumbersome.
I also tried some variations, but both versions of abs seem to have the same issue.



documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}
DeclarePairedDelimiter{abs}{lvert}{rvert}
DeclarePairedDelimiter{altabs}{|}{|}

begin{document}
[
sup_n |a_n| quad % expected output
sup_n abs{a_n} quad
sup_n {abs{a_n}} quad % expected output
sup_n lvert a_n rvert quad
sup_n altabs{a_n} quad
sup_n {altabs{a_n}} % expected output
]
end{document}


Complete output



Where is this problem coming from, and how can I get DeclarePairedDelimiter to give the right spacing?










share|improve this question


















  • 3




    The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
    – egreg
    Nov 26 at 11:33








  • 1




    In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
    – daleif
    Nov 26 at 11:56










  • I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
    – Jendrik Stelzner
    Nov 26 at 12:19













up vote
6
down vote

favorite









up vote
6
down vote

favorite











I’m trying to define an abs command for absolute values using DeclarePairedDelimiter from the mathtools package, but I’m running into some spacing issues.



I’d normall write sup_n abs{a_n} defined by DeclarePairedDelimiter{abs}{lvert}{rvert}.
But then there is some space missing.



Actual output.



I would instead expect the following output, which I get using sup_n |a_n|.



Expected output



With sup_n {abs{a_n}} this issue does not appear, but I find this additional pair of curly braces too cumbersome.
I also tried some variations, but both versions of abs seem to have the same issue.



documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}
DeclarePairedDelimiter{abs}{lvert}{rvert}
DeclarePairedDelimiter{altabs}{|}{|}

begin{document}
[
sup_n |a_n| quad % expected output
sup_n abs{a_n} quad
sup_n {abs{a_n}} quad % expected output
sup_n lvert a_n rvert quad
sup_n altabs{a_n} quad
sup_n {altabs{a_n}} % expected output
]
end{document}


Complete output



Where is this problem coming from, and how can I get DeclarePairedDelimiter to give the right spacing?










share|improve this question













I’m trying to define an abs command for absolute values using DeclarePairedDelimiter from the mathtools package, but I’m running into some spacing issues.



I’d normall write sup_n abs{a_n} defined by DeclarePairedDelimiter{abs}{lvert}{rvert}.
But then there is some space missing.



Actual output.



I would instead expect the following output, which I get using sup_n |a_n|.



Expected output



With sup_n {abs{a_n}} this issue does not appear, but I find this additional pair of curly braces too cumbersome.
I also tried some variations, but both versions of abs seem to have the same issue.



documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}
DeclarePairedDelimiter{abs}{lvert}{rvert}
DeclarePairedDelimiter{altabs}{|}{|}

begin{document}
[
sup_n |a_n| quad % expected output
sup_n abs{a_n} quad
sup_n {abs{a_n}} quad % expected output
sup_n lvert a_n rvert quad
sup_n altabs{a_n} quad
sup_n {altabs{a_n}} % expected output
]
end{document}


Complete output



Where is this problem coming from, and how can I get DeclarePairedDelimiter to give the right spacing?







spacing delimiters mathtools






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 at 11:28









Jendrik Stelzner

21327




21327








  • 3




    The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
    – egreg
    Nov 26 at 11:33








  • 1




    In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
    – daleif
    Nov 26 at 11:56










  • I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
    – Jendrik Stelzner
    Nov 26 at 12:19














  • 3




    The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
    – egreg
    Nov 26 at 11:33








  • 1




    In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
    – daleif
    Nov 26 at 11:56










  • I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
    – Jendrik Stelzner
    Nov 26 at 12:19








3




3




The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
– egreg
Nov 26 at 11:33






The fact is that the space should not be there: if you use the proper sup_nlvert a_nrvert, you see it. Just like sup(a_1,dots,a_n) should not have space.
– egreg
Nov 26 at 11:33






1




1




In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
– daleif
Nov 26 at 11:56




In addition to egregs comment, remember that |...| is not the correct syntax for absolute value. | is a normal symbol (an ord), whereas lvert and rvert are | with type math open and math close respectfully (just as ()). When sub sees an ord like a letter or | it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally DeclarePairedDelimiter will always make the fences into open and close types which is why your abs and altabs gives the same result.
– daleif
Nov 26 at 11:56












I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
– Jendrik Stelzner
Nov 26 at 12:19




I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”.
– Jendrik Stelzner
Nov 26 at 12:19










1 Answer
1






active

oldest

votes

















up vote
7
down vote













There should be no space between the operator name and a delimiter, so the output one gets from



sup_{n}lvert a_{n}rvert


is right (and is one of the reasons why amsmath introduced lvert and rvert to begin with).



On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy mathop{} before it.



documentclass[a4paper,10pt]{scrartcl}
usepackage{mathtools}

DeclarePairedDelimiter{absinner}{lvert}{rvert}
DeclarePairedDelimiter{altabsinner}{|}{|}

newcommand{abs}{mathop{}absinner}
newcommand{altabs}{mathop{}altabsinner}

begin{document}
[
sup_n |a_n| quad % expected output
sup_n abs{a_n} quad
sup_n {abs{a_n}} quad % expected output
sup_n altabs{a_n} quad
sup_n {altabs{a_n}} % expected output
]

begin{alignat*}{3}
a_n - abs{a_n} &quad& a_n-lvert a_nrvert &quad& a_n-|a_n|\
-abs{a_n} && -abs{a_n} && -|a_n|
end{alignat*}

end{document}


enter image description here



I'd not do it myself, though.






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',
    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%2f461806%2fmissing-space-with-declarepaireddelimiter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    7
    down vote













    There should be no space between the operator name and a delimiter, so the output one gets from



    sup_{n}lvert a_{n}rvert


    is right (and is one of the reasons why amsmath introduced lvert and rvert to begin with).



    On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy mathop{} before it.



    documentclass[a4paper,10pt]{scrartcl}
    usepackage{mathtools}

    DeclarePairedDelimiter{absinner}{lvert}{rvert}
    DeclarePairedDelimiter{altabsinner}{|}{|}

    newcommand{abs}{mathop{}absinner}
    newcommand{altabs}{mathop{}altabsinner}

    begin{document}
    [
    sup_n |a_n| quad % expected output
    sup_n abs{a_n} quad
    sup_n {abs{a_n}} quad % expected output
    sup_n altabs{a_n} quad
    sup_n {altabs{a_n}} % expected output
    ]

    begin{alignat*}{3}
    a_n - abs{a_n} &quad& a_n-lvert a_nrvert &quad& a_n-|a_n|\
    -abs{a_n} && -abs{a_n} && -|a_n|
    end{alignat*}

    end{document}


    enter image description here



    I'd not do it myself, though.






    share|improve this answer



























      up vote
      7
      down vote













      There should be no space between the operator name and a delimiter, so the output one gets from



      sup_{n}lvert a_{n}rvert


      is right (and is one of the reasons why amsmath introduced lvert and rvert to begin with).



      On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy mathop{} before it.



      documentclass[a4paper,10pt]{scrartcl}
      usepackage{mathtools}

      DeclarePairedDelimiter{absinner}{lvert}{rvert}
      DeclarePairedDelimiter{altabsinner}{|}{|}

      newcommand{abs}{mathop{}absinner}
      newcommand{altabs}{mathop{}altabsinner}

      begin{document}
      [
      sup_n |a_n| quad % expected output
      sup_n abs{a_n} quad
      sup_n {abs{a_n}} quad % expected output
      sup_n altabs{a_n} quad
      sup_n {altabs{a_n}} % expected output
      ]

      begin{alignat*}{3}
      a_n - abs{a_n} &quad& a_n-lvert a_nrvert &quad& a_n-|a_n|\
      -abs{a_n} && -abs{a_n} && -|a_n|
      end{alignat*}

      end{document}


      enter image description here



      I'd not do it myself, though.






      share|improve this answer

























        up vote
        7
        down vote










        up vote
        7
        down vote









        There should be no space between the operator name and a delimiter, so the output one gets from



        sup_{n}lvert a_{n}rvert


        is right (and is one of the reasons why amsmath introduced lvert and rvert to begin with).



        On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy mathop{} before it.



        documentclass[a4paper,10pt]{scrartcl}
        usepackage{mathtools}

        DeclarePairedDelimiter{absinner}{lvert}{rvert}
        DeclarePairedDelimiter{altabsinner}{|}{|}

        newcommand{abs}{mathop{}absinner}
        newcommand{altabs}{mathop{}altabsinner}

        begin{document}
        [
        sup_n |a_n| quad % expected output
        sup_n abs{a_n} quad
        sup_n {abs{a_n}} quad % expected output
        sup_n altabs{a_n} quad
        sup_n {altabs{a_n}} % expected output
        ]

        begin{alignat*}{3}
        a_n - abs{a_n} &quad& a_n-lvert a_nrvert &quad& a_n-|a_n|\
        -abs{a_n} && -abs{a_n} && -|a_n|
        end{alignat*}

        end{document}


        enter image description here



        I'd not do it myself, though.






        share|improve this answer














        There should be no space between the operator name and a delimiter, so the output one gets from



        sup_{n}lvert a_{n}rvert


        is right (and is one of the reasons why amsmath introduced lvert and rvert to begin with).



        On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy mathop{} before it.



        documentclass[a4paper,10pt]{scrartcl}
        usepackage{mathtools}

        DeclarePairedDelimiter{absinner}{lvert}{rvert}
        DeclarePairedDelimiter{altabsinner}{|}{|}

        newcommand{abs}{mathop{}absinner}
        newcommand{altabs}{mathop{}altabsinner}

        begin{document}
        [
        sup_n |a_n| quad % expected output
        sup_n abs{a_n} quad
        sup_n {abs{a_n}} quad % expected output
        sup_n altabs{a_n} quad
        sup_n {altabs{a_n}} % expected output
        ]

        begin{alignat*}{3}
        a_n - abs{a_n} &quad& a_n-lvert a_nrvert &quad& a_n-|a_n|\
        -abs{a_n} && -abs{a_n} && -|a_n|
        end{alignat*}

        end{document}


        enter image description here



        I'd not do it myself, though.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 at 14:10

























        answered Nov 26 at 14:04









        egreg

        701k8618673141




        701k8618673141






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f461806%2fmissing-space-with-declarepaireddelimiter%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

            AnyDesk - Fatal Program Failure

            How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

            QoS: MAC-Priority for clients behind a repeater