Trace in LaTeX (\text{tr}(A))

tr(A)\text{tr}(A)
LaTeX command
\text{tr}(A)
Package
Add to your preamble:\usepackage{amsmath}
Mode
Text and math mode

Where it is used

Trace of A, the sum of its diagonal entries, written with an upright 'tr' label.

The trace appears in identities like \operatorname{tr}(AB) = \operatorname{tr}(BA) and in the Frobenius norm \lVert A \rVert_F^2 = \operatorname{tr}(A^{\top}A). Using \text{tr} gets upright letters, but it inherits the surrounding text font, turning italic inside a theorem, and adds no operator spacing. The sturdier choice is \operatorname{tr}, or a global \DeclareMathOperator{\tr}{tr} in the preamble, so \tr A spaces correctly without parentheses. Physicists often write Tr with a capital, especially for density matrices. The trace also equals the sum of the eigenvalues counted with multiplicity.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

tr(A)=∑i=1naii\text{tr}(A) = \sum_{i=1}^{n} a_{ii}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Trace: $\text{tr}(A)$

\[ \text{tr}(A) = \sum_{i=1}^{n} a_{ii} \]
\end{document}

Related symbols

All 線形代数 →

Frequently asked questions

How do I write Trace in LaTeX?
Type \text{tr}(A) in math mode, for example $\text{tr}(A) = \sum_{i=1}^{n} a_{ii}$. Load amsmath first with \usepackage{amsmath}.
Which package do I need for \text{tr}(A)?
\text{tr}(A) needs amsmath: add \usepackage{amsmath} to your preamble before the document starts.
Can I use \text{tr}(A) in text mode, or only in math mode?
Both. \text{tr}(A) compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredAIでLaTeXを書く

最高のAI LaTeXエディタ、Overleaf代替

Octreeは15以上の大学の研究者がAIを使って論文をより速く書くのを支援

  • AIで美しいTikZダイアグラムを生成
  • 画像をアップロードしてシームレスにLaTeXに変換
  • 論文の執筆とフォーマットに即座にサポートを取得