# Replace backtick  with power/caret ^ in math mode

I'd like to declare the backtick symbol  to be the math operation power ^, so that by writing

\documentclass{article}
\usepackage{amsmath}
% \DeclareMathSymbol{}{\mathbin}{symbols}{^}
\begin{document}
$32$
\end{document}


it is displayed

I was thinking to use \DeclareMathSymbol{<symbol>}{<type>}{<sym-font>}{<slot>} but I'm not sure there is a slot code for ^ since it is an operation rather than a symbol.

I'd like to avoid using \newcommand because otherwise I will have to write 3\2 in order to get the power.

# PAINLESS SOLUTION

Install the lightweight program autohotkey and create a script with the following code

NumLock::
send {^}
return


once run, you can print the caret symbol ^ by pressing the Num Lock key in the numpad.

You can change NumLock to whatever you want, check the list of all keys and the list of all hotkeys, for example

MButton::     middle/wheel mouse button
^p::          ctrl+p
+p::          shift+p
F2::          F2

• If you want to live dangerously: \documentclass{article} \let\oldbacktick \catcode=\active \protected\def{\ifmmode\expandafter^\else\expandafter\oldbacktick\fi} \begin{document} $32$ ab \end{document} (see here). – Schrödinger's cat Aug 20 '19 at 13:24
• Out of curiosity, why? Is it simply to avoid hitting the shift key? – Teepeemm Aug 20 '19 at 13:29
• @Teepeemm Yes i know i'm lazy but i'm going to type thousands of ^, i solved with a small autohotkey script which prints ^ when i press NumLock – sound wave Aug 20 '19 at 14:26

All of this is really not recommended, unless you really know what you are doing and/or is willing to suffer the consequences. In the words of Mr. Cat, this is "living dangerously", and you may end up being dead when someone opens the box ;-)

\DeclareMathSymbol is used to select the glyph in a font which will be used to write a specific symbol on the paper. The superscript happens in a much lower level in TeX. Usually, the ^ symbol has the category code (catcode) 7, which is a "superscript token". This means that whenever TeX sees a ^, it will make a superscript. At the simplest, you can have that effect by changing the catcode of a  to 7:

\documentclass{article}
\catcode\=7
\begin{document}
$32$ and some quoted' text
\end{document}


however, the code above will raise a Missing $inserted because now that  is a superscript character, it is only meant to be used in math-mode. You can redefine \ to mean a "normal" (catcode 12)  character: \documentclass{article} \renewcommand\{} \catcode\=7 \begin{document}$32$and some \quoted' text \end{document}  and then you won't be able to write a grave accent with, say, D\'ej\a vu (the output will be "Déj‘a vu"). Plus, any code which relies on  being a catcode-12 token will fail miserably. A arguably better alternative is to make the  an active character only in math-mode and define it equal to a superscript token: \documentclass{article} {\catcode\=\active \global\let=^} \mathcode\="8000 \begin{document}$32\$ and some quoted' text
\end{document}


the output is:

But again, this might break something, somewhere, which relies on  being a catcode 12 token.

• Hmmh, I was hoping that you would refer to my code as "cat code". ;-) – Schrödinger's cat Aug 20 '19 at 13:44
• @Schrödinger'scat LOL! How could I miss that? :-) – Phelype Oleinik Aug 20 '19 at 13:49
• Related: Let ' print a straight quote – Olivier Cailloux Dec 28 '19 at 9:20
• Any examples of package that this code would break, or other problems arising due to the change of catcode? – Olivier Cailloux Dec 28 '19 at 9:21
• @OlivierCailloux The third alternative is rather safe, as no catcode is changed and only the meaning of the symbol in math-mode is affected. The first two, however, will break anything that relies on  being a catcode-12 character. The backtick is especially bad. Just try \usepackage{etoolbox} (for example) after changing the catcode of  to 7. – Phelype Oleinik Dec 28 '19 at 10:48