[Tex/LaTex] How to set fit height and width for tcbox according to the text inside

formattingheighttcolorboxwidth

I want to place a word into a \tcbox, but the box has too much space around the word. For example, the word "EQUAL".

Best Answer

You have several options here: you can use the top, left, bottom, right keys (and perhaps also boxsep) to control the space between text and frame on each of the sides or you could use the size key to get some predefined sizes (the accepted values minimal, tight, fbox, small, title, and normal and their effect are illustrated in my example code):

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{pgffor}

\begin{document}

\tcbox{EQUAL}

\tcbox[top=0pt,left=0pt,right=0pt,bottom=0pt]{EQUAL}

\foreach \s in {minimal,tight,fbox,small,title,normal} 
{
\tcbox[size=\s,on line]{EQUAL} 
}

\end{document}

enter image description here

Related Question