# Accented characters in vscode

In VScode, if I type θ \hat tab then the hat comes after the θ but the variable is usable.

θ̂ = 2.0

If instead I type \hat tab θ I get the hat sitting on top of the θ but Julia gives an error.

This issue is not specific to Greek characters: the same happens with x.

Is there a setting in VScode that I could change to make it both look right and not produce an error message? (I’ve looked but failed to find) Thanks!

What font are you using? If I type x \hat it produces the correct unicode character. This might seem like a font issue to me.

2 Likes

Thanks! (‘Droid Sans Mono’, ‘monospace’, monospace, ‘Droid Sans Fallback’) which I suspect is the default. I’ll experiment, but what is the font that you are using @affans ?

That definitely is a font issue. I’d recommend giving the excellent JuliaMono a shot.

5 Likes

JuliaMono seems to be a fan favourite, but I use Cascadia.

1 Like

You might find this useful: https://mono-math.netlify.app/ It shows how different monospace fonts compare for math symbols.

2 Likes

θ \hat should work, but I don’t think \hat θ will, because hat needs a character to sit on.

You can stack these too, so x \dot \vec should work (in the VS Code editor), font permitting.

2 Likes

Realize that this is not really LaTeX. You are not typing \hat{\theta} and having it typeset.

What is actually happening is that tab-completing \hat gives you the Unicode combining character U+0302 (combining circumflex accent). The way combining characters work in Unicode is that they modify the preceding character, in this cast to put a ^ over the preceding character. So, you have to put the \hat after the θ if you want a θ with a hat on top of it. (Though it may not render correctly if your font doesn’t support this combination.)

In addition to not rendering the way you want, putting the \hat first is not a valid Julia variable name — valid variable names must not begin with a combining character.

4 Likes