4

I would like to write strings that contain asterisks, but LaTeX sees the asterisks as infix operators and surrounds them with spaces. How can I switch this off?

\[
 aaa*aaa*aaa
\]

Should look like

\[
aaa\!*\!aaa\!*\!aaa 
\]
2
  • 1
    Actually, shouldn't you want the look of $aaa{*}aaa{*}aaa$ if the objective is to print the string as is? By default, TeX places \medmuskip between items of the mathord and mathbin; using \! removes only \thinmuskip, not \medmuskip.
    – Mico
    Commented Dec 1, 2016 at 22:09
  • Is the * symbol the only one that's causing trouble, or are there other symbols of type mathbin or mathrel inside the strings that need to be printed "as is"?
    – Mico
    Commented Dec 1, 2016 at 22:27

1 Answer 1

4

If you never need * as an infix binary operator, you can change its math code:

\documentclass{article}
\usepackage{amsmath}

\mathcode`*=\numexpr\mathcode`*-"2000\relax

\begin{document}

\[
aaa*aaa*aaa
\]

\end{document}

enter image description here

If it is for a one-off case,

\[
aaa{*}aaa{*}aaa
\]

would do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .