Hello again
I'm trying to write a matrix equation, but because I have fractions in one of my matrices it's much taller than the rest (despite having the same number of rows) and it's looking ugly. In fact, the whole thing looks a bit less lovely than I'd hope... does anyone know a better way to do this?
Thanks!
Here is the code:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\textwidth=15cm%6.25true in
\textheight=23cm%9.65true in
\begin{document}
\begin{equation}
\begin{bmatrix}
\frac{A_{i,1} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} & 0 & \cdots & 0 \\
\frac{1}{\Delta y^{2}} & \frac{A_{i,2} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} & & \vdots\\
0 & \ddots & \ddots & \ddots & 0\\
\vdots & & \frac{1}{\Delta y^{2}} & \frac{A_{i,M-1} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} \\
0 & \cdots & 0 & \frac{1}{\Delta y^{2}} & \frac{A_{i,M} \Delta y^{2} - 2}{\Delta y^{2}} \\
\end{bmatrix}
\left[
\begin{array}{c}
V_{i,1} \\ V_{i,2} \\ \vdots \\ V_{i,M-1} \\ V_{i,M}
\end{array} \right] = \left[
\begin{array}{c}
B_{i,1} - \frac{1}{\Delta y^{2}}V_{i,0} \\ B_{i,2} \\ \vdots \\ B_{i,M-1} \\ B_{i,M}-\frac{1}{\Delta y^{2}}V_{i,M+1}
\end{array} \right]
\end{equation}
\end{document}
General ⇒ vertical space in matrix equations
NEW: TikZ book now 40% off at Amazon.com for a short time.

vertical space in matrix equations
Replace your equation environment by the following code:
Remarks:

Code: Select all
\newcommand{\FF}{\vphantom{\frac{A_{i,1}y^2}{y^2}}}
\begin{equation}
\renewcommand{\arraystretch}{1.4}
\begin{bmatrix}
\frac{A_{i,1} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} & 0 & \cdots & 0 \\
\frac{1}{\Delta y^{2}} & \frac{A_{i,2} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} & & \vdots\\
0 & \ddots & \ddots & \ddots & 0\\
\vdots & & \frac{1}{\Delta y^{2}} & \frac{A_{i,M-1} \Delta y^{2} - 2}{\Delta y^{2}} & \frac{1}{\Delta y^{2}} \\
0 & \cdots & 0 & \frac{1}{\Delta y^{2}} & \frac{A_{i,M} \Delta y^{2} - 2}{\Delta y^{2}} \\
\end{bmatrix}
\begin{bmatrix}
\FF V_{i,1} \\ \FF V_{i,2} \\ \vdots \\ \FF V_{i,M-1} \\ \FF V_{i,M}
\end{bmatrix}=
\begin{bmatrix}
\FF B_{i,1} - \frac{1}{\Delta y^{2}}V_{i,0} \\ \FF B_{i,2} \\ \vdots \\ \FF B_{i,M-1} \\ \FF B_{i,M}-\frac{1}{\Delta y^{2}}V_{i,M+1}
\end{bmatrix}
\end{equation}
- You should consistently use environments. If you write the matrix with bmatrix, do so with the two vectors.
- The \FF command writes an invisible character having no width (so it don't fill any space) but the same height as the fraction frac{A_{i,1}y^2}{y^2}. Adding this invisible character in every vector row makes vectors have the same height than the matrix.
- \arraystrecth is a parameter to control the vertical space between rows. Inside the matrix environments defined in amsmath, its value is 1.2. Increasing a bit \arraystrecth adds vertical space.
- You can consider alternatives, taking advantage of mathematical notation. For example, since \Delta y^{2} is always dividing matrix elements, you can simply pull out this factor and write
Code: Select all
\frac{1}{\Delta y^{2}} \begin{bmatrix} (matrix stuff, once arranged without fractions) \end{bmatrix}

The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
-
- Posts: 5
- Joined: Mon Oct 06, 2008 1:55 pm
Re: vertical space in matrix equations
Thank you... Again! It's looking much better
I'll keep the tips in mind in the future...
