Fractions with characters that don't have descenders or ascenders












2















The default vertical spacing for fractions accommodates the possibility of a character with a descender or an ascender (or the possibility of subscripts/superscripts). This is, for the most part, the desirable functionality. For example, in the code below,



$$frac{g}{a}=frac{a}{c}=frac{a}{b}$$


nothing needs to be changed. However, there is occasion where an expression like the ones below



$$frac{a}{c}$$
$$frac{a}{b}$$
$$frac{b}{a}$$


occurs in isolation where a reduction in the vertical space on either side, or both, seems warranted to balance the fraction.




If I'm going on a final pass through a document, what would be the best approach to remove this vertical space that would be compatible with a change of font?











share|improve this question























  • Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

    – Skillmon
    8 hours ago






  • 1





    See Why is [ ... ] preferable to $$ ... $$?

    – Werner
    7 hours ago











  • @Werner I excluded amsmath on purpose.

    – Robert Wolfe
    7 hours ago
















2















The default vertical spacing for fractions accommodates the possibility of a character with a descender or an ascender (or the possibility of subscripts/superscripts). This is, for the most part, the desirable functionality. For example, in the code below,



$$frac{g}{a}=frac{a}{c}=frac{a}{b}$$


nothing needs to be changed. However, there is occasion where an expression like the ones below



$$frac{a}{c}$$
$$frac{a}{b}$$
$$frac{b}{a}$$


occurs in isolation where a reduction in the vertical space on either side, or both, seems warranted to balance the fraction.




If I'm going on a final pass through a document, what would be the best approach to remove this vertical space that would be compatible with a change of font?











share|improve this question























  • Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

    – Skillmon
    8 hours ago






  • 1





    See Why is [ ... ] preferable to $$ ... $$?

    – Werner
    7 hours ago











  • @Werner I excluded amsmath on purpose.

    – Robert Wolfe
    7 hours ago














2












2








2








The default vertical spacing for fractions accommodates the possibility of a character with a descender or an ascender (or the possibility of subscripts/superscripts). This is, for the most part, the desirable functionality. For example, in the code below,



$$frac{g}{a}=frac{a}{c}=frac{a}{b}$$


nothing needs to be changed. However, there is occasion where an expression like the ones below



$$frac{a}{c}$$
$$frac{a}{b}$$
$$frac{b}{a}$$


occurs in isolation where a reduction in the vertical space on either side, or both, seems warranted to balance the fraction.




If I'm going on a final pass through a document, what would be the best approach to remove this vertical space that would be compatible with a change of font?











share|improve this question














The default vertical spacing for fractions accommodates the possibility of a character with a descender or an ascender (or the possibility of subscripts/superscripts). This is, for the most part, the desirable functionality. For example, in the code below,



$$frac{g}{a}=frac{a}{c}=frac{a}{b}$$


nothing needs to be changed. However, there is occasion where an expression like the ones below



$$frac{a}{c}$$
$$frac{a}{b}$$
$$frac{b}{a}$$


occurs in isolation where a reduction in the vertical space on either side, or both, seems warranted to balance the fraction.




If I'm going on a final pass through a document, what would be the best approach to remove this vertical space that would be compatible with a change of font?








math-mode spacing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









Robert WolfeRobert Wolfe

13610




13610













  • Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

    – Skillmon
    8 hours ago






  • 1





    See Why is [ ... ] preferable to $$ ... $$?

    – Werner
    7 hours ago











  • @Werner I excluded amsmath on purpose.

    – Robert Wolfe
    7 hours ago



















  • Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

    – Skillmon
    8 hours ago






  • 1





    See Why is [ ... ] preferable to $$ ... $$?

    – Werner
    7 hours ago











  • @Werner I excluded amsmath on purpose.

    – Robert Wolfe
    7 hours ago

















Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

– Skillmon
8 hours ago





Apart from don't: you write your own macro that typesets numerator and denominator inside boxes and measures it, then draw your own version of a fraction that only uses those sizes and no strut or similar.

– Skillmon
8 hours ago




1




1





See Why is [ ... ] preferable to $$ ... $$?

– Werner
7 hours ago





See Why is [ ... ] preferable to $$ ... $$?

– Werner
7 hours ago













@Werner I excluded amsmath on purpose.

– Robert Wolfe
7 hours ago





@Werner I excluded amsmath on purpose.

– Robert Wolfe
7 hours ago










2 Answers
2






active

oldest

votes


















4














I'm not sure it's a good idea. Anyhow, here's an implementation that should only be used in displays (fractions in text style or lower are already adjusted).



documentclass{article}
usepackage{amsmath}

newcommand{afrac}[2]{%
dfrac{adjustbot{#1}}
{adjusttop{#2}}%
}

makeatletter
newcommand{adjustbot}[1]{%
begingroup
settodepthdimen@{$textstyle y$}%
raisebox{dimexprdepth-dimen@}{$m@thtextstyle#1$}%
endgroup
}
newcommand{adjusttop}[1]{%
begingroup
settoheightdimen@{$textstyle l$}%
raisebox{dimexprdimen@-height}{$m@thtextstyle#1$}%
endgroup
}
makeatother

begin{document}

[
frac{a}{b}afrac{a}{b}quad
frac{a}{c}afrac{a}{c}quad
frac{b}{a}afrac{b}{a}quad
frac{g}{a}afrac{g}{a}
]
end{document}


enter image description here






share|improve this answer































    1














    documentclass{article}
    newcommand{myfrac}[2]
    {frac{raisebox{-.4ex}{$#1$}}{raisebox{.4ex}{$#2$}}}
    begin{document}
    $$frac{p}{d}=myfrac{a}{c}$$
    $$frac{p}{d}=myfrac{a}{b}$$
    $$frac{p}{d}=myfrac{b}{a}$$
    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%2f471195%2ffractions-with-characters-that-dont-have-descenders-or-ascenders%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














      I'm not sure it's a good idea. Anyhow, here's an implementation that should only be used in displays (fractions in text style or lower are already adjusted).



      documentclass{article}
      usepackage{amsmath}

      newcommand{afrac}[2]{%
      dfrac{adjustbot{#1}}
      {adjusttop{#2}}%
      }

      makeatletter
      newcommand{adjustbot}[1]{%
      begingroup
      settodepthdimen@{$textstyle y$}%
      raisebox{dimexprdepth-dimen@}{$m@thtextstyle#1$}%
      endgroup
      }
      newcommand{adjusttop}[1]{%
      begingroup
      settoheightdimen@{$textstyle l$}%
      raisebox{dimexprdimen@-height}{$m@thtextstyle#1$}%
      endgroup
      }
      makeatother

      begin{document}

      [
      frac{a}{b}afrac{a}{b}quad
      frac{a}{c}afrac{a}{c}quad
      frac{b}{a}afrac{b}{a}quad
      frac{g}{a}afrac{g}{a}
      ]
      end{document}


      enter image description here






      share|improve this answer




























        4














        I'm not sure it's a good idea. Anyhow, here's an implementation that should only be used in displays (fractions in text style or lower are already adjusted).



        documentclass{article}
        usepackage{amsmath}

        newcommand{afrac}[2]{%
        dfrac{adjustbot{#1}}
        {adjusttop{#2}}%
        }

        makeatletter
        newcommand{adjustbot}[1]{%
        begingroup
        settodepthdimen@{$textstyle y$}%
        raisebox{dimexprdepth-dimen@}{$m@thtextstyle#1$}%
        endgroup
        }
        newcommand{adjusttop}[1]{%
        begingroup
        settoheightdimen@{$textstyle l$}%
        raisebox{dimexprdimen@-height}{$m@thtextstyle#1$}%
        endgroup
        }
        makeatother

        begin{document}

        [
        frac{a}{b}afrac{a}{b}quad
        frac{a}{c}afrac{a}{c}quad
        frac{b}{a}afrac{b}{a}quad
        frac{g}{a}afrac{g}{a}
        ]
        end{document}


        enter image description here






        share|improve this answer


























          4












          4








          4







          I'm not sure it's a good idea. Anyhow, here's an implementation that should only be used in displays (fractions in text style or lower are already adjusted).



          documentclass{article}
          usepackage{amsmath}

          newcommand{afrac}[2]{%
          dfrac{adjustbot{#1}}
          {adjusttop{#2}}%
          }

          makeatletter
          newcommand{adjustbot}[1]{%
          begingroup
          settodepthdimen@{$textstyle y$}%
          raisebox{dimexprdepth-dimen@}{$m@thtextstyle#1$}%
          endgroup
          }
          newcommand{adjusttop}[1]{%
          begingroup
          settoheightdimen@{$textstyle l$}%
          raisebox{dimexprdimen@-height}{$m@thtextstyle#1$}%
          endgroup
          }
          makeatother

          begin{document}

          [
          frac{a}{b}afrac{a}{b}quad
          frac{a}{c}afrac{a}{c}quad
          frac{b}{a}afrac{b}{a}quad
          frac{g}{a}afrac{g}{a}
          ]
          end{document}


          enter image description here






          share|improve this answer













          I'm not sure it's a good idea. Anyhow, here's an implementation that should only be used in displays (fractions in text style or lower are already adjusted).



          documentclass{article}
          usepackage{amsmath}

          newcommand{afrac}[2]{%
          dfrac{adjustbot{#1}}
          {adjusttop{#2}}%
          }

          makeatletter
          newcommand{adjustbot}[1]{%
          begingroup
          settodepthdimen@{$textstyle y$}%
          raisebox{dimexprdepth-dimen@}{$m@thtextstyle#1$}%
          endgroup
          }
          newcommand{adjusttop}[1]{%
          begingroup
          settoheightdimen@{$textstyle l$}%
          raisebox{dimexprdimen@-height}{$m@thtextstyle#1$}%
          endgroup
          }
          makeatother

          begin{document}

          [
          frac{a}{b}afrac{a}{b}quad
          frac{a}{c}afrac{a}{c}quad
          frac{b}{a}afrac{b}{a}quad
          frac{g}{a}afrac{g}{a}
          ]
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          egregegreg

          714k8618963184




          714k8618963184























              1














              documentclass{article}
              newcommand{myfrac}[2]
              {frac{raisebox{-.4ex}{$#1$}}{raisebox{.4ex}{$#2$}}}
              begin{document}
              $$frac{p}{d}=myfrac{a}{c}$$
              $$frac{p}{d}=myfrac{a}{b}$$
              $$frac{p}{d}=myfrac{b}{a}$$
              end{document}


              enter image description here






              share|improve this answer




























                1














                documentclass{article}
                newcommand{myfrac}[2]
                {frac{raisebox{-.4ex}{$#1$}}{raisebox{.4ex}{$#2$}}}
                begin{document}
                $$frac{p}{d}=myfrac{a}{c}$$
                $$frac{p}{d}=myfrac{a}{b}$$
                $$frac{p}{d}=myfrac{b}{a}$$
                end{document}


                enter image description here






                share|improve this answer


























                  1












                  1








                  1







                  documentclass{article}
                  newcommand{myfrac}[2]
                  {frac{raisebox{-.4ex}{$#1$}}{raisebox{.4ex}{$#2$}}}
                  begin{document}
                  $$frac{p}{d}=myfrac{a}{c}$$
                  $$frac{p}{d}=myfrac{a}{b}$$
                  $$frac{p}{d}=myfrac{b}{a}$$
                  end{document}


                  enter image description here






                  share|improve this answer













                  documentclass{article}
                  newcommand{myfrac}[2]
                  {frac{raisebox{-.4ex}{$#1$}}{raisebox{.4ex}{$#2$}}}
                  begin{document}
                  $$frac{p}{d}=myfrac{a}{c}$$
                  $$frac{p}{d}=myfrac{a}{b}$$
                  $$frac{p}{d}=myfrac{b}{a}$$
                  end{document}


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 8 hours ago









                  jfbujfbu

                  46.9k66149




                  46.9k66149






























                      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%2f471195%2ffractions-with-characters-that-dont-have-descenders-or-ascenders%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

                      GameSpot

                      connect to host localhost port 22: Connection refused

                      Getting a Wifi WPA2 wifi connection