[Tex/LaTex] Set \strut height

boxescolorheightstrut

I'm using quite a few \colorbox and \colorfbox in a document but they weren't sitting at the same heights (because some words contained g and this seemed to push the box down.

The solution I found (in another stackoverflow question actually) was to use \strut.

Only problem with that is that it defaulted to being very high.

I couldn't figure out how to shrink the height (I'm very new to Latex) and was wondering if there's a simple way to specify the height of the \strut command?

For example I have \colorbox{newredred}{{\color{white}{\strut\tt fun}}}.

Is what I'm asking possible? Please remember, I'm very new to LaTeX and don't really understand much about the renewing commands or setting custom commands.

Best Answer

For example : #1 the height #2 the depth

\def\mystrut(#1,#2){\vrule height #1pt depth #2pt width 0pt}   

example :

\documentclass{scrartcl}

\begin{document}   
  \def\mystrut(#1,#2){\vrule height #1pt depth #2pt width 0pt}    
  \fbox{\mystrut(18,10) qk}  
\end{document}

enter image description here