4

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}
4
  • 1
    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) May 28, 2014 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. May 28, 2014 at 19:09
  • 2
    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. May 28, 2014 at 19:28
  • @JohnWickerson The above equation is just a part of a more nasty equation!!!
    – Tanvir
    May 28, 2014 at 19:34

4 Answers 4

6

enter image description here

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

\begin{document}
\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}
1
  • how about putting {} before the plus that starts the second line? May 28, 2014 at 20:02
7

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

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

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}

enter image description here

0
7

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):

enter image description here

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}

\begin{equation}
  -\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{equation}

\end{document}

Here's a screenshot of the new equation:

enter image description here

And some other comments:

  • 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).

2
  • 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, 2014 at 19:37
  • I like this method but is there a way to make the 2 lines of equations on top of the fraction centered?, right not it looks like that they are right aligned
    – KevinKim
    Apr 27, 2016 at 20:14
0

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.

enter image description here

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
-\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{equation}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .