# Using math mode relation symbols in text mode with optimised spacing

I'd like to have easy access to commonly used relation symbols in text mode, just as they are easily accessible in math mode. An important example is ⊕, or \oplus. I'd like to configure the control symbol \+ to use it:

\documentclass{article}
\usepackage{amsmath}
\NewDocumentCommand{\+}{}{\ensuremath{\oplus}}

\begin{document}
\section{Upright}
a \+ b\\
$\text{a} \oplus \text{b}$

\section{Italics}
\textit{a} \+ \textit{b}\\
$a \oplus b$
\end{document}


While this works, I still need to optimise the spacing so that it matches, or is similar to, the spacing in math mode:

I've tried the following:

• changing the value of \mathsurround in the definition, i.e. \NewDocumentCommand{\+}{}{\mathsurround=0pt\ensuremath{\oplus}} (I believe this is already the default)
• using \mathrel around \oplus in the definition.

None of these approaches have worked. One additional idea I had was to access the \oplus symbol directly, but the Unicode symbol would not link to the math relation symbol in the font I use. Is there another way?

• You can try \NewDocumentCommand{\+}{}{\ensuremath{\mbox{}\oplus\mbox{}}} and use \+ without surrounding spaces in text mode. Jan 20, 2021 at 16:42
• this seems to be encouraging very dubious markup, the math and text a and b come from separate fonts for example. TeX markup by design chooses to make a clear distinction between math and text. Jan 20, 2021 at 22:38
• @DavidCarlisle Yes, this Q doesn't make sense when one has the usual usage pattern of math mode in mind that is used in math or physics, etc. However, in some formal areas of the humanities and SocSci, formalisms work/are used there in a quite different practice. I should have mentioned that. Jan 21, 2021 at 11:36
• @FelixEmanuel sure but in such cases I would have expected that a word space rather than the math space would be what is expected, but anyway feel free to ignore me wipet has already provided the same answer I would have given:-) (except without the hbox) Jan 21, 2021 at 11:59

You can try:

\def\+{\leavevmode\unskip\hbox{${}\oplus{}$}\ignorespaces}


This ignores space before and after \+ and adds the spaces from math mode.

• I'd probably not use the hbox here (to allow the space to stretch) but it depends what the OP wants... Jan 21, 2021 at 12:00

If you want math-mode typesetting, what you really want is to switch to math mode, but typeset the arguments as text. Both \textup and \texit work in math mode. You could also use \mathrm or \mathit.

\documentclass{article}
\usepackage{amsmath}

\newcommand\plusify[2]{$$\text{#1} \oplus \text{#2}$$}

\begin{document}
\section{Upright}
$$\textup{a} \oplus \textup{b}$$
\plusify{a}{b}
$$\text{a} \oplus \text{b}$$
$$\mathrm{a} \oplus \mathrm{b}$$

\section{Italics}
$$\textit{a} \oplus \textit{b}$$
\plusify{\itshape a}{\itshape b}
$$a \oplus b$$
$$\mathit{a} \oplus \mathit{b}$$
\end{document}


• From a technical point of view, this is probably the cleanest solution. However, if one needs to use that relation very often, typing a control symbol is much less of a hassle than a sequence + argument, and it makes for more readable code. Jan 21, 2021 at 11:32
• @FelixEmanuel It comes down to personal preference, but I would probably write macros for the text arguments instead. Jan 21, 2021 at 11:33
• @FelixEmanuel Besides, you could make the two-argument macro \+ a b, which is just as short. Jan 21, 2021 at 11:35