18

How can I create my own scalable math operator with limits just like the sum symbol? Specifically I want to invent a "concatenation" symbol that looks alike to: "[". For example I want to put

[ _{i=1}^N

etc. where the subscript/superscripts are positioned below and above the symbol as in "eqnarray" environment.

I have tried with \newcommand and creating a drawing similar to "[" with \begin{picture} \end{picture}, but it didn't work.

Thanks for the help!

Sandy G
  • 42,558

3 Answers3

40

A simple solution would be to use the \DeclareMathOperator* command from the amsmath package. The unstarred version places sub- and superscript limits to the right of the operator; the starred version places limits above and below the operator when it is in displaystyle.

\DeclareMathOperator*{\concat}{[} will produce the following results:

enter image description here

You could leave it like that, but for me, the displayed version produces a [ symbol that is too small. Using the scalerel package, you could make the symbol the same size as a \sum symbol:

\DeclareMathOperator*{\concat}{\scalerel*{[}{\sum}}, which will produce the following: enter image description here

Here is a MWE:

\documentclass{article}

\usepackage{amsmath,scalerel}

%\DeclareMathOperator{\concat}{[} \DeclareMathOperator{\concat}{\scalerel*{[}{\sum}}

\begin{document}

[ \concat_{n=1}^{\infty} a_n ]

Inline: $\concat_{n=1}^{\infty} a_n$.

\end{document}

Sandy G
  • 42,558
17

You can use a modified version of https://tex.stackexchange.com/a/23436/4427 (first code set).

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\makeatletter \DeclareRobustCommand\bigop[2][1]{% \mathop{\vphantom{\sum}\mathpalette\bigop@{{#2}{#1}}}\slimits@ } \newcommand{\bigop@}[2]{\bigop@@#1#2} \newcommand{\bigop@@}[3]{% \vcenter{% \sbox\z@{$#1\sum$}% \hbox{\resizebox{#3\dimexpr\ifx#1\displaystyle.9\fi\dimexpr\ht\z@+\dp\z@}{!}{$\m@th#2$}}% }% } \makeatother

\newcommand{\bigconcat}{\DOTSB\bigop[0.5]{[,}}

\begin{document} [ \sum_{i=1}^n \bigconcat_{i=1}^n x_i \qquad \textstyle \sum\bigconcat_{i=1}^n x_i \qquad \scriptstyle \sum\bigconcat_{i=1}^n x_i \qquad \scriptscriptstyle \sum\bigconcat_{i=1}^n x_i ] \end{document}

The scaling is necessary because of how TeX is treating [.

enter image description here

egreg
  • 1,121,712
10

My idea uses \left[\phantom{\sum}\right. trick:

\def\concat{\mathop{\left[\vphantom{\sum}\right.}}

Test: $\concat_{n=1}^\infty \displaystyle \concat_{n=1}^\infty \scriptstyle \concat_{n=1}^\infty $

\bye

wipet
  • 74,238