How to align equation numbers inside and outside of mdframed?











up vote
2
down vote

favorite












I am using mdframed to box equations to include the equation number, as I quite like how it looks. However I've noticed that this results in a misalignment between equation numbers that are boxed, and those that are not. Is there an easy fix for this, or is it recommended to use a different method to mdframed?



Below is an example of how I'm using it.



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

begin{document}

Here is an important equation I would like to highlight:
begin{mdframed}
begin{equation}
e^{ipi}=-1
end{equation}
end{mdframed}

Here is an equation not important enough to deserve a highlight:
begin{equation}
y=mx+c
end{equation}

end{document}


enter image description here



Any advice is appreciated.










share|improve this question


















  • 2




    Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
    – marmot
    Oct 3 at 18:50










  • I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
    – Garf
    Oct 3 at 20:02

















up vote
2
down vote

favorite












I am using mdframed to box equations to include the equation number, as I quite like how it looks. However I've noticed that this results in a misalignment between equation numbers that are boxed, and those that are not. Is there an easy fix for this, or is it recommended to use a different method to mdframed?



Below is an example of how I'm using it.



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

begin{document}

Here is an important equation I would like to highlight:
begin{mdframed}
begin{equation}
e^{ipi}=-1
end{equation}
end{mdframed}

Here is an equation not important enough to deserve a highlight:
begin{equation}
y=mx+c
end{equation}

end{document}


enter image description here



Any advice is appreciated.










share|improve this question


















  • 2




    Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
    – marmot
    Oct 3 at 18:50










  • I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
    – Garf
    Oct 3 at 20:02















up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am using mdframed to box equations to include the equation number, as I quite like how it looks. However I've noticed that this results in a misalignment between equation numbers that are boxed, and those that are not. Is there an easy fix for this, or is it recommended to use a different method to mdframed?



Below is an example of how I'm using it.



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

begin{document}

Here is an important equation I would like to highlight:
begin{mdframed}
begin{equation}
e^{ipi}=-1
end{equation}
end{mdframed}

Here is an equation not important enough to deserve a highlight:
begin{equation}
y=mx+c
end{equation}

end{document}


enter image description here



Any advice is appreciated.










share|improve this question













I am using mdframed to box equations to include the equation number, as I quite like how it looks. However I've noticed that this results in a misalignment between equation numbers that are boxed, and those that are not. Is there an easy fix for this, or is it recommended to use a different method to mdframed?



Below is an example of how I'm using it.



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

begin{document}

Here is an important equation I would like to highlight:
begin{mdframed}
begin{equation}
e^{ipi}=-1
end{equation}
end{mdframed}

Here is an equation not important enough to deserve a highlight:
begin{equation}
y=mx+c
end{equation}

end{document}


enter image description here



Any advice is appreciated.







equations numbering mdframed emphasis alignment






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 3 at 16:25









Garf

3227




3227








  • 2




    Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
    – marmot
    Oct 3 at 18:50










  • I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
    – Garf
    Oct 3 at 20:02
















  • 2




    Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
    – marmot
    Oct 3 at 18:50










  • I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
    – Garf
    Oct 3 at 20:02










2




2




Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
– marmot
Oct 3 at 18:50




Unless you make the box run into the right margin, aligning the equation numbers with those outside won't look good, I think. So I am wondering what you want to achieve. Do you want to shift ordinary equation numbers to the left, or run the frame through the numbers, or let the frame intrude the right margin?
– marmot
Oct 3 at 18:50












I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
– Garf
Oct 3 at 20:02






I reckon the best would probably be to shift the unframed numbers left a little - I imagine there's a simple command for that I could probably look up
– Garf
Oct 3 at 20:02












1 Answer
1






active

oldest

votes

















up vote
2
down vote













It is easiest to let the frame extend in to the right margin:



Sample output



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

newlength{mywidth}
setlength{mywidth}{dimexprlinewidth+mdflength{innerrightmargin}+mdflength{linewidth}}

begin{document}


Here is an important equation I would like to highlight:
begin{mdframed}[userdefinedwidth=mywidth]
begin{equation}
e^{ipi}=-1
end{equation}
end{mdframed}

Here is an equation not important enough to deserve a highlight:
begin{equation}
y=mx+c
end{equation}

end{document}


To go the other way, you could perhaps include all displays in an mdframed, but just hide the lines:



Second sample



documentclass{article}

usepackage{amsmath}
usepackage{mdframed}

newbool{equationframe}
surroundwithmdframed[hidealllines=ifbool{equationframe}{false}{true}]{equation}
boolfalse{equationframe}

begin{document}

Here is an important equation I would like to highlight but first
enough text to show the width of the line:
{booltrue{equationframe}%
begin{equation}
e^{ipi}=-1
end{equation}}

Here is an equation not important enough to deserve a highlight but
first enough text to show the width of the line:
begin{equation}
y=mx+c
end{equation}

end{document}


Here I have added an extra flag dedicated to frames for equations, to avoid setting hidealllines globally and thus affecting other mdframed environments.






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%2f453656%2fhow-to-align-equation-numbers-inside-and-outside-of-mdframed%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
    2
    down vote













    It is easiest to let the frame extend in to the right margin:



    Sample output



    documentclass{article}

    usepackage{amsmath}
    usepackage{mdframed}

    newlength{mywidth}
    setlength{mywidth}{dimexprlinewidth+mdflength{innerrightmargin}+mdflength{linewidth}}

    begin{document}


    Here is an important equation I would like to highlight:
    begin{mdframed}[userdefinedwidth=mywidth]
    begin{equation}
    e^{ipi}=-1
    end{equation}
    end{mdframed}

    Here is an equation not important enough to deserve a highlight:
    begin{equation}
    y=mx+c
    end{equation}

    end{document}


    To go the other way, you could perhaps include all displays in an mdframed, but just hide the lines:



    Second sample



    documentclass{article}

    usepackage{amsmath}
    usepackage{mdframed}

    newbool{equationframe}
    surroundwithmdframed[hidealllines=ifbool{equationframe}{false}{true}]{equation}
    boolfalse{equationframe}

    begin{document}

    Here is an important equation I would like to highlight but first
    enough text to show the width of the line:
    {booltrue{equationframe}%
    begin{equation}
    e^{ipi}=-1
    end{equation}}

    Here is an equation not important enough to deserve a highlight but
    first enough text to show the width of the line:
    begin{equation}
    y=mx+c
    end{equation}

    end{document}


    Here I have added an extra flag dedicated to frames for equations, to avoid setting hidealllines globally and thus affecting other mdframed environments.






    share|improve this answer



























      up vote
      2
      down vote













      It is easiest to let the frame extend in to the right margin:



      Sample output



      documentclass{article}

      usepackage{amsmath}
      usepackage{mdframed}

      newlength{mywidth}
      setlength{mywidth}{dimexprlinewidth+mdflength{innerrightmargin}+mdflength{linewidth}}

      begin{document}


      Here is an important equation I would like to highlight:
      begin{mdframed}[userdefinedwidth=mywidth]
      begin{equation}
      e^{ipi}=-1
      end{equation}
      end{mdframed}

      Here is an equation not important enough to deserve a highlight:
      begin{equation}
      y=mx+c
      end{equation}

      end{document}


      To go the other way, you could perhaps include all displays in an mdframed, but just hide the lines:



      Second sample



      documentclass{article}

      usepackage{amsmath}
      usepackage{mdframed}

      newbool{equationframe}
      surroundwithmdframed[hidealllines=ifbool{equationframe}{false}{true}]{equation}
      boolfalse{equationframe}

      begin{document}

      Here is an important equation I would like to highlight but first
      enough text to show the width of the line:
      {booltrue{equationframe}%
      begin{equation}
      e^{ipi}=-1
      end{equation}}

      Here is an equation not important enough to deserve a highlight but
      first enough text to show the width of the line:
      begin{equation}
      y=mx+c
      end{equation}

      end{document}


      Here I have added an extra flag dedicated to frames for equations, to avoid setting hidealllines globally and thus affecting other mdframed environments.






      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        It is easiest to let the frame extend in to the right margin:



        Sample output



        documentclass{article}

        usepackage{amsmath}
        usepackage{mdframed}

        newlength{mywidth}
        setlength{mywidth}{dimexprlinewidth+mdflength{innerrightmargin}+mdflength{linewidth}}

        begin{document}


        Here is an important equation I would like to highlight:
        begin{mdframed}[userdefinedwidth=mywidth]
        begin{equation}
        e^{ipi}=-1
        end{equation}
        end{mdframed}

        Here is an equation not important enough to deserve a highlight:
        begin{equation}
        y=mx+c
        end{equation}

        end{document}


        To go the other way, you could perhaps include all displays in an mdframed, but just hide the lines:



        Second sample



        documentclass{article}

        usepackage{amsmath}
        usepackage{mdframed}

        newbool{equationframe}
        surroundwithmdframed[hidealllines=ifbool{equationframe}{false}{true}]{equation}
        boolfalse{equationframe}

        begin{document}

        Here is an important equation I would like to highlight but first
        enough text to show the width of the line:
        {booltrue{equationframe}%
        begin{equation}
        e^{ipi}=-1
        end{equation}}

        Here is an equation not important enough to deserve a highlight but
        first enough text to show the width of the line:
        begin{equation}
        y=mx+c
        end{equation}

        end{document}


        Here I have added an extra flag dedicated to frames for equations, to avoid setting hidealllines globally and thus affecting other mdframed environments.






        share|improve this answer














        It is easiest to let the frame extend in to the right margin:



        Sample output



        documentclass{article}

        usepackage{amsmath}
        usepackage{mdframed}

        newlength{mywidth}
        setlength{mywidth}{dimexprlinewidth+mdflength{innerrightmargin}+mdflength{linewidth}}

        begin{document}


        Here is an important equation I would like to highlight:
        begin{mdframed}[userdefinedwidth=mywidth]
        begin{equation}
        e^{ipi}=-1
        end{equation}
        end{mdframed}

        Here is an equation not important enough to deserve a highlight:
        begin{equation}
        y=mx+c
        end{equation}

        end{document}


        To go the other way, you could perhaps include all displays in an mdframed, but just hide the lines:



        Second sample



        documentclass{article}

        usepackage{amsmath}
        usepackage{mdframed}

        newbool{equationframe}
        surroundwithmdframed[hidealllines=ifbool{equationframe}{false}{true}]{equation}
        boolfalse{equationframe}

        begin{document}

        Here is an important equation I would like to highlight but first
        enough text to show the width of the line:
        {booltrue{equationframe}%
        begin{equation}
        e^{ipi}=-1
        end{equation}}

        Here is an equation not important enough to deserve a highlight but
        first enough text to show the width of the line:
        begin{equation}
        y=mx+c
        end{equation}

        end{document}


        Here I have added an extra flag dedicated to frames for equations, to avoid setting hidealllines globally and thus affecting other mdframed environments.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited yesterday

























        answered 2 days ago









        Andrew Swann

        75.8k9125321




        75.8k9125321






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453656%2fhow-to-align-equation-numbers-inside-and-outside-of-mdframed%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