7

During a project involving plenty angle brackets, I tried to redefine \rangle as \> using \newcommand to make things a little easier.

However, this called the error "command \> already defined". When removing the definition, it does run, although the symbol \> appears pink and is listed an unrecognised symbol.

I turned off all packages and there doesn't seem to be any clashing with \>. I also defined \< as \langle in exactly the same way with no such issue occurring.

I'm unsure if this is a bug or if I am missing something subtle. Using TexStudio.

1
  • 1
    Welcome to TeX.SE. Please provide more information about how you tried to define the macros \> and \<. While you're at it, do please state which document class you employ and which math symbol packages, if any. are loaded by your document.
    – Mico
    Dec 26, 2020 at 14:15

3 Answers 3

10

TeXStudio is just an editor; the fact that it doesn't highlight a macro doesn't necessarily mean it isn't defined, especially if it's an internal macro (i.e. not intended for direct use in a document).

Now \< is undefined as standard, but \> is defined as \mskip \medmuskip. It's hard to know where this might be used by the kernel or by a package, so changing it would be very unwise. It would be better to define a command such as

\newcommand\ang[1]{\langle #1 \rangle}

Then you can place an object in angle brackets using \ang{whatever}. Depending on your usage case, you might want to use more arguments, for example an inner product might be defined as

\newcommand\ip[2]{\langle #1 , #2 \rangle}

Finally, you might want to use \left and \right in your definitions, to allow the bracket sizes to change.

1
  • Thank you, it was just for an inner product, so this should work perfectly
    – Flumpo
    Dec 26, 2020 at 14:33
7

It's impossible for editors to keep track of every command that packages may define (there are thousands of them).

Actually it's a bit surprising that \> is ignored, because it is a command defined in the LaTeX kernel with a dual function:

  1. an alias to \: for back compatibility with plain TeX (and very old LaTeX) documents;

  2. a main command inside the tabbing environment, which also (re)defines \<.

If you don't plan to use tabbing, then redefining \> might be safe. However, it pops out in some packages:

skak xskak blog qsymbols ednotes clrscode3e clrscode zxjatype knitting pax
qqru-shipunov gn-logic14 polytable catoptions bxcjkjatype AlProTex program
sgamevar alphabeta textalpha 

where it is redefined. I guess you're unlikely to use most of them, but the last two might bite you.

You can do differently:

\usepackage{mathtools}

\DeclarePairedDelimiter{\foo}{\langle}{\rangle}

and then use

\foo{x} \foo[\big]{x} ... \foo[\Bigg]{x}

where the optional argument sets the size, or \foo*{x} for \left and \right automatic sizing (use sparingly).

Find a better name than \foo, of course.

4

For inner products, you can load mathtools and xparseand define an \innerp{a,b} command this way:

\DeclarePairedDelimiterX{\innerp}[1]{\langle}{\rangle}{\innpargs{#1}}
\NewDocumentCommand{\innpargs}{ >{\SplitArgument{1}{,}}m }
 {\innpargsaux#1}
\NewDocumentCommand{\innpargsaux}{ m m }
 {#1\,,#2}%

Using \innerp*{a,b} will behave as though there was a pair of \left\langle \right\rangle. For fine-tuning the size of the delimiters, you can use an optional argument instead: \innerp[\big]{a,b}, \innerp[\Big]{a,b}, &c., which behaves as though there was a pair of \bigl\langle \bigr\rangle or \Bigl\langle Bigr\rangle, and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.