是否有适用于mathtools
的变体\DeclarePairedDelimiter
未配对分隔符?编辑:明确地说,我正在寻找一个可以调用为\command{delimited}
、\command*{delimited}
或 的命令\command[\big]{delimited}
,语法为DeclarePairedDelimiter
。
\usepackage{article}
\usepackage{mathtools}
\newcommand\tall{\rule{0pt}{10ex}}
\DeclarePairedDelimiter\withblank{}\rvert
\DeclarePairedDelimiter\withdot.\rvert
\DeclarePairedDelimiter\withrelax\relax\rvert
\begin{document}
\(\withdot*\tall\) produces the same result as \(\left.\tall\right\rvert\), but \(\withdot{}\) does not produce the same result as \({}\rvert\).
\(\withblank{}\) and \(\withrelax{}\) produce the same result as \({}\rvert\), and \(\withblank*\tall\) and \(\withrelax*\tall\) both give errors (but eventually produce the same result as \(\left.\tall\right\rvert\)).
\end{document}
编辑:明确地说,正如@Werner 指出的那样以下,的行为\withdot{}
实际上不是一个错误;它只是不是我想要的。
答案1
\withblank
和(非星号)都\withrelax
无法工作,因为没有 (比如说) 可扩展的{}
。唯一可扩展的“空白”分隔符是.
。如果您有兴趣定义可能以类似于 提供的星号形式使用的空白左/右分隔符\DeclarePairedDelimiter
,则以下内容可能足够:
\documentclass{article}
\usepackage{mathtools}
% http://tex.stackexchange.com/a/42337/5764
\begingroup\lccode`\|=`\\
\lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}}
\newcommand{\macroname}[1]{\expandafter\removebs\string#1}
\newcommand\tall{\rule{0pt}{10ex}}
\DeclarePairedDelimiter\withdot.\rvert
\makeatletter
\newcommand{\withblank}{\@ifstar\withblank@\withblank@@}
\newcommand{\withblank@}[1]{\left.\kern-\nulldelimiterspace #1\right\rvert}% \withblank*{..}
\newcommand{\withblank@@}[2][]{% \withblank[.]{..}
#2
\if\relax#1\relax
\rvert
\else
\csname\macroname{#1}r\endcsname\rvert
\fi}
\newcommand{\withrelax}{\withblank}% \withrelax is similar to \withblank
\makeatother
\begin{document}
\(\withdot*\tall\) produces the same result as \(\left.\tall\right\rvert\).
\(\withdot{}\) produce the same result as \(.{}\rvert\).
\(\withblank{}\) and \(\withrelax{}\) is similar to \({}\rvert\).
\(\withblank[\Big]{}\) and \(\withrelax[\Big]{}\) is similar to \({}\Bigr\rvert\).
\(\withblank*\tall\) and \(\withrelax*\tall\) is similar to \(\left.\kern-\nulldelimiterspace\tall\right\rvert\).
\end{document}
请注意定义
\DeclarePairedDelimiter\withdot.\rvert
很奇怪,就像\withdot{<stuff>}
提供的一样.<stuff>\rvert
,并且不清楚.
这里的分隔符(未扩展)是什么意思。