Command already defined, but is unrecognised
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.
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:
an alias to
\:
for back compatibility with plain TeX (and very old LaTeX) documents;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.
For inner products, you can load mathtools
and xparse
and 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.