2

It is common in literature to encounter the diagonal symbol when referring to matrices. For instance, if matrix A is diagonal, it can be denoted as [\A] where the "\" symbol is crossing the letter "A" from the upper left to the lower right corner.

Is there any way to do this in LaTeX (maybe by the use of any particular package)?

An example of what I am intending to do can be seen on the picture below.

enter image description here

1
  • 2
    eeuw those are big backslashes. if a matrix is diagonal write diag. and no this is not common in matrix algebra field. Maybe at other fields actually i never saw these before.
    – percusse
    Oct 1, 2015 at 20:28

2 Answers 2

6

Here's one option using the tikzmark library to define a command (using the optional argument one can control the vertical size):

enter image description here

The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\newcounter{mydiagm}

\newcommand\DiagMat[2][1]{
\stepcounter{mydiagm}
\begin{bmatrix}
\tikzmark{start-\themydiagm}\rule{1cm}{0pt}\\[#1\normalbaselineskip]\hfill\tikzmark{end-\themydiagm}
\end{bmatrix}
\tikz[remember picture,overlay]
\draw ([yshift=1ex]pic cs:start-\themydiagm) -- node[fill=white,inner sep=2pt] {$#2$} (pic cs:end-\themydiagm);%
}
\begin{document}

\begin{equation*}
\DiagMat{c^{2}}\frac{\partial C_{l}}{\partial C_{T}}
\end{equation*}

\begin{equation*}
\DiagMat[2]{ce}
\begin{bmatrix}
a \\ b \\ c \\ d
\end{bmatrix}
\end{equation*}

\end{document}

The code needs two or three runs for the rule to reach its final position.

4

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}

\newcommand{\mydiag}[1]{\left[%
\begin{array}{@{}c@{}c@{}c@{}}
\diagdown &    & \\
          & #1 & \\
          &    & \diagdown
\end{array}\right]
}
\begin{equation}
\mydiag{ce}
\end{equation}

\begin{equation}
\mydiag{c^2}
\end{equation}

\end{document}

There is a \diagdown symbol from amssymb which you can use in this case.

You must log in to answer this question.

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