Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do you write a long formula in a more beautiful manner

  1. for the better, all my formulas in lines with the same length.
  2. formulas are long with slightly smaller text.
  3. Is it better to be done automatically (because I have a lot of formulas).

I was was wondering that how formulas in the books are so pretty? How are they written?

For example, I put some of my equations below:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{breqn}
\title{‏break a long formulation}
\author{}
\begin{document}
\maketitle
It was wandering that how formula in book are very pretty? how they write?
\begin{align*}
&\left( \hat{E}h+2{{E}^{s}} \right)\,\left[ \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{u}_{mj}}+\left( \sum\limits_{m=1}^{{{N}_{x}}}{A_{im}^{x}}{{w}_{mj}} \right)\left( \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{w}_{mj}} \right) \right]+\\
&\left[ \nu \hat{E}h+Gh+2{{E}^{s}} \right]\,\left[ \sum\limits_{m=1}^{{{N}_{x}}}{\sum\limits_{n=1}^{{{N}_{y}}}{A_{im}^{x}A_{jn}^{y}{{v}_{mn}}}} \right.+\left( \sum\limits_{n=1}^{{{N}_{y}}}{A_{jn}^{y}}{{w}_{in}} \right).\\
&\left. \left( \sum\limits_{m=1}^{{{N}_{x}}}{\sum\limits_{n=1}^{{{N}_{y}}}{A_{im}^{x}A_{jn}^{y}{{w}_{mn}}}} \right) \right]\left[ Gh+2\left( \left. 2{{\mu }^{s}}-{{\tau }^{s}} \right) \right. \right]\left[ \sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}{{u}_{in}}} \right.+\\
&\left. \left( \sum\limits_{m=1}^{{{N}_{x}}}{A_{im}^{x}}{{w}_{mj}} \right)\left( \sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}{{w}_{in}}} \right) \right]=\rho h{{\ddot{u}}_{ij}}-\mu \rho h\left( \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{{\ddot{u}}}_{mj}} \right.+\\
&\left. \sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}}{{{\ddot{u}}}_{in}} \right)\\     
\end{align*}

\begin{dmath}
\left( \hat{E}h+2{{E}^{s}} \right)\left[ \sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}{{v}_{in}}}+\left( \sum\limits_{n=1}^{{{N}_{y}}}{A_{jn}^{y}{{w}_{in}}} \right)\left( \sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}{{w}_{in}}} \right) \right]+\left( \nu \hat{E}h+Gh+2{{E}^{s}} \right)\left[ \sum\limits_{m=1}^{{{N}_{x}}}{\sum\limits_{n=1}^{{{N}_{y}}}{A_{im}^{x}A_{jn}^{y}{{u}_{mn}}}} \right.+\left( \sum\limits_{m=1}^{{{N}_{x}}}{A_{im}^{x}}{{w}_{mj}} \right)\left( \sum\limits_{m=1}^{{{N}_{x}}}{\sum\limits_{n=1}^{{{N}_{y}}}{A_{im}^{x}A_{jn}^{y}{{w}_{mn}}}} \right)+\left[ Gh \right.+\left. 2\left( 2{{\mu }^{s}}-{{\tau }^{s}} \right) \right]\left[ \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{v}_{mj}}+ \right. \left. \left( \sum\limits_{n=1}^{{{N}_{y}}}{A_{jn}^{y}}{{w}_{in}} \right)\left( \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{w}_{mj}} \right) \right]=\rho h{{\ddot{v}}_{ij}}-\mu \rho h\left( \sum\limits_{m=1}^{{{N}_{x}}}{B_{im}^{x}}{{{\ddot{v}}}_{mj}} \right.+ \left. +\sum\limits_{n=1}^{{{N}_{y}}}{B_{jn}^{y}}{{{\ddot{v}}}_{in}} \right)
\end{dmath}


\begin{equation}
\begin{split}
&\left\{ \left[ {{T}_{44}}\left( 1,1 \right)+2{{T}_{44}}\left( 5,1 \right)+{{T}_{44}}\left( 2,1 \right) \right]\left( \sum\limits_{m=1}^{{{N}_{\xi }}}{\bar{D}_{im}^{\xi }}w_{mj}^{b}+B_{i1}^{\xi }\kappa _{1j}^{bx}+B_{i1}^{\xi }\kappa _{{{N}_{\xi }}j}^{b\xi } \right)+ \right.\\ 
&\left[ {{T}_{44}}\left( 1,2 \right) \right.+2{{T}_{44}}\left( 5,2 \right)+\left. {{T}_{44}}\left( 2,2 \right) \right]\left( \sum\limits_{n=1}^{{{N}_{\eta }}}{\bar{D}_{jn}^{\eta }w_{in}^{b}}+B_{j1}^{\eta }\kappa _{i1}^{b\eta }+B_{j1}^{\eta }\kappa _{i{{N}_{\eta }}}^{b\eta } \right)+\\
&\left[ {{T}_{44}}\left( 1,3 \right) \right.+2{{T}_{44}}\left( 5,3 \right)+\left. {{T}_{44}}\left( 2,3 \right) \right]\sum\limits_{n=1}^{{{N}_{\eta }}}{A_{jn}^{\eta }}\left( \sum\limits_{m=1}^{{{N}_{\xi }}}{\bar{C}_{im}^{\xi }}w_{mn}^{b}+A_{i1}^{\xi }\kappa _{1n}^{b\xi } \right.+A_{i{{N}_{\xi }}}^{\xi }.\\ 
&\left. \kappa _{{{N}_{\xi }}n}^{b\xi } \right)+\left[ {{T}_{44}}\left( 1,4 \right)+2{{T}_{44}}\left( 5,4 \right)+{{T}_{44}}\left( 2,4 \right) \right]\sum\limits_{m=1}^{{{N}_{\xi }}}{A_{im}^{\xi }}\left( \sum\limits_{n=1}^{{{N}_{\eta }}}{\bar{C}_{jn}^{\eta }}w_{mn}^{b} \right.+A_{j1}^{\eta }\kappa _{1n}^{b\eta }\\
&\left. +A_{j{{N}_{\eta }}}^{\eta }\kappa _{{{N}_{\eta }}n}^{b\eta } \right)+\left. \left[ {{T}_{44}}\left( 1,5 \right)+2{{T}_{44}}\left( 5,5 \right)+{{T}_{44}}\left( 2,5 \right) \right]\sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{B_{im}^{\xi }B_{jn}^{\eta }}w_{mn}^{b}} \right\}2\mu {{\tau }^{s}}\\
&-2\mu {{\tau }^{s}}\left\{ \left[ {{T}_{44}}\left( 1,1 \right)\hspace{0.15 cm}+ \right.2{{T}_{44}}\left( 5,1 \right)\hspace{0.15 cm}+\left. {{T}_{44}}\left( 2,1 \right) \right]\sum\limits_{m=1}^{{{N}_{\xi }}}{D_{im}^{\xi }}w_{mj}^{s}\hspace{0.15 cm}+ \right.\left[ {{T}_{44}}\left( 1,2 \right) \right.+\\
& 2{{T}_{44}}\left( 5,2 \right)+\left. {{T}_{44}}\left( 2,2 \right) \right]\sum\limits_{n=1}^{{{N}_{\eta }}}{D_{jn}^{\eta }w_{in}^{s}}+\left[ {{T}_{44}}\left( 1,3 \right) \right.+2{{T}_{44}}\left( 5,3 \right)+\left. {{T}_{44}}\left( 2,3 \right) \right].\\ 
&\sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{C_{im}^{\xi }A_{jn}^{\eta }}w_{mn}^{s}}+\left[ {{T}_{44}}\left( 1,4 \right)+2{{T}_{44}}\left( 5,4 \right)+{{T}_{44}}\left( 2,4 \right) \right]\sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{A_{im}^{\xi }C_{jn}^{\eta }}w_{mn}^{s}}+\\ 
&\left. \left[ {{T}_{44}}\left( 1,5 \right)+2{{T}_{44}}\left( 5,5 \right)+{{T}_{44}}\left( 2,5 \right) \right]\sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{B_{im}^{\xi }B_{jn}^{\eta }}w_{mn}^{s}} \right\}+\left( kGh+2{{\tau }^{s}} \right).\\
&\left[ {{T}_{22}}\left( 1,1 \right)\sum\limits_{m=1}^{{{N}_{\xi }}}{B_{im}^{\xi }} \right.w_{mj}^{s}+{{T}_{22}}\left( 1,2 \right)\sum\limits_{n=1}^{{{N}_{\eta }}}{B_{jn}^{\eta }}w_{in}^{s}+{{T}_{22}}\left( 1,3 \right)\left. \sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{A_{im}^{\xi }A_{jn}^{\eta }w_{mn}^{s}}} \right]\\ 
&+\left( 2{{\tau }^{s}}+\mu {{m}_{0}}\frac{{{\partial }^{2}}}{\partial {{t}^{2}}} \right)\left[ {{T}_{22}}\left( 1,1 \right)\sum\limits_{m=1}^{{{N}_{\xi }}}{B_{im}^{\xi }} \right.\left( w_{mj}^{b}+w_{mj}^{s} \right)+{{T}_{22}}\left( 1,2 \right)\sum\limits_{n=1}^{{{N}_{\eta }}}{B_{jn}^{\eta }}w_{in}^{b}\\
&\left. +w_{in}^{s} \right)+\left. \sum\limits_{m=1}^{{{N}_{\xi }}}{\sum\limits_{n=1}^{{{N}_{\eta }}}{A_{im}^{\xi }A_{jn}^{\eta }\left( w_{mn}^{b}+w_{mn}^{s} \right)}} \right]={{m}_{0}}\frac{{{\partial }^{2}}\left( w_{ij}^{b}+w_{ij}^{s} \right)}{\partial {{t}^{2}}} 
\end{split}
\end{equation}
\end{document}
share|improve this question
6  
Please read How do you accept an answer? in order to improve your accept rate. –  texenthusiast Dec 18 '12 at 3:29
2  
Is this question about LaTeX skills or is this about best practice mathematical typesetting? Also, the example code is hardly minimal and it is difficult to see the nub of it. –  Marc van Dongen Dec 18 '12 at 6:37
    
Yep!@texenthusiast is right! People is not encouraged of answering your questions if you don't accept answers! –  Ander Biguri Dec 18 '12 at 8:50
add comment

1 Answer 1

In my opinion the most important point is that the structure of the equations should be transparent to the reader. Automatic breaking of the equations usually fails dismally on this, despite noble efforts; making all lines the same length is far far worse.

I'll concentrate on your first example.

As a mathematician, I would seriously consider changing the notation: every sum in your example is just some matrix multiplication and I would want to just write the first sum as B u (or possibly (B_i^x) (u)_j) with notation appropriately explained in the surrounding text. Or you could use the Einstein summation convention, where repeated indices are automatically summed over. However, these approaches may be out of court.

With the given notation I would make the following points:

  • Don't use automatic sizing with \left and \right, use the specific commands \bigl, \Bigl, \biggl, \Biggl and the right variants aggressively to emphasise the structure of the equation.
  • Break lines at logical points in the equation: at major relations =, then +; avoid breaking up logical units.
  • Put relation signs at the beginning of the next line, not the end of the current.
  • Use indentation to help the visualisation of the structure.

As regards your specific coding

  • Don't overuse { } - too many brackets make unreadable code.
  • The \limits command is not necessary in display mode.
  • Indent the source so that it is readable.

Here is an updated version of your first equation

Sample output

\documentclass{article}

\usepackage[fleqn]{amsmath}
\usepackage{amssymb}

\begin{document}

\begin{align*}
  &\bigl( \hat{E}h+2E^s \bigr)
  \Biggl[ 
    \sum_{m=1}^{N_x} B_{im}^x u_{mj}
    + \biggl( \sum_{m=1}^{N_x} A_{im}^x w_{mj} \biggr)
      \biggl( \sum_{m=1}^{N_x} B_{im}^x w_{mj} \biggr)
  \Biggr]\\
  &\quad+
    \bigl( \nu \hat{E}h+Gh+2E^s \bigr) \\
    &\qquad \cdot
     \Biggl[ 
       \sum_{m=1}^{N_x} \sum_{n=1}^{N_y} A_{im}^x A_{jn}^y v_{mn}
       + \biggl( \sum_{n=1}^{{N_y}}{A_{jn}^y}{w_{in}} \biggr)
       \biggl(\sum_{m=1}^{N_x} \sum_{n=1}^{N_y} A_{im}^x A_{jn}^y w_{mn} \biggl)
      \Biggr] \\
    &\qquad \cdot
      \bigl[ Gh+2(2\mu^s - \tau^s)\bigr]
      \Biggl[
        \sum_{n=1}^{N_y} B_{jn}^y u_{in}
        + \biggl( \sum_{m=1}^{N_x} A_{im}^x w_{mj} \biggr)
          \biggl( \sum_{n=1}^{N_y} B_{jn}^y w_{in} \biggr) 
      \Biggr] \\
  &\quad = \rho h{\ddot{u}_{ij}}
     - \mu \rho h
       \biggl(
         \sum_{m=1}^{N_x} B_{im}^x \ddot{u}_{mj}
         + \sum_{n=1}^{N_y} B_{jn}^y \ddot{u}_{in}
       \biggr)  
\end{align*}

\end{document}

Reading the documentation associated with amsmath will provide lots of extra advice and further references.

share|improve this answer
2  
“Use indentation to help the visualisation of the structure.” is valid for output as well as input. –  Qrrbrbirlbel Dec 18 '12 at 9:55
    
You could use mathtools instead of amsthm, as the first one loads de latter, and which include \MoveEqLeft. I prefer using \MoveEqLeft in the first line than using \quad in the rest, because writing \quad is manually adjusting the output, what I try to avoid. –  Manuel Dec 18 '12 at 10:13
1  
@Manuel mathtools is excellent and the \MoveEqLeft is often very useful. In this particular example though I have more levels of indentation than just one. Getting big equations to look reasonable inevitably involves manually adjusting the output at many different levels from the choice of environmant down. \MoveEqLeft is also a manual adjustment. –  Andrew Swann Dec 18 '12 at 10:23
    
I know it is manual, but 'much less manual' in my opinion. I agree with you with the rest, anyway. –  Manuel Dec 18 '12 at 10:27
    
@Manuel -- mathtools is a great package, but it loads amsmath, not amsthm. –  barbara beeton Dec 18 '12 at 14:21
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.