# How to create this matrix in LaTeX?

I want to create the following picture in LaTeX. How can I do this?

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer Apr 27 '14 at 12:34
You can also start searching for on this site –  percusse Apr 27 '14 at 12:42
which site exactly? How can i search something like this in this site?! –  tanha Apr 27 '14 at 12:52
@tanha, on the top, there is a search field. See the black bar on the top. –  Sigur Apr 27 '14 at 12:52
How to create Toeplitz matrix in Latex ? –  tanha Apr 28 '14 at 8:14

## 3 Answers

Hope this will serve as a starting point for the OP to learn. Here the proposal uses array where you specifies how many columns you need, for example, by using cccc for 4 columns centered, and then separate each column by & and ends the line by \.

Code

\documentclass[12pt]{article}
\usepackage[margin=1cm,paper size={15cm,8cm}]{geometry}
\usepackage{amsmath,amssymb}
\thispagestyle{empty}
\begin{document}

$\begin{array}{lccccccccccccc} m: & & & 0 & 0 & 0 & 0 & 1 &0 &0 & 0 & 0 & & \\ d(1)=0 &-1 & 2 & 1 & & & & & & & & & & \\ d(2)=0 & & &-1 & 2 & 1 & & & & & & & & \\ d(3)=0 & & & &-1 & 2 & 1 & & & & & & & \\ \ldots\ldots & & & & & & & \ldots & & & & \\ d(5)=1 & & & & & & & &\ldots & & & & & \\ \ldots\ldots & & & & & & & & & \ldots & &\\ d(11)=0 & & & & & & & & & & & -1 & 2 & 1 \\ \end{array}$

\end{document}


Edit: Recommended by barbara beeton, a flush right solution.

Code:

\documentclass[12pt]{article}
\usepackage[margin=1cm,paper size={16cm,8cm}]{geometry}
\usepackage{amsmath,amssymb}
\thispagestyle{empty}
\begin{document}

$\begin{array}{lrrrrrrrrrrrrr} m: & & & 0 & 0 & \phantom{-}0 & \phantom{-}0 & 1 &0 &0 & \phantom{-}0 & 0 &&\\ d(1)=0 &-1 & \phantom{-}2& 1 & & & & & & & & && \\ d(2)=0 & & &-1 & 2 & 1 & & & & & & & & \\ d(3)=0 & & & &-1 & 2 & 1 & & & & & & & \\ \ldots\ldots & & & & & & & \ldots& & && \\ d(5)=1 & & & & & & & &\ldots & & & && \\ \ldots\ldots & & & & & & & & & \ldots & &\\ d(11)=0 & & & & & & & & & & & -1 & \phantom{-}2 & \phantom{-}1 \\ \end{array}$

\end{document}

-
since some of the entries in the cells are negative, i'd be inclined to set the columns flush right rather than centered. –  barbara beeton Apr 27 '14 at 19:24
Noted and added, thanks for the tips. –  Jesse Apr 27 '14 at 22:16
How to create Toeplitz matrix in Latex ? –  tanha Apr 28 '14 at 8:15

The hardest part is getting equal sized columns:

\documentclass{article}
\usepackage{array,collcell}
\newcommand{\two}[1]{\makebox[1.5em][r]{$#1$}}
\newcommand{\Ldots}{\dots\dots\hspace*{-1em}}

\begin{document}
$\setlength{\arraycolsep}{0pt} \begin{array}{l @{\quad} *{13}{>{\collectcell\two}c<{\endcollectcell}}} \quad m & & & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\[1ex] d(1)=0 & -1 & 2 & 1 \\ d(2)=0 & & & -1 & 2 & 1 \\ d(3)=0 & & & & & -1 & 2 & 1 \\ \dots & & & & & & \Ldots \\ d(5)=1 & & & & & & & & \Ldots \\ \dots & & & & & & & & & & \Ldots \\ d(11)=0 & & & & & & & & & & & -1 & 2 & 1 \end{array}$
\end{document}


-
the dotted entries in the columns to the right appear in the original to "join" two columns rather than be centered on just one column. maybe \mathllap from the rightmost affected column would produce that result. –  barbara beeton Apr 27 '14 at 19:27

You could use two array environments, with the second one containing thirteen columns, and use \phantom instructions in the first row of the second array to get equal-width columns. If you want the "dots" placed on the baseline instead of centered vertically, use \dots instead of \cdots.

\documentclass{article}
\begin{document}
$\begin{array}{@{}l} m:\\ d(1)=0\\ d(2)=0\\ d(3)=0\\ \cdots\\ d(5)=0\\ \cdots\\ d(11)=0 \end{array} \quad \setlength\arraycolsep{2pt} % default value: 5pt \begin{array}{*{13}{r}} \phantom{-0} & \phantom{-0} & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}1 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-0} & \phantom{-0} \\ -1 & 2 & 1\\ & & -1 & 2 & 1\\ & & & -1 & 2 & 1\\ & & & & \multicolumn{3}{c}{\cdots}\\ & & & & & \multicolumn{3}{c}{\cdots}\\ & & & & & & & \multicolumn{3}{c}{\cdots}\\ & & & & & & & & & & -1 & 2 & 1\\ \end{array}$
\end{document}

-