Swap definition of starred and non-starred command
You can redefine \abs
to call the opposite version of the original command:
\makeatletter
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}
\makeatother
(The reason that your commented try doesn't work is that technically the *
is not part of the macro name, but is read by the macro itself using \@ifstar
, \@ifnextchar
or similar commands.)
simply define \abs
with \def
if you do not want to use the star version.
\def\abs#1{\left\lvert#1\right\rvert}
I've had the same problem and wrote a work-around for this: a macro \DeclarePairedDelimiterY
, see this question. But note you have to replace the line
{\csname#1Temp*\endcsname{##2}}%
with
{\csname#1Temp\endcsname*{##2}}%
Then you can define \abs
by
\DeclarePairedDelimiterY{abs}{\lvert}{\rvert}
where the backslash of \abs
is omitted. Then:
\abs{x}
expands to\left\lvert x\right\rvert
\abs[normal]{x}
expands to\lvert x\rvert
\abs[big]{x}
expands to\bigl\lvert x\bigr\rvert
\abs[Big]{x}
expands to\Bigl\lvert x\Bigr\rvert
\abs[bigg]{x}
expands to\biggl\lvert x\biggr\rvert
\abs[Bigg]{x}
expands to\Biggl\lvert x\Biggr\rvert
In contrast to the original \DeclarePairedDelimiter
command, you leave out the backslash of \big
, \Big
etc.
(Unluckily I didn't find your question prior to posting my own one...)