How to make the defined `oline` adjust with texts?












0















First a MWE is as follows:



documentclass{amsart}
usepackage{amsmath,amsfonts}
newcommand*oline[1]{%
kern.2em%add the left space
vbox{%
hrule height 0.3pt% % Line above with certain width
kern0.3ex% % Distance between line and content
hbox{%
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
ifmmode#1elseensuremath{#1}fi% % The content, typeset in dependence of mode
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
}% end of hbox
}% end of vbox
kern.2em} %add the right spacce

begin{document}
[2^{oline{S}abc}=oline{S}0.]

end{document}


In the example, I define a command oline to produce the above line as my desired. But it can't adjust with the texts as you see in the following figure: oline{S} is bigger than abc while in fact it should be the same size as abc.



enter image description here



Question: who can help me improve it to make it adjust with the texts?










share|improve this question

























  • What's wrong in overline{S}?

    – egreg
    Sep 24 '18 at 16:04











  • @egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

    – Kuttens
    Sep 25 '18 at 1:38


















0















First a MWE is as follows:



documentclass{amsart}
usepackage{amsmath,amsfonts}
newcommand*oline[1]{%
kern.2em%add the left space
vbox{%
hrule height 0.3pt% % Line above with certain width
kern0.3ex% % Distance between line and content
hbox{%
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
ifmmode#1elseensuremath{#1}fi% % The content, typeset in dependence of mode
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
}% end of hbox
}% end of vbox
kern.2em} %add the right spacce

begin{document}
[2^{oline{S}abc}=oline{S}0.]

end{document}


In the example, I define a command oline to produce the above line as my desired. But it can't adjust with the texts as you see in the following figure: oline{S} is bigger than abc while in fact it should be the same size as abc.



enter image description here



Question: who can help me improve it to make it adjust with the texts?










share|improve this question

























  • What's wrong in overline{S}?

    – egreg
    Sep 24 '18 at 16:04











  • @egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

    – Kuttens
    Sep 25 '18 at 1:38
















0












0








0


0






First a MWE is as follows:



documentclass{amsart}
usepackage{amsmath,amsfonts}
newcommand*oline[1]{%
kern.2em%add the left space
vbox{%
hrule height 0.3pt% % Line above with certain width
kern0.3ex% % Distance between line and content
hbox{%
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
ifmmode#1elseensuremath{#1}fi% % The content, typeset in dependence of mode
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
}% end of hbox
}% end of vbox
kern.2em} %add the right spacce

begin{document}
[2^{oline{S}abc}=oline{S}0.]

end{document}


In the example, I define a command oline to produce the above line as my desired. But it can't adjust with the texts as you see in the following figure: oline{S} is bigger than abc while in fact it should be the same size as abc.



enter image description here



Question: who can help me improve it to make it adjust with the texts?










share|improve this question
















First a MWE is as follows:



documentclass{amsart}
usepackage{amsmath,amsfonts}
newcommand*oline[1]{%
kern.2em%add the left space
vbox{%
hrule height 0.3pt% % Line above with certain width
kern0.3ex% % Distance between line and content
hbox{%
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
ifmmode#1elseensuremath{#1}fi% % The content, typeset in dependence of mode
kern -0.1em% % Distance between content and left side of box, negative values for lines shorter than content
}% end of hbox
}% end of vbox
kern.2em} %add the right spacce

begin{document}
[2^{oline{S}abc}=oline{S}0.]

end{document}


In the example, I define a command oline to produce the above line as my desired. But it can't adjust with the texts as you see in the following figure: oline{S} is bigger than abc while in fact it should be the same size as abc.



enter image description here



Question: who can help me improve it to make it adjust with the texts?







math-mode accents






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 mins ago









Henri Menke

75.3k8164276




75.3k8164276










asked Sep 24 '18 at 16:01









KuttensKuttens

909212




909212













  • What's wrong in overline{S}?

    – egreg
    Sep 24 '18 at 16:04











  • @egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

    – Kuttens
    Sep 25 '18 at 1:38





















  • What's wrong in overline{S}?

    – egreg
    Sep 24 '18 at 16:04











  • @egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

    – Kuttens
    Sep 25 '18 at 1:38



















What's wrong in overline{S}?

– egreg
Sep 24 '18 at 16:04





What's wrong in overline{S}?

– egreg
Sep 24 '18 at 16:04













@egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

– Kuttens
Sep 25 '18 at 1:38







@egreg the line produced by overline is too long and too thick, and also when to use overline iterably, for example overline{overline{A}}, the space between produced lines is too large.

– Kuttens
Sep 25 '18 at 1:38












1 Answer
1






active

oldest

votes


















1














There are a few improvements to apply.




  1. When you open an hbox, TeX is not in math mode any longer, so ifmmode will always return false.

  2. You need to take into account the current math style, which is done with mathpalette.

  3. The hardwired 0.3ex will yield too big a spacing in superscripts.


Here's a proposal, with a comparison with the standard bar command.



documentclass{amsart}
usepackage{amsmath,amsfonts}

makeatletter
newcommand*oline[1]{{mspace{2mu}mathpaletteo@line{#1}mspace{2mu}}}
newcommand*o@line[2]{%
vbox{
sboxz@{$m@th#1mspace{2mu}$}
hrule height 0.3pt
kernwdz@
hbox{$m@thmspace{-2mu}#1#2mspace{-2mu}$}
}%
}
makeatother

begin{document}

begin{gather*}
2^{oline{S}abc}=oline{S}0 \
2^{bar{S}abc}=bar{S}0
end{gather*}

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%2f452274%2fhow-to-make-the-defined-oline-adjust-with-texts%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









    1














    There are a few improvements to apply.




    1. When you open an hbox, TeX is not in math mode any longer, so ifmmode will always return false.

    2. You need to take into account the current math style, which is done with mathpalette.

    3. The hardwired 0.3ex will yield too big a spacing in superscripts.


    Here's a proposal, with a comparison with the standard bar command.



    documentclass{amsart}
    usepackage{amsmath,amsfonts}

    makeatletter
    newcommand*oline[1]{{mspace{2mu}mathpaletteo@line{#1}mspace{2mu}}}
    newcommand*o@line[2]{%
    vbox{
    sboxz@{$m@th#1mspace{2mu}$}
    hrule height 0.3pt
    kernwdz@
    hbox{$m@thmspace{-2mu}#1#2mspace{-2mu}$}
    }%
    }
    makeatother

    begin{document}

    begin{gather*}
    2^{oline{S}abc}=oline{S}0 \
    2^{bar{S}abc}=bar{S}0
    end{gather*}

    end{document}


    enter image description here






    share|improve this answer






























      1














      There are a few improvements to apply.




      1. When you open an hbox, TeX is not in math mode any longer, so ifmmode will always return false.

      2. You need to take into account the current math style, which is done with mathpalette.

      3. The hardwired 0.3ex will yield too big a spacing in superscripts.


      Here's a proposal, with a comparison with the standard bar command.



      documentclass{amsart}
      usepackage{amsmath,amsfonts}

      makeatletter
      newcommand*oline[1]{{mspace{2mu}mathpaletteo@line{#1}mspace{2mu}}}
      newcommand*o@line[2]{%
      vbox{
      sboxz@{$m@th#1mspace{2mu}$}
      hrule height 0.3pt
      kernwdz@
      hbox{$m@thmspace{-2mu}#1#2mspace{-2mu}$}
      }%
      }
      makeatother

      begin{document}

      begin{gather*}
      2^{oline{S}abc}=oline{S}0 \
      2^{bar{S}abc}=bar{S}0
      end{gather*}

      end{document}


      enter image description here






      share|improve this answer




























        1












        1








        1







        There are a few improvements to apply.




        1. When you open an hbox, TeX is not in math mode any longer, so ifmmode will always return false.

        2. You need to take into account the current math style, which is done with mathpalette.

        3. The hardwired 0.3ex will yield too big a spacing in superscripts.


        Here's a proposal, with a comparison with the standard bar command.



        documentclass{amsart}
        usepackage{amsmath,amsfonts}

        makeatletter
        newcommand*oline[1]{{mspace{2mu}mathpaletteo@line{#1}mspace{2mu}}}
        newcommand*o@line[2]{%
        vbox{
        sboxz@{$m@th#1mspace{2mu}$}
        hrule height 0.3pt
        kernwdz@
        hbox{$m@thmspace{-2mu}#1#2mspace{-2mu}$}
        }%
        }
        makeatother

        begin{document}

        begin{gather*}
        2^{oline{S}abc}=oline{S}0 \
        2^{bar{S}abc}=bar{S}0
        end{gather*}

        end{document}


        enter image description here






        share|improve this answer















        There are a few improvements to apply.




        1. When you open an hbox, TeX is not in math mode any longer, so ifmmode will always return false.

        2. You need to take into account the current math style, which is done with mathpalette.

        3. The hardwired 0.3ex will yield too big a spacing in superscripts.


        Here's a proposal, with a comparison with the standard bar command.



        documentclass{amsart}
        usepackage{amsmath,amsfonts}

        makeatletter
        newcommand*oline[1]{{mspace{2mu}mathpaletteo@line{#1}mspace{2mu}}}
        newcommand*o@line[2]{%
        vbox{
        sboxz@{$m@th#1mspace{2mu}$}
        hrule height 0.3pt
        kernwdz@
        hbox{$m@thmspace{-2mu}#1#2mspace{-2mu}$}
        }%
        }
        makeatother

        begin{document}

        begin{gather*}
        2^{oline{S}abc}=oline{S}0 \
        2^{bar{S}abc}=bar{S}0
        end{gather*}

        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 25 '18 at 4:45









        Kuttens

        909212




        909212










        answered Sep 24 '18 at 17:30









        egregegreg

        722k8719143214




        722k8719143214






























            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%2f452274%2fhow-to-make-the-defined-oline-adjust-with-texts%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

            サソリ

            広島県道265号伴広島線

            Setup Asymptote in Texstudio