1

Is there a variant of mathtools's \DeclarePairedDelimiter that works for unpaired delimiters? EDIT: To be clear, I'm looking for a command that can be called as \command{delimited}, \command*{delimited}, or \command[\big]{delimited}, with the syntax of 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}

EDIT: To be clear, as @Werner points out below, the behaviour of \withdot{} is not literally a bug; it's just not what I want.

LSpice
  • 1,448

1 Answers1

1

Both \withblank and \withrelax (non-starred) can't work as there is no (say) extensible {}. The only extensible "blank" delimiter is .. If you're interested in defining blank left/right delimiters that might be used in a starred form similar to what is provided by \DeclarePairedDelimiter, the following may suffice:

enter image description here

\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}

Note that the definition

\DeclarePairedDelimiter\withdot.\rvert

is odd as \withdot{<stuff>} would provide .<stuff>\rvert, and it's not clear what the . delimiter (that is not extended) means here.

Werner
  • 603,163
  • Unfortunately your suggestion doesn't allow the \command[\size] syntax of \DeclarePairedDelimiter. I could just copy the relevant code from mathtools, but I'd prefer not to do so if there's an existing solution. Also, as you point out here and above, the behaviour of \withdot is not a bug in a literal sense; it's just not what I want. – LSpice Oct 27 '16 at 00:00
  • Never mind; obviously I can't execute TeX in my head as well as TeX itself can, since testing shows that your suggestion does support explicit sizing. Thank you! – LSpice Oct 27 '16 at 00:05
  • @LSpice: I've added support for \command[\size]. – Werner Oct 27 '16 at 00:08