11

I used the code below, but the equation does not fit the page as it is too long. I tried to reduce the font size but I could not. What could be done to fit the equation to the line?

I am also wondering why the equation does not start from the beginning of line. As you can see from the pic below, there is huge space in the left side of the equation

\documentclass{report}
\usepackage{amsmath}

\begin{document}

\begin{align}
 {{f}_{r:n}}(x)=\frac{n!}{(r-1)!(n-r+1)!}\,\left[ {{\left( \frac{x-1}{k}\right)}^{r-1}}\ {{\left( \frac{k-x+1}{k} \right)}^{n-r+1}}-{{\left( \frac{x}{k} \right)}^{r-1}}\ {{\left( \frac{k-x}{k} \right)}^{n-r+1}} \right]+{{f}_{r-1:n}}(x)                    
\end{align}

\end{document}

Here is the output

enter image description here

  • 5
    Fontsize reduction is never an answer. In this case (1) replace the left/right constructions with manual scaling (one of the four big commands), then (2) break the formula at the minus. If only one eqn number is wanted do: (1) replace align with aligned (this removes the number), (2) wrap it all in equation, this reintroduces the eqn number. (3) mark break points at = (via = {} & ) and at the minus (&-) and break the line before the minus – daleif Jul 31 '16 at 19:47
21

I suggest you embed a split environment (provided by the amsmath package) inside an equation environment.

Aside: Don't overuse { and } in math mode, and don't overuse auto-sizing of round parentheses and square brackets. Do take the time to look at the equation and fine-tune some of the horizontal spacing; in the code below, you'll find two instances of \, (positive thinspace) and four instances of \! (negative thinspace).

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "split" environment
\begin{document}

\begin{equation}\begin{split}
f_{r:n}(x)&=\frac{n!}{(r-1)!\,(n-r+1)!}
   \Biggl[ \biggl( \frac{x-1}{k}  \biggr)^{\!r-1} 
           \biggl( \frac{k-x+1}{k}\biggr)^{\!n-r+1} \\
  &\qquad -\biggl( \frac{x}{k}    \biggr)^{\!r-1} 
           \biggl( \frac{k-x}{k}  \biggr)^{\!n-r+1} \,
   \Biggr]+ f_{r-1:n}(x)                    
\end{split}\end{equation}

\end{document} 
  • You could even improve your answer by using \binom{n}{r-1} for the first term. (Unfortunately I cannot upvote twice though). – Henri Menke Aug 1 '16 at 9:46
  • @HenriMenke - Thanks! I did consider writing \binom{n}{r-1} instead of \frac{n!}{(r-1)!\,(n-r+1)!}, but didn't pursue it as I don't have information on the author's intentions for how he/she will discuss or highlight various parts of the formula. – Mico Aug 1 '16 at 20:11
12

Or use multline:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{multline}
  f_{r:n}(x)=\frac{n!}{(r-1)!\,(n-r+1)!}
    \Biggl[ \biggl( \frac{x-1}{k}   \biggr)^{\!r-1}
            \biggl( \frac{k-x+1}{k} \biggr)^{\!n-r+1} \\
          - \biggl( \frac{x}{k}     \biggr)^{\!r-1}
            \biggl( \frac{k-x}{k}   \biggr)^{\!n-r+1} \,
    \Biggr] + f_{r-1:n}(x)
\end{multline}

\end{document}

enter image description here

  • Thanks @Henri Menke; I like your use of a transparent background. – JPi Aug 1 '16 at 11:36
7

Answer reversed to show the 'logical' solution first, and the 'literal' answer second

If you have an equation which takes the length of a page, making it smaller / narrower / splitting onto several lines etc, is unlikely to aid the reader that much, as it is likely to be very dense and hard to read in the first place. If you have an equation like that, it probably means you're doing something wrong, and it would be worth considering if your equation can be restated in a more digestible way, as logical steps.

I think your equation could easily be restated, e.g. as:

enter image description here

      enter image description here

f_{r:n}(x) = \binom {n} {r \! - \! 1} 
             \biggl [ \Phi(x \! - \! 1) - \Phi(x) \biggr ] 
             + f_{r-1:n}(x)

\Phi(x) = \biggl ( \frac {x}   {k} \biggr ) ^ {r-1} 
          \biggl ( \frac {k-x} {k} \biggr ) ^ {n - r + 1}

which both saves you space and makes it clearer what's going on.

However, to answer your question literally, if you really don't want to split in this way, and you're just asking if it is at all possible with some sort of 'hack' to fit it all into one page / line, then you can save some space by making use of the 'choose r from n' notation, maybe substitute r-1 and x-1 with something else, and generally play with mkern to remove unnecessary extra space you don't want, particularly space resulting from the superscripts, e.g.:

f_{r:n}(x) = {n \choose r'}!! \left [! \left ( \frac {x'}{k} \right )^{!!r'}!!!! \left ( \frac{k - x'}{k}  \right )^{!!n-r'}!!!!!!!!! - \left ( \frac{x}{k} \right )^{!!r'}!!!! \left ( \frac{k-x}{k} \right )^{!!n-r'}!  \right ]!! +! f_{r':n}(x)

\text{where:}~~r' = r - 1, ~~~x' = x - 1

f_{r:n}(x) = \binom{n}{r'} 
  \mkern -4mu  \left [
  \mkern -4mu    \left ( \frac {x'}     {k} \right ) ^ { \!\! r'   }
  \mkern -12mu   \left ( \frac {k - x'} {k} \right ) ^ { \!\! n-r' }
  \mkern -24mu - \left ( \frac {x}      {k} \right ) ^ { \!\! r'   }
  \mkern -12mu   \left ( \frac {k-x}    {k} \right ) ^ { \!\! n-r' }
  \right ] \! + \! f_{r':n}(x)

\text{where:}~~r' = r - 1, ~~~x' = x - 1

However, as you might gather from the controversy this latter approach has managed to gather in the comments below, this just packs everything on one line, is probably not the best idea anyway, and some people feel quite strongly about it.

  • This “answer” is completely useless. The abundance of \! make the source hardly legible. Also {n \choose r'} is deprecated. Use \binom{n}{r'} from amsmath instead. – Henri Menke Aug 1 '16 at 9:44
  • I can replace \binom. Would you also prefer more leggible \kern instructions in place of \! or was the intent just to be rude and I shouldn't bother? This approach is reasonable, and makes it easier for the reader, so I disagree it's "useless". Legible code is secondary when the actual text produced is illegible. – Tasos Papastylianou Aug 1 '16 at 9:48
  • 1
    I would use \mkern instead of \kern while in math mode. And there should be a positive thinspace, not a negative thinspace, before \right]. – Mico Aug 1 '16 at 10:13
  • 1
    You may be overusing \!. For the sake of legibility, I believe it's better to break the long equation across two lines. With your setup, one has to look up what r' and x' mean, which interrupts the reader's attention. – Mico Aug 1 '16 at 10:21
  • 1
    the ^{\!...} is often useful after a \right) or \Bigr), as the superscript can seem a long way from what it applies to without that. Some of the other adjustments look too forced to me, hitting the readability. – Chris H Aug 1 '16 at 13:53

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.