4

I have known \overset{K}{\|} to set above. However how to do like this:

enter image description here

2 Answers 2

7

The same vertical size as \sum:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\nnn}{\DOTSB\nnn@\slimits@}
\newcommand{\nnn@}{\mathop{\mathpalette\nnn@@\|}}
\newcommand{\nnn@@}[2]{%
  \vphantom{\sum}%
  \ifx#1\displaystyle\big#2\else#2\fi
}
\makeatother

\begin{document}

\[
\nnn_{k=1}^K\quad \sum_{k=1}^K
\]
\begin{center}% just to show inline math below displaystyle
$\nnn_{k=1}^K$\quad$\sum_{k=1}^K$
\end{center}

\end{document}

enter image description here

8

Currently, the width of the widest compnent (k=1) determines the width of the stack. If it is needed so that the width of K or the vertical bars determines the width of the stack, please let me know.

It was not clear (to me) from the context of the question whether the baseline is aligned with the K or the vertical bars. Thus, I offer both possibilities. In the latter, the bars will be sized the same as \sum:

\documentclass{article}
\usepackage{stackengine,scalerel,mathtools}
\DeclareMathOperator*\vbars{\scalerel*{\rule{.6pt}{10pt}\mkern2mu\rule{.6pt}{10pt}}{\sum}}
\stackMath
\parskip1ex
\begin{document}
K baseline: 
$\stackunder[2pt]{K}{\stackunder[2pt]{%
  \rule{.6pt}{15pt}\mkern2mu\rule{.6pt}{15pt}}{\scriptstyle k=1}}$

\bigskip
Rule baseline:


$\vbars^K_{k=1}$ (textstyle)

$\displaystyle\vbars^K_{k=1}$ (displaystyle)
\end{document}

enter image description here

In the latter case (\vbars math operator), if one wishes the rule thickness and gap to remain the same in both text and display styles, then, in the definition of \vbars, merely change \scalerel to \stretchrel.

You must log in to answer this question.

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