4

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: enter image description here

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.
5

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}

enter image description here

  • 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. – user1362373 Jul 16 at 11:02
  • @user1362373 not only, $T_1$ is also higher! – yarchik Jul 16 at 18:54
4

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.

enter image description here

\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}
  • 1
    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. – user1362373 Jul 16 at 11:00
3

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} 

enter image description here

  • 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? – user1362373 Jul 16 at 11:03
  • 1
    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. – Bernard Jul 16 at 11:08
1

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

enter image description here

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$}}}
  • 1
    Accepting my own answer feels odd, but it comes closest to doing what I originally looked for... – user1362373 Jul 18 at 10:47
0

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

enter image description here

\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}
  • 1
    Thanks. This seems quite a complicated solution compared to what I'm looking for. – user1362373 Jul 18 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.