0

I found a way to define a math symbol as follow:

\documentclass{article}

\makeatletter
\begingroup\lccode`~=`*
\lowercase{\endgroup\def~}{\times}
\mathcode`*="8000
\makeatother

\begin{document}
    $a*b$
\end{document}

enter image description here

Theh problem is that I have to assign a letter which appears on keyboard "*" to replace "\times" (that means the ASCII code is in range 0-255). Because function \lccode just accept value in that range.

How can I define an arbitrary math symbol and assign it to the same character? Something like:

\begingroup\lccode`~=`\times         % it doesn't work in this way
\lowercase{\endgroup\def~}{new\ \times}
\mathcode`\times="8000

In other words, we redefine a math symbol which has value of mathcode is out of ASCII range. Because we can do as follow:

\lccode`~=`0
\lccode`~=`\_
\lccode`~=`\=
 ...

but cannot with

\lccode`~=`\times
\lccode`~=`\star
...
7
  • 1
    rather than showing code that doesn't work and making us guess the intended effect it would be better to give a top level description of what you want to do. What input do you want in the file, and what typeset output do you want it to generate? Commented Jan 6, 2020 at 0:42
  • 1
    I don't get it. Why don't you just redefine \times? Like for example \let\normaltimes\times \renewcommand*\times{new\ \normaltimes} Commented Jan 6, 2020 at 0:44
  • >>@Henri Menke: Thank you. Your suggestion is so nice. I do that because I don't know how to redefine \times.
    – Nuec Tah
    Commented Jan 6, 2020 at 0:56
  • >>@David Carlisle: Thank for your feedback. I have just attended this forum, so I don't have experience. I will pay attention next time.
    – Nuec Tah
    Commented Jan 6, 2020 at 1:00
  • 1
    @Tauyeco I did not get notified about your reply, presumably because of the >> in front of the @ sign. Commented Jan 6, 2020 at 2:47

1 Answer 1

0

I found the answer from @Henri Menke (thank you for that). I realize that we should use \lccode to redefine symbols which are typed directly by single symbol. Regarding operators (such as \times, \div, etc.), which have mathcode's out of the range, we can redefine them by using:

\let <new command> <old command>
\renewcommand <old command> (<new reformation>)
4
  • 1
    It's not that the \mathcode is out of range for \times: \times cannot have a math code (as any other macro). You use the \mathcode for characters (only characters have a \mathcode), so you make them behave as if they were macros (like in your example you made the character * behave as the macro \times). For macros, you can just redefine them, as Henri suggested. Commented Jan 6, 2020 at 1:19
  • >>@Phelype Oleinik: Thank for your answer. It's so clear now.
    – Nuec Tah
    Commented Jan 6, 2020 at 1:22
  • 1
    note that lccode is the lower case code used for lower-casing text, you don't need to use it here it is just used in a trick way to avoid having to locally make the character active while defining it. A more straight forward definition would not use lccode here at all. Commented Jan 6, 2020 at 8:57
  • >>@David Carilisle: Thank you. Could you show me what is the straight forward definition? Because I haven't understood lccode deeply yet.
    – Nuec Tah
    Commented Jan 6, 2020 at 13:17

You must log in to answer this question.

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