3

Is there a LaTeX command to indicate one is referring to the elements of a matrix diagonal? Something like \diag{X}? It seems like this must exist but I cannot find it (search terms too common in multiple contexts).

Note: I don't want to display the matrix in any way, just refer to the diagonal.

4
  • 2
    How about \documentclass{article} \usepackage{amsmath} \DeclareMathOperator{\diag}{diag} \begin{document} $A=\diag(a_1,\dots,a_n)$ \end{document}?
    – user255043
    Commented Nov 3, 2021 at 1:43
  • This would work, thank you. Since you answered this way I guess there is not a built-in version in some package (?) Commented Nov 3, 2021 at 2:03
  • 1
    I do not know if there is a package but it does not seem to be part of amsmath nor mathtools. It is not unusual that one has to define some math operators oneself but of course there could be a not too harmful package that does that for you.
    – user255043
    Commented Nov 3, 2021 at 2:15
  • +1 "not too harmful package" great phrase. Glad to accept if you want to move your comment to an answer. Commented Nov 3, 2021 at 2:22

1 Answer 1

7

One thing that one always can do is to define the math operators one needs using \DeclareMathOperator. For example, for \diag one could use

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\diag}{diag}
\begin{document}
$A=\diag(a_1,\dots,a_n)$
\end{document}

P.S. I personally would hesitate to load a package just in order to avoid defining one operator. In particular, I do not recommend the physics package (yet this one does not seem to define \diag anyway).

You must log in to answer this question.

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