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.

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

enter image description here


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

$ x * y $

| improve this answer | |
  • 4
    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. – David Carlisle Sep 23 at 11:03
  • how about textmode for example define . to appears as - ? – Salim Bou Sep 23 at 11:36
  • 2
    @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 – David Carlisle Sep 23 at 11:48
  • This is just an example my question is how to do the same in textmode not exactly with dot but with any other char. – Salim Bou Sep 23 at 11:55
  • 3
    @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. – David Carlisle Sep 23 at 13:21







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

| improve this answer | |
  • 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. – egreg Sep 23 at 14:10
  • Mainly hoping that the context displayed in the error message would be clearer. – Donald Arseneau Sep 24 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 *.

$ x \* y $

enter image description here

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

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

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

\AtBeginDocument{\Umathcode`\* = 2 0 "22C5}
| 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.