[Tex/LaTex] \fbox thickness different for different size

boxesrules

The thickness of \fbox in LaTeX can be changed by using \fboxrule. But I want different thickness for different sides. Basically I want to write a text with only a border in top and no where. So I am using \fbox, but it gives a box around the whole text. Is there any suitable method for this?

Best Answer

A tcbox from tcolorbox could be a solution

\documentclass{article}

\usepackage{lmodern}
\usepackage{tcolorbox}

\newtcbox{\upbox}[2][black]{on line, 
arc=0pt, 
outer arc=0pt, 
colback=white,
colframe=#1,
boxsep=0pt, left=1pt, right=1pt, top=2pt, boxrule=0pt, toprule=1pt,#2}

\begin{document}

This are \upbox{}{some} words with \upbox[red]{toprule=3pt}{a line on top}

\end{document}

enter image description here