Matrices with same height
I think the easiest solution, i.e., the one that requires the least amount of additional typing, involves increasing the value of \arraystretch
. Its default value is 1.0
; increasing it to about 1.8
at the start of the equation
environment should do the job.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}\label{eq:xyz}
\renewcommand\arraystretch{1.8} % default value: 1.0
\begin{pmatrix}
1 & 0 & 0 & \cdots & \cdots & 0 \\
\mu & \lambda & \nu & \ddots & & \vdots \\
0 & \mu & \lambda & \nu & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
\vdots & & 0 & \mu & \lambda & \nu \\
0 & \cdots & \cdots & 0 & -1/h & 1/h \\
\end{pmatrix}
\cdot
\begin{pmatrix}
T^{(j+1)}(0) \\
T^{(j+1)}(h) \\
\vdots \\
\vdots \\
\vdots \\
T^{(j+1)}(N h)
\end{pmatrix}
=
\begin{pmatrix}
T(0) \\
f(h) \\
f(2h) \\
\vdots \\
f((N-1) h) \\
\text{blabla}
\end{pmatrix}
\end{equation}
\end{document}
For consistency reasons, I don't think that increasing the \arraystretch
is a good idea. However, if we correctly understand the cause of this behavior, we may come with a simple and exact solution. The main cause of this problem here is writing symbols of different heights in the three matrices, namely, the \vdots
and \ddots
symbols which are higher than the rest of the symbols.
To remedy this, one should deliberately introduce redundant \vdots
(or \ddots
) so that the three matrices can have the same number of them. The second matrix requires only one because it has only three \vdots
while the first one has four of them. Similarly, the third matrix requires three \vdots
since it has only one \vdots
.
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\begin{document}
\newcommand{\D}{\vphantom{\vdots}}
\begin{equation}
\begin{pmatrix}
1 & 0 & 0 & \cdots & \cdots & 0 \\
\mu & \lambda & \nu & \ddots & & \vdots \\
0 & \mu & \lambda & \nu & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
\vdots & & 0 & \mu & \lambda & \nu \\
0 & \cdots & \cdots & 0 & -1/h & 1/h \\
\end{pmatrix}
\cdot
\begin{pmatrix}
T^{(j+1)}(0) \\
T^{(j+1)}(h)\D \\
\vdots \\
\vdots \\
\vdots \\
T^{(j+1)}(N\cdot h)
\end{pmatrix}
=
\begin{pmatrix}
T(0) \D \\
f(h) \D \\
f(2h)\D \\
\vdots \\
f((N-1)\cdot h) \\
blabla
\end{pmatrix}
\end{equation}
\end{document}
Edit: (In response to the OP's comment)
If you don't like typing that \D
command in every row, try this automatic alternative:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath, array}
\newcolumntype{V}{>{\vphantom{\vdots}\arraybackslash}c}
\begin{document}
\begin{equation}\left (
\begin{array}{@{}*5{c}V@{}}
1 & 0 & 0 & \cdots & \cdots & 0 \\
\mu & \lambda & \nu & \ddots & & \vdots \\
0 & \mu & \lambda & \nu & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
\vdots & & 0 & \mu & \lambda & \nu \\
0 & \cdots & \cdots & 0 & -1/h & 1/h \\
\end{array}\right )
\cdot \left (
\begin{array}{@{}V@{}}
T^{(j+1)}(0) \\
T^{(j+1)}(h) \\
\vdots \\
\vdots \\
\vdots \\
T^{(j+1)}(N h)
\end{array}\right )
=\left (
\begin{array}{@{}V@{}}
T(0) \\
f(h) \\
f(2h) \\
\vdots \\
f((N-1) h) \\
blabla
\end{array}\right )
\end{equation}
\end{document}
which gives the first equation below.
Now compare equation 1 (for my code above) and equation 2 (using the \arraystretch
method). Which one do you think is better? And look how they are inconsistent. Imagine that you have two consecutive paragraphs one is single-spaced and the other is almost double-spaced (except for captions, etc.). Of course they will look bad.
Besides, changing the \arraystretch
requires trial and error. How would we know in advance that this 1.8
will be just the right value? Why not 1.5
, for example?
Here, I just turn all pmatrix
environments into \parenMatrixstack
s and \parenVectorstack
s. The inter-column gap in the matrix is governed by \setstacktabbedgap{}
and the inter-row baselineskip is governed by \setstackgap{L}{}
. This answer requires my tabstackengine
package.
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,tabstackengine}
\setstacktabbedgap{1ex}
\setstackgap{L}{1.2\baselineskip}
\begin{document}
\begin{equation}
\parenMatrixstack{
1 & 0 & 0 & \cdots & \cdots & 0 \\
\mu & \lambda & \nu & \ddots & & \vdots \\
0 & \mu & \lambda & \nu & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
\vdots & & 0 & \mu & \lambda & \nu \\
0 & \cdots & \cdots & 0 & -1/h & 1/h
}
\cdot
\parenVectorstack{
T^{(j+1)}(0) \\
T^{(j+1)}(h) \\
\vdots \\
\vdots \\
\vdots \\
T^{(j+1)}(N\cdot h)
}
=
\parenVectorstack{
T(0) \\
f(h) \\
f(2h) \\
\vdots \\
f((N-1)\cdot h) \\
blabla
}
\end{equation}
\end{document}