# Define a star "*" - to become a dot

When writing in mathmode, is it possible to define a * to become \cdot, in the main document?

As it makes it easier when writing equations to make a star.

• Just hope you don't need any star macros in math mode...Just sayin' Sep 23, 2020 at 11:17
• @StevenB.Segletes \star will do, in that case. Sep 24, 2020 at 10:18

\documentclass{article}

% \DeclareMathSymbol{\cdot}{\mathbin}{symbols}{"01} % from fontmath.ltx
\DeclareMathSymbol{*}{\mathbin}{symbols}{"01}
\begin{document}

$x * y$

\end{document}
• Donald just beat me to it by a second or two , but mine's a bit more latex-y and comes with a picture, so I posted anyway. Sep 23, 2020 at 11:03
• how about textmode for example define . to appears as - ? Sep 23, 2020 at 11:36
• @SalimBou you want to make every full stop a dash???? That is a lot harder if you want to not break uses such as width=0.5\textwidth Sep 23, 2020 at 11:48
• @SalimBou classic tex has no corresponding feature for text mode. You can make the character active and give it a definition, just as ~ is \nobreakspace but for example if you made * active to make it . in text mode, all * forms of commands like \section* would break unless you changed them to match, which would then break many packages handling section headings... so for ? \catcode?\active \def?{!} but things will break. Sep 23, 2020 at 13:21
• @Gooz well there I used {symbols}{"01} so will use whatever font is set up as the symbol font, doesn't have to be computer modern. If you have declared an additional font and you want to use that just reference that instead of symbols Oct 24, 2020 at 12:04

Either

\mathcode\*=\number\cdot

or

\mathcode\*=\number\circ

or

\mathcode\*=\number\bullet

(The \number isn't really necessary, but it might help for abnormal versions of \circ or \cdot or \bullet.)

• If a class or package defines \cdot to be \mathbin{foo}, using \number would do nothing good. I'm not sure what “abnormal” definition you're thinking to. Sep 23, 2020 at 14:10
• Mainly hoping that the context displayed in the error message would be clearer. Sep 24, 2020 at 9:50

As I pointed out in a comment, redefining the use of * in the wrong way will prevent you from using star versions of math-mode macros (see partial list below*). For example, making * active would be the wrong way. However, David C and Don both note that their approaches do not suffer this problem, and I was negligent for not noting the distinction.

While the use of star macros in math mode may be rare, it occurs often enough to warrant avoiding an approach that would use an active *. Even if you use David's approach, you lose the use of the typeset asterisk in math mode, unless you save it beforehand into a named macro.

An alternative that does not mess with * in any way would be to redefine \*. This is a plain-Tex macro known as a "discretionary multiplication sign". I've never used it myself, but the idea is that you can place it between multiplied math terms. Normally, it does nothing, but if the line breaking wants to happen between the two terms, a symbol (equivalent to \times) is inserted at the line end (in text size). It acts like a mathematical hyphen, but with \times instead of -. If you, like me, never use such a construct, then I think it would be safer to redefine \* rather than *.

\documentclass{article}
\renewcommand\*{\cdot}
\begin{document}
$x \* y$
\end{document}

*Examples of star macros include things like \tag*, \ref*, \\*, \matrix* (and all its variants), \operatorname*, \alignat*, just to get started.

• the definition I gave in my answer would not affect * forms in math mode, so I am not sure I follow your first sentence? Sep 23, 2020 at 18:15
• @DavidCarlisle Thanks for pointing that out. I will revise my answer. Sep 23, 2020 at 18:29
• @DavidCarlisle Please check to see if I have mischaracterized the situation, upon EDIT. I apologize for the prior omission. Sep 23, 2020 at 18:36
• :-)............ Sep 23, 2020 at 18:40
• None of the other answers "redefine" the * character; they do not change how * is interpreted in text or in syntactical contexts. Sep 24, 2020 at 9:48

For the sake of completness, version for unicode-math:

\documentclass{article}
\usepackage{unicode-math}
\AtBeginDocument{\Umathcode`\* = 2 0 "22C5}
\begin{document}
$x*y$
\end{document}