How to put fixed-height shading around text (inline)?

I have a chunk of code in an alltt environment and I want to highlight elements that are auto-generated (two colours for different methods):

\newcommand{\gen}[1]{\colorbox{DGray}{#1}}
\newcommand{\tpl}[1]{\colorbox{Gray}{#1}}

\begin{alltt}
\gen{class }\tpl{Something}...
\end{alltt}


My problem is that the frame around 'Something' is taller than the one around 'class ' and reaches lower due to the letter 'g', so the two frames aren't aligned. Is there a way to make a shading frame with a fixed height and position? Basically, I want shading the OpenOffice/MS Office way.

-

You can use \strut:

\newcommand{\gen}[1]{\colorbox{DGray}{\strut #1}}
\newcommand{\tpl}[1]{\colorbox{Gray}{\strut #1}}


or a \vphantom with some appropriate letters:

\newcommand{\gen}[1]{\colorbox{DGray}{\vphantom{Ag}#1}}
\newcommand{\tpl}[1]{\colorbox{Gray}{\vphantom{Ag}#1}}


or, to have even finer control, a \rule with the desired height and depth, and zero width:

\newcommand{\gen}[1]{\colorbox{DGray}{\rule[-6pt]{0pt}{16pt}#1}}
\newcommand{\tpl}[1]{\colorbox{Gray}{\rule[-6pt]{0pt}{16pt}#1}}

-