Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

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.

share|improve this answer
    
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 '12 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 '12 at 0:09
    
@Guido: True. I've referenced that in my answer. Thanks. –  Werner Sep 21 '12 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 '12 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 '12 at 1:50
show 1 more comment

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$}}}
  }
}
share|improve this answer
    
That led to exactly the solution I needed. Thanks a lot! –  geezer Sep 21 '12 at 1:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.