# Adjusting vertical spacing in fractions?

Consider the following MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
t = \frac{\dfrac{T_1}{T_2}}{1+\dfrac{Q_1}{Q_2}}
\end{equation*}
\end{document}


It produces:

For my taste, the vertical spacing above and below the fraction line is too small. I'm aware of the various questions that have been asked before (e.g., "vertical spacing in nested fraction"), but I do not find the solutions advocated there to be satisfactory.

What I would like to be able to do is to set either a global factor (for all fractions) or a local factor (for a specific fraction) that stretches the default spacing.

Any ideas on how I could achieve this?

Edits:

1. In the above MWE, the fraction is much simpler than the one I'm grappling with in my real document. So replacing the \frac's by / won't help.
2. As suggested by my question, what I would like to have is a command that allows me to influence the spacing without changing the typesetting of the equation itself.

You can use \cfrac, which is thought for continued fractions, which this is a case of:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
t =
\frac{\dfrac{T_1}{T_2}}{1+\dfrac{Q_1}{Q_2}}=
\cfrac{\cfrac{T_1}{T_2}}{1+\cfrac{Q_1}{Q_2}}
\end{equation*}

\end{document}


• Fair enough, but it only seems to influence the spacing between the fraction line and the bottom fraction. I would like to also be able to influence the spacing between the fraction line and the top fraction. Jul 16, 2019 at 11:02
• @user1362373 not only, $T_1$ is also higher! Jul 16, 2019 at 18:54

I would use inline-fraction notation rather than stack two \dfrac expressions. The presence of the / characters ensures almost automatically that the numerator and denominator terms are not placed too closely to the fraction bar.

\documentclass{article}
\usepackage{amsmath} % for "\dfrac" macro and "equation*" env.
\begin{document}
\begin{equation*}
t=\dfrac{T_1/T_2}{1+Q_1/Q_2}
\end{equation*}
\end{document}

• This is not an option because in my real example the fractions are a lot more complicated and typesetting them in this way would make them hard to read. Jul 16, 2019 at 11:00

Use\cfrac, combined with \bigstrut for the numerator:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bigstrut}

\begin{document}

\begin{equation*}
t = \frac{\cfrac{T_1}{T_2\bigstrut[b]}}{1+\cfrac{Q_1}{Q_2}}
\end{equation*}

\end{document}


• Thanks, this goes in the direction I want. How could I turn this into something that does not require me to insert extra commands into the fraction itself? Jul 16, 2019 at 11:03
• Probably, you would have to delve into the low level coding of \cfrac to see how to patch it. Not sure it's worth this effort, unless you really have many fractions that require it. Jul 16, 2019 at 11:08

After unsuccessfully playing around trying to find a fix, I searched tex.stackexchange.com once more and found too little space between the bar on the denominator and the horizontal line, where Werner proposed building on amsmath's \genfrac command thus:

\newcommand{\myfrac}[3][0pt]{\genfrac{}{}{}{}{\raisebox{#1}{$#2$}}{\raisebox{-#1}{$#3$}}}


This does nearly all of what I want. The updated MWE is:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\myfrac}[3][0pt]{\genfrac{}{}{}{}{\raisebox{#1}{$#2$}}{\raisebox{-#1}{$#3$}}}
\begin{document}
\begin{equation*}
t = \frac{\dfrac{T_1}{T_2}}{1+\dfrac{Q_1}{Q_2}}
\end{equation*}
\begin{equation*}
t = \myfrac[7pt]{\dfrac{T_1}{T_2}}{1+\dfrac{Q_1}{Q_2}}
\end{equation*}
\end{document}


and gives

Separating the amounts by which the boxes are raised and lowered is a trivial extension:

\usepackage{twoopt}
\newcommandtwoopt{\myfrac}[4][0pt][0pt]{\genfrac{}{}{}{}{\raisebox{#1}{$#3$}}{\raisebox{-#2}{$#4$}}}

• Accepting my own answer feels odd, but it comes closest to doing what I originally looked for... Jul 18, 2019 at 10:47

This is a little late, but I have been experiencing the same problem. Until now I have been passive about it, but after I made the effort to switch to MathTime Pro II, I decided it was time to try to find a solution. After reading these posts:

Increase the vertical space in a fraction

\frac with mathpazo: bar too close to denominator

too little space between the bar on the denominator and the horizontal line

I came to the conclusion that the amsmath command \genfrac would probably meet my requirements if I could find a way to redefine/fine-tune the division line. According to the User’s Guide for the amsmath Package (Version 2.0), the signature of \genfrac is as follows:

\genfrac{left-delim}{right-delim}{thickness}{mathstyle}{numerator}{denominator}


Hence, if one could patch the existing definition with a new API that splits the thickness parameter into three sub-arguments, namely:

• totalthickness (e.g. 1pt)
• visiblethickness (e.g. 0.6pt)
• position ("b", "t" or "c")

it would give me enough degrees of freedom without (I believe) endangering the typography of either TeX or mtpro2.

In words: I would like to be able to define a visible part of \genfrac's division line, that can be centered ("c") or moved up ("t") and down ("b") within the total height (thickness) of the line. Today, visiblethickness = totalthickness => only one degree of freedom.

Regarding the details, I am vague since I have no experience with programming in TeX at this level, so I leave the idea here for a while to see if someone who is more skilled than me picks it up before I make an attempt myself.

To increase the vertical spacing above and below the fraction line, we can use TikZ to customize as follows.

\documentclass{article}
\usepackage{tikz,amsmath}
\begin{document}
This is from OP. The vertical spacing above and below the fraction line is too small.
\begin{equation*}
t = \frac{\dfrac{T_1}{T_2}}{1+\dfrac{Q_1}{Q_2}}
\end{equation*}

To increase the vertical spacing above and below the fraction line, we can use TikZ to customize as follows.

\begin{center}
\begin{tikzpicture}
\def\d{1} % length of fraction line
\draw
(0,0)     node[left]{$t=$}--+(0:\d)++(0:\d/2)
+(90:.5)  node{$\dfrac{T_1}{T_2}$}
+(-90:.5) node{$1+\dfrac{Q_1}{Q_2}$};
\end{tikzpicture}
\end{center}
\end{document}

• Thanks. This seems quite a complicated solution compared to what I'm looking for. Jul 18, 2019 at 6:11