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

% \DeclareMathSymbol{`}{\mathbin}{symbols}{^}

it is displayed enter image description here

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.


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

send {^}

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
  • 3
    If you want to live dangerously: \documentclass{article} \let\oldbacktick` \catcode``=\active \protected\def`{\ifmmode\expandafter^\else\expandafter\oldbacktick\fi} \begin{document} $3`2$ a`b \end{document} (see here). – user194703 Aug 20 '19 at 13:24
  • 1
    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:

$3`2$ and some `quoted' text

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:

$3`2$ and some \`quoted' text

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:

$3`2$ and some `quoted' text

the output is:

enter image description here

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

  • 3
    Hmmh, I was hoping that you would refer to my code as "cat code". ;-) – user194703 Aug 20 '19 at 13:44
  • 2
    @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
  • 1
    @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

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.