# Stacking words above of a summation symbols [duplicate]

For this equation:

P_{\lambda \sigma} = 2 \sum\limits_{i}^{\hbox{occupied  molecular  orbitals} } c_{\lambda i} c_{\sigma i}


I want the words "occupied molecular orbitals" stacked 3 high. I tried \vbox, but that did not work.

• what do you mean with "stacked 3 high"? – naphaneal Sep 27 '16 at 18:08

## \substack

A solution with amsmath' macro \substack:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$P_{\lambda \sigma} = 2 \sum\limits_{i}^{ \substack{\text{occupied}\\\text{molecular\vphantom{p}}\\\text{orbitals}} } c_{\lambda i} c_{\sigma i}$
\end{document}


The purpose of \vphantom is the better line spacing.

## tabular

Also a tabular works:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$P_{\lambda \sigma} = 2 \sum\limits_{i}^{ \text{\scriptsize \begin{tabular}{@{}c@{}}occupied\\molecular\\orbitals\end{tabular}% } } c_{\lambda i} c_{\sigma i}$
\end{document}


## \mathclap

Macro \mathclap lies to TeX, that its contents does not have width. Therefore, it can be used to place the superscript without affecting the horizontal spacing below:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$P_{\lambda \sigma} = 2 \sum\limits_{i}^{ \mathclap{% \substack{\text{occupied}\\\text{molecular\vphantom{p}}\\\text{orbitals}} }% } c_{\lambda i} c_{\sigma i}$
\end{document}


## plain TeX

P_{\lambda \sigma} = 2 \sum\limits_{i}^{ \hbox to 0pt{% \hss \vbox{% \sevenrm \baselineskip=8pt \halign{\hss#\hss\cr occupied\cr molecular\cr orbitals\cr}% }\hss } } c_{\lambda i} c_{\sigma i}

\bye


• There's also \smashoperator from mathtools. – Manuel Sep 27 '16 at 18:28

Instead of placing the string "occupied molecular orbitals" above the \sum symbol, I'd place it below the symbol and group it with the i summation index.

\documentclass{article}
\usepackage{mathtools} % for "\smashoperator" macro
\begin{document}
$P_{\lambda\sigma} = 2 \smashoperator{\sum_{\substack{ i\in\text{\,occupied}\\ \text{molecular}\mathstrut\\ \text{orbitals}\mathstrut}}} c_{\lambda i} c_{\sigma i}$
\end{document}


Perhaps a \Longstack in \scriptsize.

\documentclass{article}
\usepackage{stackengine}
\begin{document}
$P_{\lambda \sigma} = 2 \sum\limits_{i}^{\scriptsize\Longstack{occupied molecular orbitals} } c_{\lambda i} c_{\sigma i}$
\end{document}


If you didn't want the spacing of the text to affect the surrounding math, add a \mathclap

\documentclass{article}
\usepackage{stackengine,mathtools}
\begin{document}
$P_{\lambda \sigma} = 2 \sum\limits_{i}^{\mathclap{\scriptsize\Longstack{occupied molecular orbitals} }} c_{\lambda i} c_{\sigma i}$
\end{document}


the \substack from amsmath is another way of approaching this.

because there are no descenders on the second and third lines, a \mathstrut is added to keep the lines a constant distance apart.

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\thispagestyle{empty}
$P_{\lambda \sigma} = 2 \sum_{i}^{\substack{\text{occupied}\\ \mathstrut\text{molecular}\\ \mathstrut\text{orbitals}}} c_{\lambda i} c_{\sigma i}$
\end{document}