0

The xcolor package influences the spacing of the algebraic sign. How to prevent this behavior?

Screenshot

enter image description here

Mathematical background

The second example should be treated as a binary operator instead of an unary operator.

See: Unary vs. binary operator spacing in LaTeX

MWE

\documentclass{scrreprt}

\usepackage{xcolor}

\begin{document}
\(1 + 2\)

\(1 {\color{gray} + 2}\)

\end{document}

Workaround

By manually adjusting the spacing...

\(1 {\color{gray}\,+\,2}\)

2 Answers2

3

An explicit brace group creates a sub_mlist which will always be assigned class mathord (if I'm not mistaken). You can easily work around that problem by just using \begingroup...\endgroup instead of braces.

\documentclass{scrreprt}

\usepackage{xcolor}

\begin{document}
\(1 + 2\)

\(1 \begingroup\color{gray} + 2\endgroup\)

\end{document}

enter image description here

Henri Menke
  • 109,596
1

The problem is not the color but the group:

\documentclass{scrreprt}

\usepackage{xcolor}

\begin{document}
\(1 + 2\)

\(1 {+ 2}\)

\(1 {{} + 2}\)

\(1 {\color{gray} + 2}\)

\(1 {\color{gray}{} + 2}\)

\end{document}

enter image description here

Ulrike Fischer
  • 327,261