I am working through the TeXbook and I came across the section (pg. 130) where `'`

and `\prime`

are discussed. Knuth mentions that TeX treats `\prime`

as a large symbol that appears only in superscripts instead of making it a smaller symbol that has already been shifted up into the superscript position. Part of the reason is because some authors actually use `\prime`

in the subscript position.

I know `$y'_1+y''_2$`

yields a typographical output equivalent to that of `$y^\prime_1+y^{\prime\prime}_2$`

, but I am wondering if there is an equivalent to `'`

for putting the `\prime`

into the subscript position.

For example, `$h'$`

is typographically equivalent to `$h^\prime$`

, but is `$h_\prime$`

equivalent to any "quicker" expression (i.e., involving an apostrophe or something similar)? I tried `$h_'$`

, but this produces an error; then I tried `$h_{'}$`

, but I realized this is equivalent to typing `$h_{{}^\prime}$`

.

Basically, is there a character `X`

where `$hX$`

and `$h_\prime$`

are equivalent?

## Best Answer

Just mimic what the kernel does for

`\prime`

:What does this do? First of all, a backquote in math mode is dealt with as if it were an active character, because of

`\mathcode`\`="8000`

; TeX will look for a definition of```

as active character, which is`\active@math@sprime`

.When it's found first in a possible sequence of backquotes, TeX expands

`\active@math@sprime`

, so doing`_\bgroup\sprim@s`

. This starts a subscript, exploiting the fact that`_\bgroup<tokens>\egroup`

is legal syntax. Now`\sprim@s`

is expanded, which typesets`\prime`

and doesThis looks at the following token, stores it into

`\@let@token`

without removing it from the input stream and executes`\spr@m@s`

.This macro does some tests:

if

`\@let@token`

is a backquote, the`\else...\fi`

part is removed by`\expandafter`

and`\spr@@@s`

is executed;if

`\@let@token`

is`_`

the`\else...\fi\fi`

part is removed by the triple`\expandafter`

and`\spr@@@t`

is executed;none of the above:

`\egroup`

is executed which will close the subscript.Now let's look at

`\spr@m@s`

: it is defined just to remove the next token (which is a backquote) and does`\sprim@s`

again. This is how`$h``$`

becomes`$h_\bgroup\prime\prime\egroup$`

.The macro

`\spr@@@t`

has two arguments: the first is`_`

which is simply gobbled and the second is the intended subscript, which is closed by`\egroup`

that balances the initial`\bgroup`

. This is how`$h`_{1}$`

becomes`$h_\bgroup\prime 1\egroup`

.