我想声明一个成对的分隔符,以便我可以使用类似以下语法:
\mycommand'_k[\big]{x}\\
\mycommand^\prime_k[\big]{x}
放入大小x
的括号中\big
,前面加上DeclareMathOperator
,例如,它将返回相当于
\texttt{mean}'_k\big(x\big)
例如:
\DeclareMathOperator*{\mean}{\texttt{mean}}
\DeclarePairedDelimiterXPP\mycommand[1]{\operatorname{\mean}}[]{}{#1}%
但我不知道如何为此提供下标和上标。
答案1
e
并且t
参数类型可以在这里使用:
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\meanb{[}{]}
\NewDocumentCommand\mycommand{t{'}e{_^}}{%
\operatorname{mean}%
\IfBooleanT{#1}{'}%
\IfNoValueF{#2}{_{#2}}%
\IfNoValueF{#3}{^{#3}}%
\meanb}
\begin{document}
\begin{gather}
\meanb{x}\\
\meanb[\bigg]{x}\\
\mycommand{x} \\
\mycommand^{\prime}{x} \\
\mycommand^{\prime}_{k}{x} \\
\mycommand'{x} \\
\mycommand'_{k}{x} \\
\mycommand[\bigg]{x} \\
\mycommand^{\prime}[\bigg]{x} \\
\mycommand^{\prime}_{k}[\bigg]{x} \\
\mycommand'[\bigg]{x} \\
\mycommand'_{k}[\bigg]{x}
\end{gather}
\end{document}