How to reduce colorbox width for text?

Here's the MWE:

\documentclass[a4paper, 12pt]{article}

\renewcommand{\rmdefault}{ptm}
\usepackage[table]{xcolor}

\definecolor{tpgray}{gray}{0.90}
\newcommand{\tp}[1]{\colorbox{tpgray}{#1}}

\begin{document}
The board connectors are called \tp{GND} and \tp{VDD}.
\end{document}


This results in

How do I reduce the width of the gray area left and right of the highlighted text? I think there's a bit too much space, particularly at the end before the period. I don't mind leaving it as is but if there is a simple answer that takes less than 5 minutes (I don't want to waste anybody's time), I'd highly appreciate it :-)

The following solution shows two approaches: (1) use \colorbox and reduce the spacing at all sides and (2) use \tcbox from tcolorbox and change the sides independently.

\documentclass[a4paper, 12pt]{article}

\renewcommand{\rmdefault}{ptm}
\usepackage[table]{xcolor}

\definecolor{tpgray}{gray}{0.90}
\newcommand{\tp}[1]{\colorbox{tpgray}{#1}}
\setlength{\fboxsep}{1pt}

\usepackage[skins]{tcolorbox}
\newtcbox\tcbtp{hbox, on line, colback=tpgray, enhanced, frame hidden, boxrule=0pt,
top=1pt, bottom=1pt, right=-2pt, left=-2pt, sharp corners}

\begin{document}
The board connectors are called \tp{GND} and \tp{VDD}.

The board connectors are called \tcbtp{GND} and \tcbtp{VDD}.
\end{document}

• Dang, that's cool! And now I can even use rounded corners which makes it look even better. Very nice. Thanks a lot for your quick help. This community is awesome. Aug 26 '18 at 8:24