# How to add letters above equal sign

I’d like to be able to add letters above an equal sign. For example, adding “def” to indicate that this equality is a definition.

In TeXmacs, the closest thing I found is to first type `=` and then type `^`. However, the result is not very visually pleasing as shown below.

You can see that the `d` is above `=` too much, and the `=` got stretched also a bit too much. I’m looking for more of the effect shown in this LaTeX post How do I put text over symbols?. Thanks!

You can get something similar with `\above` (or `Insert->Script->Script above`):

Thanks for the reply. Using `script above` will get rid of the stretching but there’s still too much space between the letter and the equal sign. It seems that the lower boarder of the letter is at the same height as the upper boarder of the symbols around the equal sign, whereas in the LaTeX case the letter gets closer to the equal sign.

You can do some more tweaking with `Format->Transform->Move` or `Shift`

1 Like

And then assign the well-positioned symbol to either a macro or a keyboard shortcut.

1 Like

Thanks. This achives what I want.

``````<assign|def|<macro| <above|=|<shift|d||-2pt>> >>
``````

Two spaces around the `above` is needed so that the two symbols around the equal sign get separated from it.

1 Like

Does anyone know if it is possible to make the typeset form of an expression take the same space as the typeset form of another expression?
I think it would be very nice to get the “def” macro take the same space as the equal symbol, with the same spacings between the symbol and the left and right-hand sides of the definition.

Perhaps this:

``````<assign|def|<macro|<shift|<superpose|<shift|<above|=|<shift|d||-2pt>>|-.5w|>|<phantom|<space|0pt>=<space|0pt>>>|.5w|>>>
``````

I use the box lengths (TeXmacs manual, section 14.8) to move first the
`<shift|<above|=|<shift|d||-2pt>>`
back by one half of itself, then forward by one half of
`<phantom|<space|0pt>=<space|0pt>>` which I hope is an equal sign with the correct spacing (I forgot how to put a blank lhs and rhs to generate the spacings around the equal sign).

1 Like

I would not use “pt” but “em” as unit of measure, since “pt” is absolute while “em” is relative to the current font so it will change accordingly if the font size changes. Same considerations with “px” vs. e.g. “ln”

2 Likes

Following up from @mgubi’s suggestion above:

`<assign|def|<macro|<shift|<superpose|<shift|<above|=|<shift|d||-.2em>>|-.5w|>|<phantom|<space|0em>=<space|0em>>>|.5w|>>>`

2 Likes