views:

1269

answers:

4

I have this equation and it's quite big (basically a FDM one) but it aligns with the text and then continues out on the right side to the nothingness. I've tried stuff like \begin{center} and \hspace*{-2.5cm} but to no avail. I want it to use the whole line not just from the left-margin and out to the right.

How do I do it and do I need to install some special package for it?

I use the \[ instead of the displaymath like this

\[
  Equation arrays here
\]

The code

\[
 \left(
   \begin{array}{cccccc}
      -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots  & 0 \\
      -\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots \\  
      0 & -\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots \\  
      \vdots  & 0  & \ddots & \vdots  \\
      \vdots & \vdots  & \vdots  & -\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) \\  
      0 & \vdots  & \vdots  & 0 & \kappa - \frac{2h\kappa_{v}}{\kappa}(\frac{hv\rho}{2} - \kappa) & -2\kappa \\  
   \end{array} 
 \right)
 \left(
   \begin{array}{c}
      T_{1} \\
      T_{2} \\
      \vdots \\
      T_{n} \\
   \end{array} 
 \right)
 =  
 \left(
   \begin{array}{c}
      Q(0) + \kappa T_{0} \\
      Q(h) \\
      Q(2h) \\
      \vdots \\
      Q((n-1)h) \\
      2\frac{\kappa_{v}}{\kappa_{v}}T_{out} \\
   \end{array} 
 \right)  
\]
A: 

could you add a line-break using \\ ? Begin centre only aligns things like figures, it won't affect line equations.

You might like to look at the American Mathematical Society guide to their package s ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf

UberAlex
AFAIK the standard equation environment does not support line breaks using `\\\`.
Oben Sonne
A: 

You could use the eqnarray environment to break equations into multiple lines.

Oben Sonne
Use align from amsmath instead: http://www.tug.org/pracjourn/2006-4/madsen/
Will Robertson
+5  A: 

The \[ \] delimiters are intended for single-line equations. In basic LaTeX you can use the eqnarray environment to make a multi-line equations, or you can use the multline environment from the amsmath package. The eqnarray environment lets you use \\ for line breaks but if you want the equation to be numbered, you also need to use the \nonumber command on all lines but one to prevent the numbering of all lines. The multline environment is intended for a single equation so it always produces just one equation number too.

EDIT: This isn't what I would do habitually, but since your equation does seem to fit on a single line, here's the code I've used to get whole-line spanning things:

\newenvironment{widefig}[1][1in]{%
  \begin{list}{}{\setlength{\itemindent}{-#1}%
      \setlength{\leftmargin}{0pt}%
      \setlength{\rightmargin}{0pt}}\item
  }{%
  \end{list}
}

Like the environment name suggests, I wrote it for figures that are too wide to fit inside the margins, so this allows controlling the left margin and permits a figure to be centered on the whole line.

How I modified your example was to wrap it inside a \begin{widefig}[1.5in]-\end{widefig} pair, added

\relpenalty=10000
\binoppenalty=10000

after the \begin{widefig} line to prohibit line breaking inside the formula, and changed the \[\] into \(\) because the widefig environment only works for inline, not display. You might also need to fiddle a bit with the amount of space given on the \begin line to make the equation properly centered.

I don't believe this is very good typesetting style, though, so you'll want to be very careful about using it, and preferably try to fit things inside the margins. For instance, in this case you could also get rid of a few columns in your first matrix; the usual standard is to have only the first, second, and last, but you probably also want the second-to-last row and column, since the changes in the values for the last row and column is a bit surprising. If you did that, it might fit (but I didn't check).

jk
amsmath's align is highly recommended over eqnarray
Will Robertson
That's a awesome hack!! Thanks, it worked perfectly.
Reed Richards
+1  A: 

If you really don't want to break the equation over lines and you don't mind breaking the text width, you could try something like: (untested)

\centerline{$\displaystyle <long equation here>$}
Will Robertson
Hmm didn't work, made the text go over the equation instead.
Reed Richards
Huh? \documentclass{article} \usepackage{lipsum} \begin{document} \lipsum[1] \centerline{$\displaystyle a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a$} \lipsum[1] \end{document}
Will Robertson