1

To define string concatenation, I use the || symbol to concatenate two strings, like S1||S2. Now I need to show the concatenation of more than two. Is there any known symbol to define the concatenation of more than two strings, like the sum in \sum_{i=1}^N S_i, but with something different from \sum?

Bernard
  • 271,350

1 Answers1

3

This can be done using \DeclareMathOperator* and the scalerel package:

enter image description here

In the code below, \scalerel* scales the \Vert symbol (double vertical lines) to match the size of a \sum symbol, whether inline or displayed or in a subscript. \DeclareMathOperator gives the symbol the same behavior as a large operator like \sum. The starred version \DeclareMathOperator* places the limits above and below when displayed, but on the right when inline.

\documentclass{article}

\usepackage{amsmath,scalerel}

\DeclareMathOperator{\concat}{\scalerel{\Vert}{\sum}}

\begin{document}

Inline: $\concat_{n=1}^{\infty} S_n$. Display: $\displaystyle{\concat_{n=1}^{\infty} S_n}$

\end{document}

Sandy G
  • 42,558
  • Perhaps you could consider adding For 2 arguments: ${S_1}\concat{S_2}$. to illustrate the nice spacing of this approach even as an operator between 2 arguments (like +) – jessexknight Apr 28 '22 at 12:54
  • I was also tinkering with \& as the operator, instead of \Vert, but the scaling gets wonky. Some people may find this hack useful: replace \Vert with \vphantom{\textstyle\sum}\smash{\&} to get better scaling with that approach. – jessexknight Apr 28 '22 at 12:56
  • @Sandy G Thanks, this is exactly what I tried as the first thought. I was principally interested if such an operator exists and is commonly used (somehow, I do not know myself). Anyway, many thanks! Sorry, as a new member, I cannot upvote. ):- – Stanislav Koncebovski Apr 28 '22 at 13:09