Sum Over Classes in LaTeX (\sum_{c=1}^{C})
- LaTeX command
\sum_{c=1}^{C}- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Summation over classes c from 1 to C, as used in multi-class losses and probability normalization.
Sums over classes appear in the categorical cross-entropy, -\sum_{c=1}^{C} y_c \log \hat{y}_c, and in the softmax denominator. In display math the limits go above and below the large sigma; inline they sit to the right in smaller type, which saves line height. Force the display placement inline with \sum\limits, or the reverse with \nolimits. Using C for the number of classes and c for the index is a common convention; just do not reuse C for a cost or constant in the same equation. The symbol \Sigma is a Greek letter and should not replace \sum.
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
Sum Over Classes: $\sum_{c=1}^{C}$
\[ \mathcal{L} = -\sum_{c=1}^{C} y_c \log \hat{y}_c \]
\end{document}Related symbols
- Product Over Samples
\prod_{i=1}^{N} - Conditional Probability
p(y | x) - L1 Norm
\| \theta \|_1 - Probability Distribution
p(x) - L2 Norm
\| \theta \|_2 - Log Likelihood
\log p(x | \theta)
Frequently asked questions
- How do I write Sum Over Classes in LaTeX?
- Type \sum_{c=1}^{C} in math mode, for example $\mathcal{L} = -\sum_{c=1}^{C} y_c \log \hat{y}_c$. It works in plain LaTeX without loading any package.
- Which package do I need for \sum_{c=1}^{C}?
- None. \sum_{c=1}^{C} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \sum_{c=1}^{C} in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\sum_{c=1}^{C}$ in running text.
أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf
يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي
- أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
- ارفع صورة وحولها إلى LaTeX بسلاسة
- احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث