6

What to do if one want's to center an equation that's to wide for the margins and the equation isn't possible to split between rows like my example where there is a big fraction containing Mclaurinexpansions.

I'm searching for solutions that either just center the equation on the a4 paper or that can scale down the size of the equation so it fits.

Thanks in advance for shared knowledge!

There are some similar subjects already but I'm not satisfied with the answers there so I ask and add a picture.

Visualization of the centering problem

  • 4
    \usepackage{mathtools} then put a \mathclap around the complete equation, like so: \begin{equation}\mathclap{my really long formula}\end{equation}. – Skillmon Nov 28 '18 at 14:29
  • 1
    Can't you factor out the denominator, put a big parenthesis and split the numerator on multiple lines? Personally, I'd prefer to see this than an equation that goes over into the margin, or a reduced fontsize. – G. Gare Nov 28 '18 at 14:30
  • Just realizing that \mathclap might put the equation number over the equation. – Skillmon Nov 28 '18 at 14:31
  • 1
    off topic: don't forget to use \cdots after the minus sign. – Sigur Nov 28 '18 at 14:31
  • hm could test the \mathclap, worst case I will skipp the equation number and add it manually with hyper ref in the text above. – StiggyStardust Nov 28 '18 at 14:35

4 Answers4

6
\noindent
\makebox[\textwidth]{\parbox{1.3\textwidth}{%
  \begin{align}
  y &= f(x)\\
  khdakshdkashdkajhsdkjahsdkh &= ksdjhf lksjdh fkjsdh fökjH SDÖKJFH ÖDFH öDFH 
  KSHDFKS
  \end{align}
}}

enter image description here

However, it makes more sense to split the formular in pieces.

  • If this is being submitted for publication, please make sure that the width of the centered equation doesn't exceed the width of the paper the document will be printed on. Although you should get a warning from the publication office, these days you may not, and one or both ends of the equation could be cut off, or buried in the spine, and thus be lost. It's always safer to reduce the width to fit within the specified margins. – barbara beeton Dec 17 '20 at 02:48
2

I propose three other possible layouts, with mathtools and/or nccmath:

 \documentclass{article}
 \usepackage{mathtools, nccmath}
 \usepackage{lipsum}

\begin{document}
\lipsum[11]
\begin{fleqn}[-0.75em]
 \begin{equation}
 \begin{aligned}[b]
  &\hspace{0.67em} f(x) = \\
   & \frac{\Bigl(6x-x^2 + \cfrac{x^5}{20}-\dotsm\Bigr) +\Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr) + \Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr)-6x}%
 {\Bigl(x^3-\cfrac{2x^5}{3} + \cfrac{23x^7}{45}-\dotsm\Bigr)-x^3}
 \end{aligned}
 \end{equation}
 \end{fleqn}
\bigskip

      \begin{equation}
      f(x) = \mfrac{\Bigl(6x-x^2 + \cfrac{x^5}{20}-\dotsm\Bigr) +\Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr) + \Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr)-6x}%
      {\Bigl(x^3-\cfrac{2x^5}{3} + \cfrac{23x^7}{45}-\dotsm\Bigr)-x^3}
      \end{equation}
\bigskip

      \begin{equation}
      f(x) = \frac{\splitfrac{\Bigl(6x-x^2 + \cfrac{x^5}{20}-\dotsm\Bigr) +\Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr)} {+ \Bigl(x^3-\cfrac{x^6}{2} + \cfrac{x^9}{3}-\dotsm\Bigr)-6x}}%
      {\Bigl(x^3-\cfrac{2x^5}{3} + \cfrac{23x^7}{45}-\dotsm\Bigr)-x^3}
      \end{equation}

\end{document} 

enter image description here

Bernard
  • 271,350
2

Here is an another way to centre an equation that is too wide to fit within the text area. It is similar to the solution proposed by Skillmon in this comment, but it wraps your equation in a box whose width is exactly the maximal of the equation instead of one of width zero. This causes the equation number to be pushed to the next line, as desired.

\documentclass{article}

\usepackage{showframe} %% <- Makes the text margins visible
\usepackage{amsmath}

\begin{document}

\begin{equation}
    \makebox[\displaywidth]{$\displaystyle
      f(x) =
        \frac{
          \Bigl( 6x - x^2 + \dfrac{x^5}{20} - \dotsb \Bigr)
          + \Bigl( x^3 - \dfrac{x^6}{2} + \dfrac{x^9}{3} - \dotsb \Bigr)
          + \Bigl( x^3 - \dfrac{x^6}{2} + \dfrac{x^9}{3} - \dotsb \Bigr)
          - 6x
        }{
          \Bigl( x^3 - \dfrac{2x^5}{3} + \dfrac{23x^7}{45} - \dotsb \Bigr) - x^3
        }
    $}
\end{equation}

\end{document}

output

The code is probably mostly self-explanatory, but here is a short explanation anyway:

  • \makebox[<width>]{<content>} creates a box of width <width> that contains <content> (centred).
  • \displaywidth is the maximum width of the current display math environment.
  • $\displaystyle <equation>$ produces an equation set in display style (with large fractions, summation symbols etc.).

Alternative: reduce the amount of empty space in the equation

As an alternative to allowing your equations to stick out of the margins, I suggest reducing the amount of space between its constituents. This can be done as follows:

\documentclass{article}
\usepackage{showframe} %% <- Makes the text margins visible
\usepackage{amsmath}

\newcommand*\squeezespaces[1]{% %% <- #1 is a number between 0 and 1
  \thickmuskip=\scalemuskip{\thickmuskip}{#1}% %% <- around =, \rightarrow, etc.
  \medmuskip=\scalemuskip{\medmuskip}{#1}%     %% <- around +, \times, etc.
  \thinmuskip=\scalemuskip{\thinmuskip}{#1}%   %% <- around \sum, \sin, etc.
  \nulldelimiterspace=#1\nulldelimiterspace    %% <- around fractions
  \scriptspace=#1\scriptspace                  %% <- after sub-/superscripts
}
\newcommand*\scalemuskip[2]{% %% <- scales muskips, including stretch/shrink
  \muexpr #1*\numexpr\dimexpr#2pt\relax\relax/65536\relax
} %% <- based on  https://tex.stackexchange.com/a/198966/156366

\begin{document}

\begin{equation}
    \squeezespaces{.6}
    f(x) =
      \frac{
        \Bigl( 6x - x^2 + \dfrac{x^5}{20} - \dotsb \Bigr)
        + \Bigl( x^3 - \dfrac{x^6}{2} + \dfrac{x^9}{3} - \dotsb \Bigr)
        + \Bigl( x^3 - \dfrac{x^6}{2} + \dfrac{x^9}{3} - \dotsb \Bigr)
        - 6x
      }{
        \Bigl( x^3 - \dfrac{2x^5}{3} + \dfrac{23x^7}{45} - \dotsb \Bigr) - x^3
      }
\end{equation}

\end{document}

Squeezed to 60%

The three lengths \thickmuskip, \medmuskip and \thinmuskip determine the amount of space that is inserted between various types of math atoms (see this answer for a nice overview of when each is used). \nulldelimiterspace and \scriptspace are inserted around fractions and after sub-/superscripts respectively. I'm reducing each of them to 60% of their original values (within this equation only).

If you want the equation number to appear on the same line you can of course compress the equation even further. The following image was produced by replacing .6 by .45 in the previous document.

Squeezed to 45%

Circumscribe
  • 10,856
1

You can simply add \hss to both sides of the equation:

\hsize=7cm

\hbox to\hsize{|:left margin \hss text \hss right margin:|}

$$ \hss This is an equation which slightly exceeds margins \hss $$

wipet
  • 74,238