2

I need in-line pills like the ones Bootstrap has: https://getbootstrap.com/docs/4.0/components/badge/

How do I go about achieving this in LaTeX/XeTeX?

1

1 Answer 1

7

One possibility with the tcolorbox package:

\documentclass{article}


\usepackage[most]{tcolorbox}


\newtcbox{\badge}[1][red]{
  on line, 
  arc=2pt,
  colback=#1!50!black,
  colframe=#1!50!black,
  fontupper=\color{white},
  boxrule=1pt, 
  boxsep=0pt,
  left=6pt,
  right=6pt,
  top=2pt,
  bottom=2pt
}

\begin{document}

test \badge{test} test \badge[blue]{test}

\end{document}

enter image description here

3
  • 1
    To make all the badges the same vertical offset (even if the text includes a y or g characeter), set fontupper=\strut\color{white}: tex.stackexchange.com/a/418770/100323
    – crypdick
    Jan 3 at 14:49
  • Is it possible to fix the issue we have in this picture: dropbox.com/s/mqfaps9xr4cwi0t/… As you can see in CSS and Heroku the size of the badge is diferent from the rest of the other badges. I think that this has to do with the size of the letters, because in the remaining cases we do not have anything bellow the baseline I have added a last badge test for you to see that the size is not matching
    – lucasbbs
    May 31 at 0:50
  • @lucasbbs If you have a new question, please ask a new question. More people will see it. May 31 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .