I'm searching for a way to avoid the following layout (image below) where the underscore and the lower case letters get tightened inside the tcbox : ideally, I'd like the tcbox to keep a height that would be equal to something like 1em or 1.2em in order to keep consistancy across those boxes inside my document.

The box I've got with uppercase letters or digits (see image below) are just nice but my code seems to fit the box to its content rather than to the font's max height inside the current size.

Right now, the code looks like this :

% inline code blocks
\newtcbox{\code}{on line, boxrule=0pt, boxsep=0pt, top=2pt, left=2pt,
bottom=2pt, right=2pt, colback=gray!30, colframe=white,

I looked up into the tcbox manual but couldn't find the correct parameter to enter (I know it's there somewhere).

I don't like how the underscore is tightened inside tcbox

Edit (getting close)

Thanks to the commenters :

Adding the \strut command made the boxes bigger, but now they're too big (probably because of the line spacing, which is mandatory according to my university so I can't change that) : even upper cases and digits get some extra space (see image below)

enter image description here

  • Since you did not provide example code, I can't try it, but would adding a \strut suffice? As in fontupper={\ttfamily\small\strut}? Sep 22, 2021 at 11:43
  • For this simple type of color boxes, hope \setlength{\fboxsep}{0pt}\colorbox{black!10}{...text...} is enough, I think so...
    – MadyYuvi
    Sep 22, 2021 at 12:23
  • @StevenB.Segletes Waow ! We're getting close but now it's too big ^^' I've edited the post according to it. I tried the other solution but it doesn't work as I'd like it to.
    – Etsaf
    Sep 22, 2021 at 12:59
  • 1
    Then use \mystrut, where you define \mystrut the height you want, for example, \newcommand\mystrut{\rule[-3pt]{0pt}{12pt}}. Sep 22, 2021 at 14:19
  • 1
    Thaks a lot @StevenB.Segletes that worked smoothly! I jut had to twick a little bit but verything is cool now ^^ >> \newcommand\mystrut{\rule[-1pt]{0pt}{.8em}}
    – Etsaf
    Sep 22, 2021 at 16:57

1 Answer 1


Posting the solution from comments

Creating a new command to emulate a strut of a different height was the way to go, thanks :-)

% inline code blocks

\newtcbox{\code}{on line, boxrule=0pt, boxsep=0pt, top=2pt,
left=2pt, bottom=2pt, right=2pt, colback=gray!25, colframe=white,

Output below : lower cases and underscore do get the same height than everything else.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .