I am trying to find out a way to type this symbol illustrated below by latex, which means vector concatenation.
Does anyone know it? Thanks a lot!
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI am trying to find out a way to type this symbol illustrated below by latex, which means vector concatenation.
Does anyone know it? Thanks a lot!
I don't know if there is a dedicated command for such an operator, but you could simply use a big \Vert
symbol.
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\concat}{%
\mathchoice%
{\Big\Vert}%
{\big\Vert}%
{\Vert}%
{\Vert}%
}
\begin{document}
\begin{align*}
& \vec{h}_i' = \concat_{k=1}^K \sigma\Biggl( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j \Biggr) \\
& \textstyle \vec{h}_i' = \concat_{k=1}^K \sigma\Bigl( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j \Bigr) \\
& \scriptstyle \vec{h}_i' = \concat_{k=1}^K \sigma\bigl( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j \bigr) \\
& \scriptscriptstyle \vec{h}_i' = \concat_{k=1}^K \sigma( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j )
\end{align*}
\end{document}
\DeclareMathOperator*{\veccat}{\mathchoice{\Big\Vert}{\big\Vert}{\Vert}{\Vert}}
. Using \Big\Vert
is good in displaystyle, but for in-line text that would be too big. (For in-line \big
seems to be a good size, using \sum
as a comparison.)
Mar 7, 2022 at 14:01
To make the new operator the same size as a sum
, I suggest scalerel
.
\documentclass{article}
\usepackage{amsmath,scalerel}
\DeclareMathOperator*{\concat}{\scalerel*{\Vert}{\sum}}
\begin{document}
Display:
\[
\vec{h}_i' = \concat_{k=1}^K \sigma\left( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j \right)
\]
Inline: $\vec{h}_i' = \concat_{k=1}^K \sigma\left( \sum_{j\in\mathcal{N}_i} \alpha_{ij}^k \mathbf{W}^k \vec{h}_j \right)$.
\end{document}
Also, you might consider replacing \left(
and \right)
with \Biggl(
and \Biggl)
in display mode, which will make the parentheses slightly smaller than they are in your screenshot. Similarly, I suggest \bigl(
and \bigl)
for inline mode.
This will make the symbol with the same vertical dimension as \sum
.
\documentclass{article}
\usepackage{amsmath,graphicx}
% if you use also lmodern, add
% \usepackage{fixcmex}
\makeatletter
\newcommand{\concat@}{\mathop{\vphantom{\sum}\mathpalette\concat@@\relax}}
\newcommand{\concat@@}[2]{%
\vcenter{\hbox{%
\sbox\z@{$#1\sum$}%
\resizebox{\width}{\dimexpr\ht\z@+\dp\z@\relax}{\raisebox{\depth}{$\m@th#1\Vert$}}%
}}%
}
\newcommand{\concat}{\DOTSB\concat@\slimits@}
\makeatother
\begin{document}
\[
\sum_{k=1}^K h=\concat_{k=1}^K x
\quad
\textstyle \sum h=\concat_{k=1}^K x
\]
\end{document}