# Union with text inside

I would like to create math symbol similar to set Union (big U) where I can insert inside an arbitrary word or symbol (e.g. "foo"). Something along the lines of this solution: Is a cupdot symbol available in amsmath? but with any text instead of dot. Is it possible?

• Welcome to TeX.SE. Simply replacing the \cdot with \text{foo} should work. Not sure how good it will look like though as there is not much space in there. – Peter Grill Feb 1 '18 at 1:15
• See e.g. \stackinset from the stackengine package – and probably use it with \bigcup. – Bernard Feb 1 '18 at 1:37
• How many letters might be in the word that should be placed inside the cup (union) symbol? – Mico Feb 1 '18 at 6:10
• – Steven B. Segletes Feb 1 '18 at 11:55

A possible solution with TikZ:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\uwithtext}[1]{\DOTSB\mathbin{\text{\tikz{%
\node (a) {#1};
\draw[black, rounded corners=1.2ex]
([yshift=-2pt]a.north west) -- (a.south west) -- (a.south east) -- ([yshift=-2pt]a.north east);}}}}

\begin{document}
$A \uwithtext{a} B \quad X_{A \uwithtext{a} B} \quad A \uwithtext{ab} B \quad X_{A \uwithtext{ab} B} \quad A \uwithtext{abp} B \quad X_{A \uwithtext{abp} B}$
\end{document}


• To enhance compatibility with the amsmath package, you might want to add \DOTSB at the beginning of \uwithtext. – GuM Feb 1 '18 at 11:44
• @GuM Added, thank you! Did I add it in the correct place? – CarLaTeX Feb 1 '18 at 11:47
• Yes, it’s in the correct place. You might want to have a look at how, say, the \skull command is implemented in the halloweenmath package (search the code for \newcommand*\skull. – GuM Feb 1 '18 at 17:04
• @krokodil You're welcome! Thank you for accepting my answer and please don't eat ducks! :):):):) – CarLaTeX Feb 2 '18 at 5:53