149

I am new to Latex, and I have been trying to get the matrix of following form

    [x11 x12 x13 . . . . x1n
     x21 x22 x23 . . . . x2n
     .
     .
     .
     .
     xd1 xd2 xd3 . . . . xdn]

Where the letters accompanying the elements are subscripts '11 12 13' etc. I tried it in the following fashion

    $$
    \begin{bmatrix} 
    x_{11}&x_{12}&x_{13}&.&.&.&.&x_{1n}

And so on in similar fashion. I get errors when I use the above method and I know its amateurish. Can you please tell me how to get it done the right way? I even tried including '\' for the periods. Thanks in advance.

2
  • 7
    @pushpen.paul Why is that? It gives proper context.
    – percusse
    Commented Oct 5, 2014 at 9:11
  • this is very important \usepackage(asmath) do not forget this. Commented Apr 28 at 22:43

2 Answers 2

218

You must read at least lshort (page 58) or amsldoc.pdf Section 4 (page 12).

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{bmatrix}
    x_{11}       & x_{12} & x_{13} & \dots & x_{1n} \\
    x_{21}       & x_{22} & x_{23} & \dots & x_{2n} \\
    \hdotsfor{5} \\
    x_{d1}       & x_{d2} & x_{d3} & \dots & x_{dn}
\end{bmatrix}
=
\begin{bmatrix}
    x_{11} & x_{12} & x_{13} & \dots  & x_{1n} \\
    x_{21} & x_{22} & x_{23} & \dots  & x_{2n} \\
    \vdots & \vdots & \vdots & \ddots & \vdots \\
    x_{d1} & x_{d2} & x_{d3} & \dots  & x_{dn}
\end{bmatrix}
\]
\end{document}

enter image description here

2
  • 6
    As an extension of this answer, a nice place to see the different matrix visuals is here: latex.wikia.com/wiki/Matrix_environments
    – TobyStack
    Commented Feb 9, 2018 at 14:27
  • 1
    It's a good site, however I didn't see nothing about ellipsis in the matrix
    – skpblack
    Commented Feb 9, 2018 at 14:32
24

From the link @TobyStack gave:

I don't use the document/array package because I'm not very experienced.

new row:\\ (btw, you can use that for $\displaystyle\sum_{j=0\\j\ne i}^m\sum_{i=0}^n$) output: enter image description here

new column: &

Also, use

    line:     \ldots 
    diagonal: \ddots 
    vertical: \vdots

output:enter image description here

Depending on your preference:

    brackets: \begin{bmatrix}\end{bmatrix}
    parentheses: \begin{pmatrix}\end{pmatrix}

Screenshoot:enter image description here

1
  • 1
    The baseline spacing of the lower limit is a bit large. You might take a look at substack, provided by amsmath, which should tighten things up a bit. Commented Jan 5, 2020 at 16:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .