19

I have the following (quite horrible) equation in my thesis:

\begin{align*}
\frac{\partial^2}{\partial t_1^2} f(t_0,t_1) = 
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-1} \cdot \bigl(  
\frac{\partial^2}{\partial t_1^2}\alpha(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +\\
\alpha'(w-t_0+t_1) \cdot 2 \cdot  \log ( \delta+2t_0+2t_1)+
\alpha'(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \frac{2}{\delta+2t_0+2t_1} +\\
2 \frac{\partial}{\partial t_1} \alpha( w-t_0+t_1 ) \bigr) +
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-2}\cdot\\
 \bigl( \frac{\partial}{\partial t_1} \alpha(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot \log ( \delta+2t_0+2t_1) + (\alpha (w-t_0+t_1) -2) \bigr) \cdot \\
\bigl( \alpha'(w -t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +
2\alpha( w-t_0+t_1)\bigr) = \\
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-1} \cdot \Bigl( 
 \frac{\partial^2}{\partial t_1^2}\alpha(w -t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +\\
2 \cdot \alpha'(w-t_0+t_1)  \cdot  \bigl( 2 + \log ( \delta+2t_0+2t_1) \bigr) \Bigr) +
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1)-2} \cdot \Bigl( \\
\alpha '(w-t_0+t_1) \cdot 
(\delta + 2t_0+2t_1) \cdot \log (\delta + 2t_0+2t_1) +  
\bigl(\alpha (w-t_0+t_1) -2) \bigr) \cdot
 \bigl(   \\
\alpha'(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +2\alpha( w-t_0+t_1)\bigr) \Bigr)  < 0
\end{align*}

Using this exact piece of code, without any special formatting commands such as & or \[2mm] the resulting mathematical text is quite unreadable: The equation

How would you format such equations in LaTeX and what would you say is good practice when typesetting such large equations?

  • Either keep your align* or use a split inside a display-math environment, but add breaks in places unlikely to throw your reader off. Break lines before plus signs, but after multiplication signs. For the latter, I think \times is easier to parse than \cdot, here. Also, use \left(, \right) for an automatic hierarchy in delimiter size; that will help your reader parse your equation. – jub0bs Apr 14 '13 at 11:30
  • 1
    You want to prove that this second derivative is negative, right? I guess there's no good typesetting answer to your question, but my mathematical answer is: try and give the proof more structure. – Hendrik Vogt Apr 15 '13 at 12:12
14

I'd try to make the equation smaller by grouping parts:

  • Don't use \cdot where it's not necessary. I use it only for scalar products of vectors and for numbers, but not for symbolic factors or before parentheses.
  • Derivatives are often written as \partial_{t_1} instead of \frac{\partial}{\partial t_1}. This can save some space.
  • Introducing substitutions can be helpful. In your code (\delta+2t_0+2t_1) appears quite often and it could be replaced by a new symbol which will be defined before or after the equation
  • Align the equation at least on all equal signs: &=
  • Other line breaks may be before + signs to "group" summands (this shows that the equation consists of similar parts that are added together)
37

enter image description here

breaking before not after operators and defining names for the subterms

\documentclass{article}
\usepackage{amsmath}

\begin{document}


\begin{align*}
\frac{\partial^2}{\partial t_1^2} f(t_0,t_1)
 &= 
b^{a-1} \cdot \bigl(  
\frac{\partial^2}{\partial t_1^2}a \cdot b \cdot  \log ( b) +
a' \cdot 2 \cdot  \log ( b)+
a' \cdot b \cdot  \frac{2}{b} +
2 \frac{\partial}{\partial t_1} a \bigr) \\
 &\quad+
 b^{a-2}\cdot
 \bigl( \frac{\partial}{\partial t_1}a \cdot b \cdot \log ( b) + (a -2) \bigr) \cdot 
\bigl( a' \cdot b \cdot  \log ( b) + 2a\bigr)\\
  & = 
b^{a-1} \cdot \Bigl( 
 \frac{\partial^2}{\partial t_1^2}a \cdot  b \cdot  \log ( b) +
2 \cdot a'  \cdot  \bigl( 2 + \log ( b) \bigr) \Bigr)\\
&\quad +
b^{a-2} \cdot \bigl(a' \cdot 
c \cdot \log (c) +  
\bigl(a -2) \bigr) \cdot
 \bigl(a' \cdot  b \cdot  \log ( b) +2a)\bigr)\bigr)\\
  &< 0
\end{align*}
where:\\
$a=\alpha( w-t_0+t_1 )$\\
$a'=\alpha'(w-t_0+t_1)$\\
$b=\delta+2t_0+2t_1$\\
$c=\delta + 2t_0+2t_1$
\end{document}
  • 4
    I think adding a \qquad after the first and third line breaks would help the parsing. – jub0bs Apr 14 '13 at 11:35
  • 1
    @FooBar ' is equivalent to ^\prime. – jub0bs Apr 14 '13 at 11:36
  • 1
    @Jubobs always? – Foo Bar Apr 14 '13 at 11:37
  • 2
    @FooBar yes (unless you define it not to be) – David Carlisle Apr 14 '13 at 11:38
  • 1
    @David Carlisle, Thanks, didn't knew that. – Foo Bar Apr 14 '13 at 11:39
12

Actually, I would like to start answering with a question: Is it very informative to display an equation that long?

I would try to identify parts in your equation, and write something like

\[a (A + B + C) < 0\]
where
\[a = ... \]
and
\begin{align} 
A &= ... \\
B &= ... \\
C &= ...
\end{align}

this makes it much easier to read it, and you can maybe give also an exlanation to every term.

2

Try using the breqn package. Begin with usepackage{breqn}, then replace the align* environment with dmath*. Then remove all the manual linebreaks \\, because breqn does the line-breaking and aligning automatically. Also you can replace \bigl and \bigr with \left and \right, because breqn allows line breaks within a \left-\right pair.

\documentclass{article}
\usepackage{breqn}  % from the "mh" bundle

\begin{document}

\begin{dmath*}
\frac{\partial^2}{\partial t_1^2} f(t_0,t_1) = 
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-1} \cdot \left(  
\frac{\partial^2}{\partial t_1^2}\alpha(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  
\log ( \delta+2t_0+2t_1) +
\alpha'(w-t_0+t_1) \cdot 2 \cdot  \log ( \delta+2t_0+2t_1)+
\alpha'(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \frac{2}{\delta+2t_0+2t_1} +
2 \frac{\partial}{\partial t_1} \alpha( w-t_0+t_1 ) \right) +
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-2}\cdot
 \left( \frac{\partial}{\partial t_1} \alpha(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) 
\cdot \log ( \delta+2t_0+2t_1) + (\alpha (w-t_0+t_1) -2) \right) \cdot 
\left( \alpha'(w -t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +
2\alpha( w-t_0+t_1)\right) = 
( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1 )-1} \cdot \left( 
\frac{\partial^2}{\partial t_1^2}\alpha(w -t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  
\log ( \delta+2t_0+2t_1) +
2 \cdot \alpha'(w-t_0+t_1)  \cdot  \left( 2 + \log ( \delta+2t_0+2t_1) \right) \right)
+ ( \delta+2t_0+2t_1)^{\alpha( w-t_0+t_1)-2} \cdot \Bigl( 
\alpha '(w-t_0+t_1) \cdot 
(\delta + 2t_0+2t_1) \cdot \log (\delta + 2t_0+2t_1) +  
\left(\alpha (w-t_0+t_1) -2 \right) \cdot
 \left(   
\alpha'(w-t_0+t_1) \cdot ( \delta+2t_0+2t_1) \cdot  \log ( \delta+2t_0+2t_1) +2\alpha(
 w-t_0+t_1)\right) \Bigr)  < 0
\end{dmath*}
\end{document}

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.