Re: Come evitare \left e \right nella definizione del modulo

#14679
Up
0
Down
::

Beh, che dire Enrico… grazie mille! 😀

Ho ricalcato il tuo codice per definire anche la norma:
`\makeatletter
\newcommand\abs{\@ifstar{\@abs\@firstofone}{\@abs\mathord}}
\newcommand{\@abs}[2]{#1{\left|#2\right|}}
\newcommand\norma{\@ifstar{\@norma\@firstofone}{\@norma\mathord}}
\newcommand{\@norma}[2]{#1{\left\|#2\right\|}}
\makeatother
`
Se c’è qualcosa che non va, fammi sapere!

Meglio ancora: puoi astrarre la definizione. Gli argomenti di \DeclareNormCommand sono il comando da definire, il delimitatore sinistro e quello destro. Ho aggiunto alcuni esempi che puoi studiare.
`\makeatletter
\newcommand{\DeclareNormCommand}[3]{%
\DeclareRobustCommand{#1}{%
\@ifstar{\@normlike\@firstofone{#2}{#3}}{\@normlike\mathord{#2}{#3}}}}
\newcommand{\@normlike}[4]{#1{\left#2#4\right#3}}
\DeclareNormCommand{\abs}{|}{|}
\DeclareNormCommand{\norma}{\|}{\|}
\DeclareNormCommand{\rhalfopen}{[}{[}
\DeclareNormCommand{\lhalfopen}{]}{]}
\DeclareNormCommand{\open}{]}{[}
\DeclareNormCommand{\closed}{[}{]}
\makeatother`
Ciao
Enrico

Go to top