Make < behave like \langle
The LaTeX kernel (fontmath.ltx
) defines the symbols the following way:
\DeclareMathDelimiter{<}{\mathopen}{symbols}{"68}{largesymbols}{"0A}
\DeclareMathDelimiter{>}{\mathclose}{symbols}{"69}{largesymbols}{"0B}
...
\DeclareMathDelimiter{\rangle}
{\mathclose}{symbols}{"69}{largesymbols}{"0B}
\DeclareMathDelimiter{\langle}
{\mathopen}{symbols}{"68}{largesymbols}{"0A}
Thus, it is possible to define <
and >
the same way as \langle
and \rangle
:
\documentclass{article}
\DeclareMathDelimiter{<}{\mathopen}{symbols}{"68}{largesymbols}{"0A}
\DeclareMathDelimiter{>}{\mathclose}{symbols}{"69}{largesymbols}{"0B}
\begin{document}
$M< x >$
\end{document}
The next example safes the less and greater signs in macros \less
and \greater
for the case they are needed:
\documentclass{article}
\mathchardef\less=\mathcode`<
\mathchardef\greater=\mathcode`>
\DeclareMathDelimiter{<}{\mathopen}{symbols}{"68}{largesymbols}{"0A}
\DeclareMathDelimiter{>}{\mathclose}{symbols}{"69}{largesymbols}{"0B}
\begin{document}
$1 \greater 0 \less M< x >$
\end{document}
Other math fonts may have different symbol encodings. Example for MnSymbol
:
\documentclass{article}
\usepackage{MnSymbol}
\mathchardef\less=\mathcode`<
\mathchardef\greater=\mathcode`>
\DeclareMathDelimiter{<}{\mathopen}{largesymbols}{'140}{largesymbols}{'140}
\DeclareMathDelimiter{>}{\mathclose}{largesymbols}{'145}{largesymbols}{'145}
\begin{document}
$1 \greater 0 \less M< x >$
\end{document}
A more automatic solution, which assumes that \langle
and \rangle
are defined by LaTeX's \DeclareMathDelimiter
with a definition text as \delimiter"
followed by 7 hexadecimal digits. Then the values for the math category code for the redefined <
and >
can be extracted from the definition of \langle
and \rangle
. Packages like MnSymbol
, mathabx
, txfonts
works then out of the box (if they are loaded before).
\documentclass{article}
\usepackage{txfonts}
\mathchardef\less=\mathcode`<
\mathchardef\greater=\mathcode`>
\def\tmp{\delimiter"}
\edef\tmp{\meaning\tmp}
\expandafter\def\expandafter\ScanDelimiterDefinition\tmp#1#2#3#4#5\relax#6{%
\mathcode`#6="#1#2#3#4\relax
}
\expandafter\ScanDelimiterDefinition\meaning\langle\relax<
\expandafter\ScanDelimiterDefinition\meaning\rangle\relax>
\begin{document}
$1 \greater 0 \less M< x >$
\end{document}
Similar to Heiko's, but with less cryptic code: the required \mathcode
can be obtained by dividing (with truncation) the \delcode
:
\documentclass{article}
%\usepackage{newtxmath}
\AtBeginDocument{%
\mathchardef\lt=\mathcode`<
\mathchardef\gt=\mathcode`>
\count255=\delcode`< \divide\count255 "1000
\mathcode`<=\count255
\count255=\delcode`> \divide\count255 "1000
\mathcode`>=\count255
}
\begin{document}
$1 \gt 0 \lt M<x>$
$\displaystyle\left<\frac{a}{b}\right>$
$<\bigl<\Bigl<\biggl<\Biggl<\Biggr>\biggr>\Bigr>\bigr>>$
\end{document}
This should be independent of the math font package.
On the other hand, you might use mathtools
and \DeclarePairedDelimiter
:
\documentclass{article}
\usepackage{mathtools}
%\usepackage{newtxmath}
\DeclarePairedDelimiter{\avg}{\langle}{\rangle}
\begin{document}
$1 < 0 < M\avg{x}$
$\displaystyle\avg*{\frac{a}{b}}$
$\avg{\avg[\big]{\avg[\Big]{\avg[\bigg]{\avg[\Bigg]x}}}}$
\end{document}