# Text under equation

I'm trying to achieve which can be best described from this picture:

I want to be able to write the green text and line under my equation (it's exactly this equation actually) but how do I do that? All I have at the moment is:

\noindent read stall cycles = $$\displaystyle \frac{reads}{program}\ *\ read\ miss\ rate\ (\%)\ *\ read\ miss\ penalty\ (cycles)$$

• \underbrace{foo}_{\text{read miss per program}}, for example – user31729 Mar 2 '16 at 20:11
• Something is wrong with the (vertical) alignment of what you display... unless you placed the content in the image manually. – Werner Mar 2 '16 at 20:14
• Thanks, that was what I was looking for. I didn't know it was called underbrace – Nubcake Mar 2 '16 at 20:31

Just for fun (this may not be the optimal way of doing this):

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[usenames]{color}
\definecolor{cyan}{rgb}{0,1,1}
\newcommand{\cyan}[1]{\textcolor{cyan}{#1}}
\definecolor{black}{rgb}{0,0,0}
\newcommand{\black}[1]{\textcolor{black}{#1}}

\begin{document}

$\text{read stall cycles} = \cyan{\underbrace{\black{\frac{\text{reads}}{\text{program}} \times \parbox{48pt}{read miss \\ rate (\%)}}}_{\text{read miss per program}}} \times \cyan{\underbrace{\black{\parbox{76pt}{read miss \\ penalty (cycle)}}}_{\parbox{62pt}{\scriptsize\centering number of cycles \\ per read miss}}}$

\end{document}


• Wow that looks really better than what I have :D Thanks ! – Nubcake Mar 2 '16 at 20:37

Judicious color changing solves the problem, together with some definitions for “textual fractions”:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\definecolor{underbrace}{RGB}{30,199,166}

\newcommand{\textfrac}[1]{%
\begin{tabular}{@{}l@{}}#1\end{tabular}%
}

\begin{document}
$\colorlet{currentcolor}{.} \text{read stall cycles}= \textcolor{underbrace}{% {\underbrace{% \textcolor{currentcolor}{% \textfrac{reads\\\hline program} \times \textfrac{read miss\\[\arrayrulewidth]rate (\%)} } }_{\text{read miss per program}} } } \times \textcolor{underbrace}{% {\underbrace{% \textcolor{currentcolor}{% \textfrac{read miss\\[\arrayrulewidth]penalty (cycle)} } }_{\substack{\text{number of cycles}\\\text{per read miss}}} } }$

\end{document}