I use \textlangle
and \textrangle
in a command
\newcommand{\qdist}[1]{\textlangle#1\textrangle}
which is used in math and text mode. In math mode, I get the error message
LaTeX Warning: Command \textrangle invalid in math mode on input line 952.
what similar symbol could be used in both modes? I use Lualatex.
the MWE
\documentclass[msmallroyalvopaper
]{memoir}
\newcommand{\qdist}[1]{\textlangle#1\textrangle}
\begin{document}
text with \qdist{word}
and some math
\[ a = \qdist{symbol} \]
The multiple applications of a GIS can be summarized in three prototypical situations:
more text
\end{document}
Best Answer
You could incorporate an
\ifmmode
conditional, to use\langle
and\rangle
in math mode and\textlangle
and\textrangle
in text mode.This approach works with pdfLaTeX, LuaLaTeX, and XeLaTeX.
Addendum -- As @egreg has pointed out in a comment and in his separate answer, using
\newcommand
to create the\qdist
macro, as is done above, can run into trouble. It's necessary to use\DeclareRobustCommand
instead of\newcommand
.