3

I would like to typeset a fairly complicated fraction in display style surrounded by paragraph text. Here's an MWE.

\documentclass{memoir}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{amsmath}

\begin{document}
    The quick brown fox jummped over the lazy dog.

    \(m = \dfrac{\left(\dfrac{r}{1,200}\right)\left(1 + \dfrac{r}{1,200}\right)^N}{\left(1 + \dfrac{r}{1,200}\right)^N - 1}P\)

    The quick brown fox jumped over the lazy dog.

    This line has the correct leading.
\end{document}

mwe rendered

Notice that the leading immediately before and after the fraction is a bit tight, e.g. underneath the “p” of the first line. I can't change this line to an environment such as AMS's align, and I'm not willing to use tfracs. Is there a way to make LaTeX compensate for leading around a huge fration?

Simon Kuang
  • 1,861
  • 1
    This should definitely be an equation* environment, why not? – egreg Sep 09 '15 at 22:17
  • 1
    @egreg, it's not meant to be a "figure" type equation. It's meant to be used in the flow of text, for example 1/2 way through a paragraph (like that). It's fine if the leading gets ugly to accomodate the big equation—I don't want to smash or inline it. – Simon Kuang Sep 09 '15 at 22:19

2 Answers2

5

Change the \lineskip for the particular paragraph; use \Big and not automatic sizing, in order to reduce uglyness; shift a bit the exponent and leave some space before the P. Don't use thousands separator for four digit numbers. If you really want to do it, please use {,} in order to avoid an unwanted space (or use \num from siunitx, with appropriate settings).

\documentclass{memoir}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{amsmath}

\begin{document}

\lipsum[2]

\begingroup\setlength{\lineskip}{3pt}%
The quick brown fox jumped over the lazy dog, while the smart duck
flew away saying
\(m = \dfrac{\Bigl(\dfrac{r}{1200}\Bigr)\Bigl(1 + \dfrac{r}{1200}\Bigr)^{\!N}}
            {\Bigl(1 + \dfrac{r}{1200}\Bigr)^{\!N} - 1}\,P\).
Again the quick brown fox jumped over the lazy dog, while the smart duck
flew away. This line has the correct leading.\par\endgroup

\lipsum[3]

\end{document}

enter image description here

You're lucky that, when I was answering, the radio was broadcasting the ouverture from Wagner's Tannhäuser and nothing can be more awful than that, even this piece of bad typesetting.

egreg
  • 1,121,712
  • Can you explain what \lineskip does and how it's different from \baselineskip? – Simon Kuang Sep 09 '15 at 22:29
  • @SimonKuang \lineskip (default value 1pt) is used when \baselineskip would not have effect because depth+height is more than it. – egreg Sep 09 '15 at 22:30
  • 1
    @SimonKuang See http://tex.stackexchange.com/a/137249/4427 for more information. – egreg Sep 09 '15 at 22:38
0

One can just wrap the \dfrac in an \addstackgap[<length>]{}, which adds a blank buffer of height <length> above and below the item. Here, I make the buffer 5pt.

\documentclass{memoir}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{stackengine}
\stackMath
\begin{document}
    The quick brown fox jummped over the lazy dog.

    \(m = \addstackgap[5pt]{
  \dfrac{\left(\dfrac{r}{1,200}\right)\left(1 + \dfrac{r}{1,200}\right)^N}
  {\left(1 + \dfrac{r}{1,200}\right)^N - 1}
  }P\)

    The quick brown fox jumped over the lazy dog.

    This line has the correct leading.
\end{document}

enter image description here