10

I am looking for a good way to typeset the concatenation of two strings. This is standard notation in descriptive set theory to join an m-tuple x to an n-tuple y to get an (m+n)-tuple x^y, that is, a small slightly raised circumflex or frown joining the upper parts of the characters together. I currently use the straightforward

x^\smallfrown y

which doesn't look terribly good.

Semantically, this is a binary operation, but it shouldn't have the usual spacing on the right and the left and it should be higher up than a minus sign, say.

Here's a sample screen shot from Moschovakis's Descriptive set theory (p.76 of the pdf) which is approximately what I'd like to do, but I'd prefer a frown:

Sample screen shot from Moschovakis


Looking around on this site, I found the question String/vector concatenation symbol but it is concerned with which symbol to use for the operation, so it doesn't address my question.

0

2 Answers 2

10

Define a binary math command (\mathbin) that is typeset according to your specifications:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\newcommand{\concatA}{%
  \mathbin{\raisebox{1ex}{\scalebox{.7}{$\frown$}}}%
}
\newcommand{\concatB}{%
  \mathbin{\rotatebox[origin=c]{90}{\scalebox{.7}{(\kern1ex)}}}
}
\begin{document}
$x\concatA y\ x\concatB y$
\end{document}​​​​​​​​​​​​​​​​​​​​​​​​​

\concatA could be what you're after, although I've also added \concatB to show you another possibility. There may be more, so if you're interested, see How to look up a symbol?.

You can fiddle around with the \frown raise (1ex) as well as the size (scaled to .7 of its original size thanks to graphicx).

It sounds logical to me to have the spacing set as \mathbin since it represents an operator acting on two entities (operands). However, you can use \mathord to remove the binary-operator-ness. Perhaps even specifying your own spacing around the symbol with additional \mkerns if needed.

6
  • The original post asked to remove the spaces around the operator. So it would be better to use \mathord instead of \mathbin.
    – Guido
    Sep 21, 2012 at 0:02
  • Great! Thanks for the quick response (and the edit to my question). Yes, \concatA is essentially what I want, except for the spacing around the operation which is taken care of by @Guido's comment. I'll leave this open for a few hours to see if someone else has another suggestion but in my document it works the way I wanted.
    – geezer
    Sep 21, 2012 at 0:09
  • @Guido: True. I've referenced that in my answer. Thanks.
    – Werner
    Sep 21, 2012 at 0:14
  • There is one problem with the suggested solution: I often need the command in subscripts, e.g. N_{x \concatA y} and your solution doesn't seem to scale properly, like the ordinary operations like + do. How do I get it to do that?
    – geezer
    Sep 21, 2012 at 0:32
  • @geezer: That wasn't part of the original request. However, without repeating Guido's suggestion, see his answer for an alternative that provides this functionality.
    – Werner
    Sep 21, 2012 at 1:50
5

You can expand on Werner's solution using \mathchoice.

\newcommand{\concatA}{%
  \mathord{
    \mathchoice
    {\raisebox{1ex}{\scalebox{.7}{$\frown$}}}
    {\raisebox{1ex}{\scalebox{.7}{$\frown$}}}
    {\raisebox{.7ex}{\scalebox{.5}{$\frown$}}}
    {\raisebox{.7ex}{\scalebox{.5}{$\frown$}}}
  }
}
1
  • That led to exactly the solution I needed. Thanks a lot!
    – geezer
    Sep 21, 2012 at 1:56

You must log in to answer this question.

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