# Is there a way to create elements that looks like tags?

How can I style some element that looks like stackoverflow tags?

• Welcome to TeX.SX! This can be easily done with TikZ or alike. Please see the PGF manual and try to construct them. If you encounter any problems, post you code here with your specific question and we try to help you. Like this, it is just a "do-it-for-me"-question which will not find much interest here. – LaRiFaRi Jan 9 '15 at 8:31
• tex does not have "elements" are you asking about a web page (with mathjax style math as on math.stackexchange?) (If so it is off topic for this site) – David Carlisle Jan 9 '15 at 8:43
• tcolorbox could be another solution. – Ignasi Jan 9 '15 at 9:01

Here's another option using tcolorbox:

The code:

\documentclass{article}
\usepackage[many]{tcolorbox}

\definecolor{tagbg}{RGB}{224,234,241}
\definecolor{tagtext}{RGB}{62,109,154}

\newtcbox{\mytag}{
enhanced,
nobeforeafter,
tcbox raise base,
boxrule=0.4pt,
top=1pt,
bottom=1pt,
right=3pt,
left=3pt,
arc=0pt,
outer arc=0pt,
boxrule=0.4pt,
before upper={\vphantom{dlg}},
coltext=tagtext,
colback=tagbg,
colframe=tagtext,
fontupper=\sffamily
}

\begin{document}

\mytag{html}
\mytag{css}
\mytag{alignment}

\end{document}


With \fcolorbox command from the xcolor package you can define a new command \tagbox

\newcommand{\tagbox}[1]{\fcolorbox{LightGray}{LightCyan}{\textsf{#1}}}


Change the colors to the ones you like.

MWE:

\documentclass{article}
\usepackage[svgnames]{xcolor}
\newcommand{\tagbox}[1]{\fcolorbox{LightGray}{LightCyan}{\textsf{#1}}}
\begin{document}
\tagbox{html}
\end{document}


Output:

## EDIT

Just to show that it can be done without tcolorbox.

MWE (colors borrowed from Gonzalo's answer

\documentclass{article}
\usepackage{xcolor}

% colors borrowed from Gonzalo's answer
\definecolor{TagBG}{RGB}{224,234,241}
\definecolor{TagText}{RGB}{62,109,154}

\newcommand{\tagbox}[1]{\fcolorbox{TagText}{TagBG}{\textcolor{TagText}{\textsf{\vphantom{hg}#1}}}}

\begin{document}
\tagbox{html} \tagbox{css} \tagbox{alignment}
\end{document}


Output: