0

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?

krokodil
  • 237

1 Answers1

3

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}

enter image description here

CarLaTeX
  • 62,716
  • To enhance compatibility with the amsmath package, you might want to add \DOTSB at the beginning of \uwithtext. – GuM Feb 01 '18 at 11:44
  • @GuM Added, thank you! Did I add it in the correct place? – CarLaTeX Feb 01 '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 01 '18 at 17:04
  • @krokodil You're welcome! Thank you for accepting my answer and please don't eat ducks! :):):):) – CarLaTeX Feb 02 '18 at 05:53