1

I am trying to place a row vector notation inside a matrix where all other elements are numeric values. I want to insert 1X2 vectors in-between numbers. I am not satisfied with what my code produced. I am posting an MWE with my code and what I got from it below.

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
$M = \begin{bmatrix} 0 & \text{---}\mathbf{a}\text{---} & & 0 & 0\\
0 & \text{---}\mathbf{b}\text{---} & & 0 & 0\\
1 & 2 & 3 & 4 & 0\\
5 & 6 & 7 & 0 & 0\\
0 & 0 & 8 & 9 & 0
\end{bmatrix}$
\end{document}

enter image description here

The lines are too much on the left side and the blank in the 3rd column is looking bad. Is it possible to move the "--a--" and "--b--" slightly to the right?? I tried to put '-' in the 3rd column instead of blank, but it looks like a separate line.

1 Answer 1

2

I guess that you like to write your matrix as follows:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$M = \begin{bmatrix} 
0 & \multicolumn{2}{c}{~\mathbf{a}~} 
                    & 0 & 0\\
0 & \multicolumn{2}{c}{\mathbf{b}}
                    & 0 & 0\\
1 &         2   & 3 & 4 & 0\\
5 &         6   & 7 & 0 & 0\\
0 &         0   & 8 & 9 & 0
\end{bmatrix}$
\end{document}

enter image description here

1
  • It worked. Nice idea using \multicolumn within mathmode. Inside my article first two and last two columns looked a little congested, but after adding ~ before the entries, it worked perfectly. May 11, 2021 at 3:16

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.