I have implemented the suggestions from this thread using a tcolorbox to highlight inline with rounded corners.
I've noticed that the box has vertical margins I am unable to remove, and it pushes the lines before and after it further away.
MVE as follows:
\documentclass[]{article}
\usepackage[most]{tcolorbox}
\usepackage{relsize}
\definecolor{kode-color}{RGB}{240,240,240}
\newcommand{\codesize}{\smaller[0.75]}
\newcommand{\kode}[1]{%
\tcbox[on line,
show bounding box,
boxsep=4pt,
left=0pt, right=0pt, top=0pt, bottom=0pt,
colframe=white,colback=kode-color
]{\texttt{\codesize #1}}%
}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea \kode{commodo consequat} duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}
Any idea how to avoid it?
I'm not so keen on using tcolorbox, as I've read it gives headaches with line-breaking. What I'm using now is this:
\definecolor{kode-color}{RGB}{140,40,40}
\newcommand{\codesize}{\smaller[0.75]} % requires "relsize"
% File extension
\newcommand{\kode}[1]{\colorbox[HTML]{EEEEEE}{\color{kode-color}{{\texttt{\codesize #1}}}}}
It is simpler, with no line-height or line-breaking problems (AFAIK), but no rounded corners either. I'm trying to understand whether I can add a bit of eye candy without ruining it functionally.
Thanks!


\tcbox, it's caused by your settingboxsep=4pt. For\colorbox, it's caused by\fboxsepwhich defaults to 3pt. – muzimuzhi Z Sep 17 '23 at 11:50boxsep=0pt, and the line height is indeed OK, but the box is too tight. Settingleft,right,top, andbottomgets me back to square one, alas. – unDavide Sep 17 '23 at 12:37tcolorboxpackage manual, sec. 4.15.5) won't enlarge bounding box. You can try withboxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt, extrude by=2pt(extrusion option must be the last). – muzimuzhi Z Sep 17 '23 at 13:00