5

I have a matrix and a vector where lines are partially overlapped:enter image description here

\documentclass{article}
\begin{equation}\label{eq25}
\begin{aligned}
&\left( \begin{array}{rrrr}
3 & -3 & 0 & 1 \\ 
\frac{16}{9} & -\frac{20}{9} & 1 & 0 \\ 
-2 & \frac{1}{2} & 0 & 0 \\ 
2 & -1 & 0 & 0
\end{array} \right)\left( \begin{array}{c}
y_{n+1} \\ 
y_{n+2} \\ 
y_{n+\frac{8}{3}} \\ 
y_{n+3}
\end{array} \right)
=\left( \begin{array}{rrrr}
0 & 0 & 0 & 1 \\ 
0 & 0 & 0 & \frac{5}{9} \\ 
0 & 0 & 0 & -\frac{3}{2} \\ 
0 & 0 & 0 & 1
\end{array} \right)\left( \begin{array}{c}
y_{n-3} \\ 
y_{n-2} \\ 
y_{n-1} \\ 
y_n
\end{array} \right) \\ \nonumber
&+
h^3\left( \begin{array}{rrrr}
\frac{47}{100} & \frac{23}{40} & -\frac{81}{800} & \frac{1}{20} \\ 
\frac{7}{27} & \frac{203}{729} & -\frac{25}{324} & \frac{65}{2187} \\ 
\frac{1399}{4200} & -\frac{23}{168} & \frac{783}{5600} & -\frac{17}{2800} \\            -\frac{109}{120} & \frac{61}{120} & -\frac{81}{160} & \frac{79}{360}
\end{array} \right)\left( \begin{array}{c}
f_{n+1} \\ 
f_{n+2} \\ 
f_{n+\frac{8}{3}} \\ 
f_{n+3}
\end{array} \right)+h^3\left( \begin{array}{rrrr}
0 & 0 & 0 & \frac{1}{160} \\ 
0 & 0 & 0 & \frac{31}{8748} \\ 
0 & 0 & 0 & -\frac{13}{224} \\ 
0 & 0 & 0 & -\frac{451}{1440}
\end{array} \right)\left( \begin{array}{c}
f_{n-3} \\ 
f_{n-2} \\ 
f_{n-1} \\ 
f_n
\end{array} \right). \nonumber %\eqno{(25)}      
\end{aligned}
\end{equation}
\end{document}

Question. How to add additional space between the lines inside the matrix?

1
5

I propose this variant, always based on pmatrix and pmatrix* environments, but also on cellspace, which enables you to define a minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you you load siunitx). The [math] option extends this to the various matrix environments, but not to the matrix* environment. However a small patch (communicated by the package author) makes it work also in the latter case.

Another improvement uses \mfrac (medium-size fractions) from nccmath, to avoid the size discrepancy between fractions and integers in arrays and matrices.

\documentclass{article}
\usepackage{mathtools, nccmath} 
\usepackage[math]{cellspace} 
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}
\makeatletter
\edef\@tempa{%
      \catcode`:=\the\catcode`:\relax
      \catcode`_=\the\catcode`_\relax}
\catcode`:=11
\catcode`_=11
\def\MT_matrix_begin:N #1{%
      \hskip -\arraycolsep
      \MH_let:NwN \@ifnextchar \MH_nospace_ifnextchar:Nnn
      \array{*\c@MaxMatrixCols {>{$}S#1<{$}}}}
\@tempa
\makeatother

\begin{document}

\begin{equation}\label{eq25}
\begin{aligned}
& \begin{pmatrix*}[r]
3 & -3 & 0 & 1 \\
\frac{16}{9} & -\frac{20}{9} & 1 & 0 \\
-2 & \frac{1}{2} & 0 & 0 \\
2 & -1 & 0 & 0
\end{pmatrix*} \begin{pmatrix*}
y_{n+1} \\
y_{n+2} \\
y_{n+\frac{8}{3}} \\
y_{n+3}
\end{pmatrix*}
= \begin{pmatrix*}[r]
0 & 0 & 0 & 1 \\
0 & 0 & 0 & \frac{5}{9} \\
0 & 0 & 0 & -\frac{3}{2} \\
0 & 0 & 0 & 1
\end{pmatrix*} \begin{pmatrix*}
y_{n-3} \\
y_{n-2} \\
y_{n-1} \\
y_n
\end{pmatrix*} \\ \nonumber
&+
h^3 \begin{pmatrix*}[r]
\frac{47}{100} & \frac{23}{40} & -\frac{81}{800} & \frac{1}{20} \\
\frac{7}{27} & \frac{203}{729} & -\frac{25}{324} & \frac{65}{2187} \\
\frac{1399}{4200} & -\frac{23}{168} & \frac{783}{5600} & -\frac{17}{2800} \\ -\frac{109}{120} & \frac{61}{120} & -\frac{81}{160} & \frac{79}{360}
\end{pmatrix*} \begin{pmatrix}
f_{n+1} \\
f_{n+2} \\
f_{n+\frac{8}{3}} \\
f_{n+3}
\end{pmatrix} + h^3 \begin{pmatrix*}[r]
0 & 0 & 0 & \frac{1}{160} \\
0 & 0 & 0 & \frac{31}{8748} \\
0 & 0 & 0 & -\frac{13}{224} \\
0 & 0 & 0 & -\frac{451}{1440}
\end{pmatrix*} \begin{pmatrix}
f_{n-3} \\
f_{n-2} \\
f_{n-1} \\
f_n
\end{pmatrix} \nonumber %\eqno{(25)}
\end{aligned}
\end{equation}
\bigskip

\begin{equation}\label{eq26}
\begin{aligned}
& \begin{pmatrix*}[r]
3 & -3 & 0 & 1 \\
\mfrac{16}{9} & -\mfrac{20}{9} & 1 & 0 \\
-2 & \mfrac{1}{2} & 0 & 0 \\
2 & -1 & 0 & 0
\end{pmatrix*} \begin{pmatrix*}
y_{n+1} \\
y_{n+2} \\
y_{n+\frac{8}{3}} \\
y_{n+3}
\end{pmatrix*}
= \begin{pmatrix*}[r]
0 & 0 & 0 & 1 \\
0 & 0 & 0 & \mfrac{5}{9} \\
0 & 0 & 0 & -\mfrac{3}{2} \\
0 & 0 & 0 & 1
\end{pmatrix*} \begin{pmatrix*}
y_{n-3} \\
y_{n-2} \\
y_{n-1} \\
y_n
\end{pmatrix*} \\ \nonumber
&+
h^3 \begin{pmatrix*}[r]
\mfrac{47}{100} & \mfrac{23}{40} & -\mfrac{81}{800} & \mfrac{1}{20} \\
\mfrac{7}{27} & \mfrac{203}{729} & -\mfrac{25}{324} & \mfrac{65}{2187} \\
\mfrac{1399}{4200} & -\mfrac{23}{168} & \mfrac{783}{5600} & -\mfrac{17}{2800} \\ -\mfrac{109}{120} & \mfrac{61}{120} & -\mfrac{81}{160} & \mfrac{79}{360}
\end{pmatrix*} \begin{pmatrix}
f_{n+1} \\
f_{n+2} \\
f_{n+\frac{8}{3}} \\
f_{n+3}
\end{pmatrix} + h^3 \begin{pmatrix*}[r]
0 & 0 & 0 & \mfrac{1}{160} \\
0 & 0 & 0 & \mfrac{31}{8748} \\
0 & 0 & 0 & -\mfrac{13}{224} \\
0 & 0 & 0 & -\mfrac{451}{1440}
\end{pmatrix*} \begin{pmatrix}
f_{n-3} \\
f_{n-2} \\
f_{n-1} \\
f_n
\end{pmatrix} \nonumber %\eqno{(25)}
\end{aligned}
\end{equation}

\end{document} 

enter image description here

4

With considering the mathtools package you equation can be written as follows:

\documentclass{article}
\usepackage{geometry}           % <---
\usepackage{mathtools}          % <---

\begin{document}
\begingroup                     % <---
\renewcommand\arraystretch{1.3} % <---
    \begin{multline*}           % <---
\begin{pmatrix*}{r}             % <---       
3               & -3            & 0 & 1 \\
\frac{16}{9}    & -\frac{20}{9} & 1 & 0 \\
-2              &  \frac{1}{2}  & 0 & 0 \\
2               & -1            & 0 & 0
\end{pmatrix*}\begin{pmatrix}
                y_{n+1}             \\
                y_{n+2}             \\
                y_{n+\frac{8}{3}}   \\
                y_{n+3}
              \end{pmatrix} = \begin{pmatrix*}{r}
                                0 & 0 & 0 & 1               \\
                                0 & 0 & 0 &  \frac{5}{9}    \\
                                0 & 0 & 0 & -\frac{3}{2}    \\
                                0 & 0 & 0 & 1
                               \end{pmatrix*}\begin{pmatrix}
                                                y_{n-3} \\
                                                y_{n-2} \\
                                                y_{n-1} \\
                                                y_n
                                             \end{pmatrix}   \\
%
+ h^3 \begin{pmatrix*}{r}
 \frac{47}{100}     &   \frac{23}{40}   & -\frac{81}{800}   &  \frac{1}{20}     \\
 \frac{7}{27}       &   \frac{203}{729} & -\frac{25}{324}   &  \frac{65}{2187}  \\
 \frac{1399}{4200}  & -\frac{23}{168}   & \frac{783}{5600}  & -\frac{17}{2800}  \\            -\frac{109}{120}   &  \frac{61}{120}   & -\frac{81}{160}   & \frac{79}{360}
\end{pmatrix*}\begin{pmatrix}
                f_{n+1}             \\
                f_{n+2}             \\
                f_{n+\frac{8}{3}}   \\
                f_{n+3}
             \end{pmatrix} + h^3 \begin{pmatrix*}{r}
                        0 & 0 & 0 & \frac{1}{160}       \\
                        0 & 0 & 0 & \frac{31}{8748}     \\
                        0 & 0 & 0 & -\frac{13}{224}     \\
                        0 & 0 & 0 & -\frac{451}{1440}
                        \end{pmatrix*}\begin{pmatrix}
                                        f_{n-3}     \\
                                        f_{n-2}     \\
                                        f_{n-1}     \\
                                        f_n
                                     \end{pmatrix}.
    \end{multline*}
\endgroup
\end{document}

enter image description here

(red lines indicate text borders)

  • more spaces between matrix rows is obtained by \renewcommand\arraystretch{1.3} which is put before equation (it is limited to the equation by forming group for this equation).
  • instead arrays are used {pmatrix*}{r} from mathtools. it enable dhorter writing of matrices as well number in them are right aligned
  • instead of aligned is used multline˛
0

I just added the [0.25em] after \\:

\frac{16}{9} & -\frac{20}{9} & 1 & 0 \\ [0.25em]

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.