3

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

green stuff http://i68.tinypic.com/28mmu7p.png

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)\)
3

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}

enter image description here

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

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.