# Make < behave like \langle

In a document I am writing I have to make heavy use of the notation M with the angle-brackets, so I'm using $M\langle x \rangle$, I would like to use instead $M<x>$as it is a lot more readable (and faster to type!) but it leaves a nasty space around the symbol. Is there a way to change the behaviour of the symbols < and > in math mode to behave as \langleand rangle?

Thank you

• In cases like this, I think it's better to define a logical macro to handle the setting (promoting consistency), say, \newcommand{\domain}[1]{M\langle #1\rangle}. Using \domain{x} seems pretty readable to me.
– Werner
Nov 11, 2016 at 17:30

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}


• I don't understand: It seems like the LaTeX kernel defines < [>] to be exactly the same as \langle [\rangle], yet one still has to redefine it?
– Werner
Nov 11, 2016 at 17:28
• @Werner the normal symbols are different: < and > use family operators and \langle and \rangle use family symbols. But in the case of a large delimiters (e.g. \left...\right...), the symbols are mapped to the same math font largesymbols and < and \langle, and > and \rangle are the same symbols, mapped to the same slots. < and > are relational operators, but if they are used as delimiters they become \langle and \rangle. Nov 11, 2016 at 17:37

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}

• +1 for recommending using \DeclarePairedDelimiter`, which I think is the real solution.
– GuM
Nov 11, 2016 at 18:58