How to print overline or bar on top of character

The overline is often used to indicate the sample mean. In LaTeX, we could use something like \bar{x} or \overline{x}, is there a way to achieve this in GMT?

{\overline {x}}

The unicode code for overline is U+203E if it helps. I’ve tried looking at https://docs.generic-mapping-tools.org/6.1/text.html#composite-characters and https://docs.generic-mapping-tools.org/6.1/cookbook/features.html#character-escape-sequences but couldn’t seem to figure out how to overlay a line on top of another character.

Perhaps this is what you want:

echo 5 5 '@!\257x' | gmt text -R0/10/0/10 -JX10 -png map

map

To follow-up on this …

Could future version of GMT support LaTeX syntax ? @maxrjones ?

Well, support the syntax maybe, but making it plot LaTeX without LaTeX, that is more difficult. However, it looks like it’s possible. At least this Julia package is able to do it. Just have no idea on how.

A few years ago (summer 2017 I think) I played with this via a system call to pdflatex or similar. It was partly successful but requires the full Latex machinery etc. I know many would like to have this feature but clearly we are not going to write a Latex parser for GMT. As @seisman indicates you can do some basic stuff in GMT with the composite character effect, plus sub/subscripts, but you cannot do complicated things like fractions. I am sure I have no records of what I tried 3 years ago but maybe I can assemble enough for a feature request posting.

That’s the interest of that GR program I linked above. It doesn’t require any Latex installation but still manages to print Latex!!!

Cool, thanks @seisman! This works for ordinary alphabetical characters (abc), but is there a way to plot the overline on top of Greek characters like \tau (which would be @~t@~ in GMT)? The following result doesn’t seem correct.

echo 5 5 '@~@!\257t@~' | gmt text -R0/20/0/20 -JX10 -png map

wrong overline on tau

Also tried @!\257@~t@~ but that ended up trying to plot the overline on top of @ instead of \tau:

map

Edit: Nevermind, the problem is only on GMT 6.0.0. Things work properly on GMT 6.1.1:

echo 5 5 '@!\257@~t@~' | gmt text -R0/20/0/20 -JX10 -png map

map