# Breaking the equation inside a fraction

I am trying to write this equation using the help provided in the link below

How to break a long expression in the denominator of a fraction?

Still the equation goes outside the margin. I using \documentclass[a4paper,10pt]{article}.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
%opening
\title{}
\author{}

\begin{document}
\maketitle

\begin{abstract}
\end{abstract}

\section{}

\begin{equation*}
-\dfrac{1}{128\pi^{2}}\left[\dfrac{\splitdfrac{4(m_1 + m_3)\cos~\delta~\sin\theta_{12}~\sin\theta_{13}(\cos~\delta~\cos~\theta_{12}(2~y_e^{2}
- y_\mu^{2} - y_\tau^{2} +(y_\mu^{2} - y_\tau^{2})\cos~2\theta_{23})\sin~\theta_{13}}{+ (-y_\mu^{2} + y_\tau^{2})\sin~
\theta_{12}~\sin~2\theta_{23}}}{m_1 - m_3}\right] +
\end{equation*}
\end{document}

-
You can mark code sections by highlighting and using the {} button but please make it a complete document (not least so we see same margins that you see) –  David Carlisle May 28 at 19:07
Never write multiple letter identifiers such as sin and cos using the math italic font, use \sin and \cos or define similar commands if you really need the mixed case versions. –  David Carlisle May 28 at 19:09
That's rather a nasty-looking equation! I wonder if you'd be better off making some intermediate definitions, and then composing them to build the main equation. –  John Wickerson May 28 at 19:28
@JohnWickerson The above equation is just a part of a more nasty equation!!! –  Tanvir May 28 at 19:34

\documentclass[a4paper]{article}
\usepackage{mathtools}

\begin{document}
$$\dfrac{1}{128\pi^{2}} \left[\dfrac{\splitdfrac{ 4(m_1 + m_3)\cos \delta \sin\theta_{12} \sin\theta_{13}( \cos \delta \cos \theta_{12}(2 y_e^{2} - y_\mu^{2} - y_\tau^{2}}{ +(y_\mu^{2} -y_\tau^{2})\cos 2\theta_{23})\sin \theta_{13} + (-y_\mu^{2} + y_\tau^{2})\sin \theta_{12} \sin 2\theta_{23})}} {m_1 - m_3}\right]$$

\end{document}

-
how about putting {} before the plus that starts the second line? –  barbara beeton May 28 at 20:02

Here, I suggest an alternative to avoid the ugly split numerator.

\documentclass[a4paper]{article}
\usepackage[usestackEOL]{stackengine}
\stackMath
\begin{document}
$$\frac{1}{128\pi^{2}} \left[\frac{Q} {m_1 - m_3}\right]$$

where

$\setstackgap{S}{4pt} \Shortstack[r]{Q = 4(m_1 + m_3)\cos \delta \sin\theta_{12} \sin\theta_{13}( \cos \delta \cos \theta_{12}(2 y_e^{2} - y_\mu^{2} - y_\tau^{2}\\ +(y_\mu^{2} -y_\tau^{2})\cos 2\theta_{23})\sin \theta_{13} + (-y_\mu^{2} + y_\tau^{2})\sin \theta_{12} \sin 2\theta_{23})}$

\end{document}


-
+1 sensible mathematical exhibition! –  Niel de Beaudrap May 28 at 20:37

The problem is that the only item getting placed in the lower half of the \splitdfrac was the + symbol, and everything else was being placed on a single line. It’s easier to see in a screenshot of the fraction (this was taken in landscape):

Look at how the + appears to be typeset below everything else, and then the rest of the numerator continues on a different baseline.

Here's a cleaned up version of the code, that is hopefully a little easier to read/follow and compiles to a slightly less wide/more compact fraction:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

$$-\frac{1}{128 \pi^2} \left[ \frac{ \splitfrac{ 4 (m_1+m_3) \cos\delta \sin\theta_{12} \sin\theta_{13} (\cos\delta \cos\theta_{12} (2\,y_e^2 - y_\mu^2 - y_\tau^2 }{ + (y_\mu^2 - y_\tau^2) \cos 2\theta_{23})) \sin\theta_{13} + (-y_\mu^2 + y_\tau^2) \sin\theta_{12} \sin 2\theta_{23} } }{ m_1 - m_3 } \right]$$

\end{document}


Here's a screenshot of the new equation:

• As David Carlisle says in the comments, you should be using \sin or \cos for math operators; not just typing out the words in italic maths font. Additionally, don’t use non-breaking spaces (the tildes ~) in maths mode. Instead, consider using maths-spaces (such as the thin space \, that I’ve used above).

• Consider breaking your fraction up into multiple lines, to make it easier to read and debug. That was the first thing I did, and then the out-of-place + leapt out at me. The scheme above perhaps isn't perfect, but I claim it’s better than a single monolithic line.

• You don't need curly braces around exponents with a single character (e.g. y^2 rather than y^{2}). Again, might make things easier to read (but that's a personal preference).

-
Thanks a lot for the cleaned up code and the comments. I will keep in mind while doing the coding the rest part of the equation. –  Tanvir May 28 at 19:37

To make it easier on your readers to parse the many terms in the numerator, you may want to break the entire expression across three lines. Note also that I have -- like the other responders too -- replaced all Sin and Cos occurrences with \sin and \cos and have deleted all ~ spacer elements.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$$-\frac{1}{128\pi^{2}}\, \dfrac{\left( \splitdfrac{\splitdfrac{4(m_1 + m_3) \cos\delta\sin\theta_{12}\sin\theta_{13}}{{}\times[\cos\delta\cos\theta_{12} (2y_e^{2} - y_\mu^{2} - y_\tau^{2} + (y_\mu^{2} -y_\tau^{2})\cos2\theta_{23}] \sin\theta_{13}}}{+(-y_\mu^{2} + y_\tau^{2}) \sin \theta_{12}\sin2\theta_{23}}\right)}{m_1 - m_3}$$
\end{document}

-