7

I have complicated math expression:

enter image description here

Vertical spacing between text and fraction line is too small.
I tried to define new \frac command (with amsmath package) with adjustable vertical spaces. As you can see, the result is not satisfying:

enter image description here

\documentclass[a4paper,fleqn,leqno]{article}
\usepackage{polyglossia}
\usepackage{color,pifont,fontspec}
\usepackage[top=2.54cm,bottom=2.54cm,left=2.54cm,right=2.54cm]{geometry}
\usepackage{tikz,tikz-3dplot,graphicx}
\usepackage{mathtools,breqn,amsmath}
\usepackage[fontsize=12]{scrextend}
\usepackage{array,multirow}
\usepackage{pgfplots}
\DeclareMathSizes{12}{14}{14}{10}
\newcommand{\myfrac}[3][0pt]{\genfrac{}{}{}{}{\raisebox{#1}{$#2$}}{\raisebox{-#1}{$#3$}}}
\begin{document}
\begin{dmath*}[breakdepth={0},style={\mathindent=0pt},spread={10pt}]
{n=\myfrac[3pt]{\myfrac[3pt]{0,0625N+0,0215}{2}-0,043}{\myfrac[3pt]{\myfrac[3pt]{\scriptstyle 0,0625N+0,0215}{\scriptstyle 2}-0,043}{\myfrac[3pt]{\scriptstyle N}{\scriptstyle 2}-1}+0,0215}}
\end{dmath*}
\end{document}

How can I enlarge verticall spacing in whole fraction?

  • 1
    mathtools loads amsmath (\RequirePackage), so it's useless to load it again. – barbara beeton Nov 19 '15 at 14:07
2

In such cases I'd add a \mathstrut which however is not sufficient if the fraction is part of a denominator. For this situation, \big| seems to do.

\documentclass{article}
\usepackage{amsmath,xparse}

\NewDocumentCommand{\qfrac}{smm}{%
  \dfrac{\IfBooleanT{#1}{\vphantom{\big|}}#2}{\mathstrut #3}%
}

\begin{document}

Without adjustment
\[
n=\frac
   {\qfrac{0{,}0625N+0{,}0215}{2}-0{,}043}
   {\qfrac
     {\qfrac{0{,}0625N+0{,}0215}{2}-0{,}043}
     {\qfrac{N}{2}-1+0{,}0215}
   }
\]

With adjustment
\[
n=\frac
   {\qfrac{0{,}0625N+0{,}0215}{2}-0{,}043}
   {\qfrac
     {\qfrac*{0{,}0625N+0{,}0215}{2}-0{,}043}
     {\qfrac*{N}{2}-1+0{,}0215}
   }
\]

\end{document}

The \qfrac* version is to be used when the fraction is in a denominator.

Note {,} so there's no space after the comma.

enter image description here

The picture seems to hint that the top minus sign next to 0,043 is not aligned with the fraction line, but it's just due to pixel rounding. Here's the detail at maximum magnification.

enter image description here

  • on my screen, the minuses aren't lined up even with the fraction bars. is this just a consequence of pixel roundoff, or is there a structural cause? – barbara beeton Nov 19 '15 at 14:04
  • Shouldn't the additive term 0.0215 be a part of the overall (first-level) denominator instead of the inner (second-level) denominator? – Mico Nov 19 '15 at 14:21
  • @barbarabeeton I added a detail at high magnification; it was pixel rounding when taking the snapshot. – egreg Nov 19 '15 at 14:22
  • @Mico The original input gave an error, so I tried to interpret it as best as I could. I don't think it has an impact on the method. – egreg Nov 19 '15 at 14:23
3

Vertical spacing adjustments are unnecessary if you use the \cfrac machinery ("continued fractions") to typeset the complicated nested fraction expression.

enter image description here

\documentclass[a4paper,fleqn,leqno]{article}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage[margin=2.54cm]{geometry}
\usepackage{amsmath}
\usepackage[fontsize=12]{scrextend}
\begin{document}
\[
n=\cfrac{\cfrac{0{,}0625N+0{,}0215}{2}-0{,}043}
        {\cfrac{\cfrac{0{,}0625N+0{,}0215}{2}-0{,}043}
               {\cfrac{N}{2}-1}
        +0{,}0215}
\]
\end{document}

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.