How can I draw a matrix with dots in tex like the one shown below:
2 Answers
I suggest you load the amsmath
package, employ its the bmatrix
("bracketed matrix") environment, and use \dots
(or \ldots
), \vdots
("vertical dots"), and \ddots
("diagonal dots") as needed.
The following screenshot shows two ways this approach could be employed. The first replicates the matrix shown in the OP's posting. The second shows that this method can be used for square as well as non-square matrices.
\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' environment
\begin{document}
\[
A = \begin{bmatrix}
a_{11} & a_{12} & \dots \\
\vdots & \ddots & \\
a_{K1} & & a_{KK}
\end{bmatrix}
\qquad
B = \begin{bmatrix}
b_{11} & \dots & b_{1M}\\
\vdots & \ddots & \vdots\\
b_{K1} & \dots & b_{KM}
\end{bmatrix}
\]
\end{document}
-
2
-
5@Meysam --
\[
is LaTeX code to initiate an unnumbered display-math environment, and\]
is LaTeX code to terminate this environment. Please check out the posting What are the differences between$$
,\[
,align
,equation
anddisplaymath?
for more information on the subject of TeX and LaTeX display-math environments.– MicoSep 3, 2016 at 12:07 -
\cdots
might be more appropriate than\dots
, depending what look exactly you're going for. Oct 12, 2022 at 17:04 -
@TheZachMan - As a typographic ellipsis,
\cdots
is generally used only as the connector between (explicit or implicit) binary operators. E.g.,a_1+a_2+\cdots+c_n
, orb_1 b_2 \cdots b_T
. Plus, there's the multIple integration case:\int\int\cdots\int
. I don't think that that's the impression one wants to create for "gaps" in a row of a matrix. Hence, I'm comfortable with using\dots
(or\ldots
) for the matrices at hand.– MicoOct 12, 2022 at 17:15 -
I think it's appropriate since it matches the centering of
\vdots
and\ddots
, but fair enough. Oct 12, 2022 at 17:16
For information, here is what you can do with {bNiceMatrix}
with nicematrix
.
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[\NiceMatrixOptions{xdots/shorten=0.5em}
A = \begin{bNiceMatrix}
a_{11} & a_{12} & \Ldots \\
\Vdots & \Ddots & \\
a_{K1} & & a_{KK}
\end{bNiceMatrix}
\qquad
B = \begin{bNiceMatrix}
b_{11} & \Ldots & b_{1M}\\
\Vdots & \Ddots & \Vdots\\
b_{K1} & \Ldots & b_{KM}
\end{bNiceMatrix}\]
\end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes under the hood).
\dots
\vdots
\ddots
plusbmatrix
env