Trace in LaTeX (\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.
\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.
أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf
يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي
- أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
- ارفع صورة وحولها إلى LaTeX بسلاسة
- احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث