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}
- 506,678
-
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,equationanddisplaymath?for more information on the subject of TeX and LaTeX display-math environments. – Mico Sep 03 '16 at 12:07 -
\cdotsmight be more appropriate than\dots, depending what look exactly you're going for. – The Zach Man Oct 12 '22 at 17:04 -
@TheZachMan - As a typographic ellipsis,
\cdotsis 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. – Mico Oct 12 '22 at 17:15 -
I think it's appropriate since it matches the centering of
\vdotsand\ddots, but fair enough. – The Zach Man Oct 12 '22 at 17:16 -
@TheZachMan - By your argument, there could never be a use case for
\ldotsin a matrix. That can't be quite right, can it? – Mico Oct 12 '22 at 17:20
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).
- 40,250



\dots\vdots\ddotsplusbmatrixenv – daleif Sep 03 '16 at 11:38