I want to place a word into a \tcbox
, but the box has too much space around the word. For example, the word "EQUAL".
2 Answers
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}
-
If looked carefully, the top padding of is quite smaller than the bottom padding. To fix this for
title
size, use\tcbox[size=title,on line,top=3pt]{EQUAL}
– OokerDec 10, 2017 at 19:03
If it is only one word inside the box, you may use tikz
straight away. Change inner sep
values as you wish.
\documentclass{article}
\usepackage{tikz}
\newcommand{\mybox}[1]{\tikz[baseline={(a.base)}]\node[draw=blue,rounded corners=0.5ex,fill=red!40!white,inner sep=1pt](a){#1};}
\begin{document}
\mybox{hello} my world \mybox{EQUAL}
\end{document}