答案1
区分显示和文本样式的版本(不要在下标中尝试)
\documentclass[twocolumn]{article} % twocolumn just for a smaller picture
\usepackage{amsmath,amssymb}
\makeatletter
\newcommand{\rocl}[3]{%
% #1 = left bound, #2 = function, #3 = right bound
\mathopen{}
\mathpalette\rocl@{{#1}{#2}{#3}}%
\mathclose{}
}
\newcommand{\rocl@}[2]{\rocl@@{#1}#2}
\newcommand{\rocl@@}[4]{%
\ifx#1\displaystyle
{\vphantom{\Big|}}_{#2}\kern-\scriptspace
\Big|%
\mspace{-4.5mu}
\vcenter{\hbox{$\scriptstyle\blacktriangleright$}}%
\,{#3}\,
\vcenter{\hbox{$\scriptstyle\blacktriangleleft$}}%
\mspace{-4.5mu}
{\Big|}_{#4}%
\else
{\vphantom{\big|}}_{#2}\kern-\scriptspace
\big|%
\mspace{-4.5mu}
\vcenter{\hbox{$\scriptscriptstyle\blacktriangleright$}}%
\,{#3}\,
\vcenter{\hbox{$\scriptscriptstyle\blacktriangleleft$}}%
\mspace{-4.5mu}
{\big|}_{#4}%
\fi
}
\makeatother
\begin{document}
This $\rocl{\sigma_{\mathrm{L}}}{X(s)}{\sigma_{\mathrm{H}}}$
in text, next in a display
\[
\rocl{\sigma_{\mathrm{L}}}{X(s)}{\sigma_{\mathrm{H}}}
\]
with some text following.
\end{document}
答案2
其实,这个公式最难的部分是左边的下标。我发现如果你使用_
下面的下标,\vphantom
它就不能正常工作,所以我发明了\subdepth{}
将下标推到正确的深度。
\documentclass{article}
\usepackage{amssymb}
\newcommand\subdepth[1]{\raisebox{-6pt}{${}_{#1}$}}
\newcommand\midscript[1]{\vcenter{\hbox{$\scriptstyle#1$}}}
\newcommand\ROCl{\Bigl|\mkern-4mu\midscript{\blacktriangleright}}
\newcommand\ROCr{\midscript{\blacktriangleleft}\mkern-4mu\Bigr|}
\begin{document}
$\subdepth{\sigma_L}\ROCl X(s)\ROCr\subdepth{\sigma_H}$
\end{document}
在这里,我将其自动化从 displaystyle 切换到 textstyle,并将调用简化为三参数\ROC
宏。
\documentclass{article}
\usepackage{amssymb,amsmath,scalerel}
\makeatletter
\newcommand\subdepth[1]{\ThisStyle{\if D\m@switch
\raisebox{-6pt}{${}_{#1}$}\else{}_{#1}\fi}}
\newcommand\midscript[1]{\vcenter{\hbox{$\scriptstyle#1$}}}
\newcommand\ROCl{\ThisStyle{\if D\m@switch
\Bigl|\mkern-4mu\midscript{\blacktriangleright}\else
|\mkern-4mu\midscript{\blacktriangleright}\fi}}
\newcommand\ROCr{\ThisStyle{\if D\m@switch
\midscript{\blacktriangleleft}\mkern-4mu\Bigr|\else
\midscript{\blacktriangleleft}\mkern-4mu|\fi}}
\makeatother
\newcommand\ROC[3]{\subdepth{#1}\ROCl #2\ROCr\subdepth{#3}}
\begin{document}
\[
\ROC{\sigma_L}{X(s)}{\sigma_H}
\]
\centering
$\ROC{\sigma_L}{X(s)}{\sigma_H}$
\end{document}