3

Suppose, we are writing a logical expression in math mode:

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\begin{document}
$a\&b$
\end{document}

The output looks like this:

enter image description here

Questions:

  1. What should be the space size around the '&' symbol: \, or \> or \;?

  2. How can I automate adding the correct spaces around &? So I won't need to type \;&\; every time.

  • since this question is about a specific symbol, i identified it in the title. – barbara beeton Aug 28 '15 at 18:31
  • Do you know about $a \wedge b$? – Sigur Aug 28 '15 at 19:34
  • @Sigur Yes, just wanted to know, how to put spaces around my own symbols. – user4035 Aug 28 '15 at 20:05
  • 1
    @user4035, so I recommend you to read about \mathrel and \mathpunct also. – Sigur Aug 28 '15 at 20:12
  • @Sigur Will do. – user4035 Aug 28 '15 at 20:12
5

The symbol can be set as binary operator \mathbin.

The amount of the space is \medmuskip and the space can be set via \>.

Manually, \& can be put into \mathbin, then TeX sets the space automatically:

\documentclass{article}
\begin{document}
$a\mathbin{\&}b$
\end{document}

Result

Also, `\&` can be redefined to add `\mathbin` in math mode automatically:

\documentclass{article}
\renewcommand*{\&}{%
  \relax
  \ifmmode
    \mathbin{\char`\&}%
  \else
    \char`\&\relax
  \fi
}
\begin{document}
$a \& b$
\end{document}
|improve this answer|||||
6

There's no definition for \& as a math character, so it's regarded as a letter.

However, simply defining it as a math character would make it unusable in text mode, so a branching should be used:

\DeclareRobustCommand{\&}{%
  \ifmmode\expandafter\mathbin\fi\char`&
}

Full example:

\documentclass{article}

\DeclareRobustCommand{\&}{%
  \ifmmode\expandafter\mathbin\fi\char`&
}

\begin{document}

Duck \& Co.

$a \& b$

\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.