4

I have quite a few equations in a latex document that are similar to this one here:

\mathbb{E}(\cos^2) =  
 \frac{\pi  \left(\beta  \left(8 \left(2 \alpha ^2+2 \alpha +1\right)
   \beta ^2-12 (2 \alpha +1) \beta +15\right) I_1(2 \beta )+2 \left(-3
   \left(4 \alpha ^2+4 \alpha +3\right) \beta ^2+(8 \alpha +4) \beta
   ^3+12 (2 \alpha +1) \beta -15\right) I_2(2 \beta )\right)}{64 \beta
   ^4}

Now, I am just looking for a fast way to split this equation into several terms without having to change much here. The problem is that this equation contains a fraction on the right side, so when I try to do it with align, I need to reorder the nominators and denominators, so that it works out.

Since I have to change like 40 of these guys, I would love to see a fast way to split these equations into several terms standing in different lines without having to change much here.

6

Please always post complete documents.

If you are generating lots of these I'd set it up so line breaking is automatic.

Don't over-use \left\right and avoid big fractions:

enter image description here

If you are breaking by hand you could do better but if you need automatic solution of output from a CA system or similar...

\documentclass{article}
\usepackage{amsfonts}
\begin{document}
\begin{center}
\let\oldfrac\frac
\def\frac#1#2{\oldfrac{1}{#2}(#1)}

$\mathbb{E}(\cos^2) =  
 \frac{\pi  (\beta  (8 (2 \alpha ^2+2 \alpha +1)
   \beta ^2-12 (2 \alpha +1) \beta +15) I_1(2 \beta )+2 (-3
   (4 \alpha ^2+4 \alpha +3) \beta ^2+(8 \alpha +4) \beta
   ^3+12 (2 \alpha +1) \beta -15) I_2(2 \beta ))}{64 \beta
   ^4}$
\end{center}

\end{document}
  • two questions about this. I just put \let\oldfrac\frac \def\frac#1#2{\oldfrac{1}{#2}(#1)} in front of my document and now all equations are affected, can I do it that way that this has only an effect on a local set of equations. Second question: Apparently I don't get automatic line-breaking and only the denominator is in front of my equation, but I have to say that I am using the \begin{equation}...\end{equation} environment for equations. – user48924 Nov 3 '14 at 8:13
  • You won't get automatic linebreaking in equation use center you can use \refstepcounter{equation} (\theequation) to get automatic referencable equation numbers. The frac redefintion can be in the environment as I did it or inside any {} group or environment , or just explicitly restore \frac with \let\frac\oldfrac – David Carlisle Nov 3 '14 at 8:23
2

If you really must use a long fractional expression, I would use the \splitfrac macro of the mathtools package to split the long numerator. In order to enhance the readability of your equations, you shouldn't rely on TeX to find "good" line breaks. Instead, parse the equation yourself and find the best place for \splitfrac to introduce the line break.

I would also use curly braces and square brackets in addition to round parentheses to help the reader with the visual parsing of the hierarchy of parentheses. By the way, using \left and \right gives you nothing in the case of this equation: all round parentheses have exactly the same size since the material they enclose isn't "large".

enter image description here

\documentclass{article}
\usepackage{amssymb,mathtools}
\begin{document}
\[
\mathbb{E}(\cos^2) =  
 \frac{\splitfrac{\pi  \bigl\{\beta  \bigl[8 (2 \alpha ^2+2 \alpha +1)
   \beta ^2-12 (2 \alpha +1) \beta +15\bigr] I_1(2 \beta )}
   {+2 \bigl[-3
   (4 \alpha ^2+4 \alpha +3) \beta ^2+(8 \alpha +4) \beta
   ^3+12 (2 \alpha +1) \beta -15\bigr] I_2(2 \beta ) \bigr\}}}{64 \beta^4}
\]
\end{document}
  • Why the \pi \{ ... \} instead of \pi ( ... )? – wchargin Nov 3 '14 at 2:22
  • @WChargin - for optical variety: curly braces for the outermost group, square brackets for the middle group, etc – Mico Nov 3 '14 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy