[Tex/LaTex] Space on the right hand side of a unary math operator

math-modemath-operatorsspacing

I know that \mathop{...} is used to give some space on the both sides of the binary operator. Could anyone tell what to use to give some space only on the right hand side of an unary math operator?

Edit1: for instance, i want to define a function NOT b such that NOT true returns false, and NOT false returns true. How could I space NOT and b under math mode?

Best Answer

There are a variety of spacing techniques in math mode that you could consider. The following is taken verbatim from Herbert Voss' Mathmode document on horizontal alignment. It showcases the different types of spacing available and compares them very well:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

    % Taken from http://ctan.org/pkg/voss-mathmode
    \begin{tabular}{ll|ll}
        \multicolumn{2}{l|}{Positive Space}&\multicolumn{2}{l}{Negative Space}\\\hline
        \verb|$ab$|   & $\boxed{a}\boxed{b}$\\\verb|$a b$|  & $\boxed{a} \boxed{b}$\\\verb|$a\ b$| & $\boxed{a}\ \boxed{b}$\\\verb|$a\mbox{\textvisiblespace}b$| & $\boxed{a}\mbox{\textvisiblespace}\boxed{b}$\\\verb|$a\,b$|\index{,@\textbackslash ,} (\verb|$a\thinspace b$|)\index{thinspace@\textbackslash thinspace} & $\boxed{a}\,\boxed{b}$&
        \verb|$a\! b$|\index{negthinspace@\textbackslash negthinspace} & $\boxed{a}\!\boxed{b}$\\\verb|$a\: b$|\index{:@\textbackslash :} (\verb|$a\medspace b$|)\index{medspace@\textbackslash medspace}&
        $\boxed{a}\:\boxed{b}$&
        \verb|$a\negmedspace b$|\index{negmedspace@\textbackslash negmedspace} & $\boxed{a}\negmedspace\boxed{b}$\\\verb|$a\; b$|\index{;@\textbackslash ;} (\verb|$a\thickspace b$|\index{thickspace@\textbackslash thickspace}&
        $\boxed{a}\;\boxed{b}$&
        \verb|$a\negthickspace b$|\index{negthickspace@\textbackslash negthickspace}&
        $\boxed{a}\negthickspace\boxed{b}$\\\verb|$a\quad b$|\index{quad@\textbackslash quad} & $\boxed{a}\quad\boxed{b}$\\\verb|$a\qquad b$|\index{qquad@\textbackslash qquad} & $\boxed{a}\qquad\boxed{b}$\\\verb|$a\hspace{0.5cm}b$|\index{hspace@\textbackslash hspace}& $\boxed{a}\hspace{0.5cm}\boxed{b}$&
        \verb|$a\hspace{-0.5cm}b$| & $\boxed{a}\hspace{-0.5cm}\boxed{b}$\\\verb|$a\kern0.5cm b$|\index{kern@\textbackslash kern} & $\boxed{a}\kern0.5cm \boxed{b}$ & \verb|$a\kern-0.5cm b$| & $\boxed{a}\kern-0.5cm \boxed{b}$\\ \verb|$a\hphantom{xx}b$|\index{hphantom@\textbackslash hphantom} & $\boxed{a}\hphantom{xx}\boxed{b}$\\\verb|$axxb$| & $\boxed{a}xx\boxed{b}$
    \end{tabular}
\end{document}

Additional horizontal alignment

Consequently, here's an example that defines the command \NOT{<bool>} that places \sim (the negation operator), followed by a \, (\thinspace), followed by <bool>:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand{\NOT}[1]{\ensuremath{{\sim}\,#1}}% NOT{<bool>}
$\NOT{a}$

$\NOT{\texttt{true}}=\texttt{false}$
\end{document}

Defining a command \NOT with spacing

For more on mathematical typesetting, actually, much more, consider reading the entire document. Specifically for spacing in math mode, read Section 11.1 Math typesetting.