# Off Diagonal matrix

How to write off diagonal matrix in latex? I tried this

 \begin{align*}
\left[
\begin{array}{ccccc}
&  &  &  & 1 \\
&  &  & \ldots  \\
1 &  &  &  &
\end{array}
\right]
\end{align*}

• Welcometo TeX.SE.
– mmr
Commented Dec 8, 2021 at 5:05

You can use the bmatrix environment from amsmath to typeset the matrix, and the command \iddots from the package mathdots for the dots.

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathdots}
\begin{document}
$R_n = \begin{bmatrix} & & 1 \\ & \iddots & \\ 1 & & \end{bmatrix}$
\end{document}


This could be a solution with less code and beauty:

\documentclass{article}

\usepackage{mathdots} % http://ctan.org/pkg/mathdots

\begin{document}

$R_n = \left[ \begin{array}{ccccc} & & & & 1 \\ & & \iddots & & \\ 1 & & & & \end{array} \right]$

\end{document}


Output:

## Update

Similar types of dots can be found: \iddots from mathdots, \adots from yhmath or \reflectbox{$\ddots$} from the graphicx package.

Check this out:

\documentclass{article}

\usepackage{mathdots}
\usepackage{yhmath}
\usepackage{graphicx}
\usepackage{MnSymbol}

\begin{document}
Different types of diagonal dots:

$\begin{array}{ll} \verb!\ddots! & \ddots \\ \verb!\udots! & \udots \\ \verb!\iddots! & \iddots \\ \verb!\adots! & \adots \\ \verb!\reflectbox{\ddots}! & \reflectbox{\ddots} \end{array}$

\end{document}


Snippet:

This could be more nicer using nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
\begin{equation*}
R_n =\begin{bNiceMatrix}
&    &          & 1 \\
&    & \Iddots  &   \\
&    &          &   \\
1  &    &          &
\end{bNiceMatrix}
\end{equation*}
\end{document}


Output:

• In LaTeX document don't use TeX syntax  . Commented Dec 8, 2021 at 6:03
• @Zarko Corrected.
– mmr
Commented Dec 8, 2021 at 6:06
• @zarko you can use nicematrix😃 Commented Dec 8, 2021 at 6:43
• @Sebastiano, this cross my mind, but today is not my day :-(. Please be so kind and wrote an answer with nicematrix Commented Dec 8, 2021 at 8:30
• @mmr, no, it is OK. On the same way as you write answer author of the package. Commented Dec 8, 2021 at 16:24

Here is what you can do with {bNiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{align*}
\begin{bNiceArray}{cccc}
&  &         & 1 \\
&  & \Iddots     \\
\\
1 \\
\end{bNiceArray}
\end{align*}

\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

• Great prof. You have a good day Commented Dec 8, 2021 at 12:32