Printing letter C with caron

Now you can try "@[\v{c}@["

I tried taking your expression and including the c-caron:

gmt begin GMT_latex
	gmt set GMT_THEME cookbook
	gmt basemap -R-200/200/0/2 -JX15c -Bxaf+l"@[ \v{c} \nabla^4 \psi - \Delta \sigma_{xx}^2@[ (MPa)" -BS
gmt end show

But nothing appears like a “č”, in the output PDF.

I just read chapter 13 in the GMT technical reference and saw the recommended TeX iinstallation. I’ve installed the texlive apps through MacPorts. That didn’t help. The @[\v{c}@[ still isn’t showing up in the output PDF.

Do you have an error message or something?
Does the first command ressembles this :


?

Yes, looks just like that, on the first try. But still looks like that when I used the \v{c} in my second try. No error messages.

try \capitalcaron{c} ?

Nice try, but not getting it yet. I tried this:

gmt begin GMT_latex
	gmt set GMT_THEME cookbook
	gmt basemap -R-200/200/0/2 -JX15c -Bxaf+l"@[\capitalcaron{c}@[ (MPa)" -BS
gmt end show

and got this:

Try \check{c}

Yes, that works, but the “c” is italic.

Additionally, the situation I’m working involves a list of items that I pass through pstext, inside of a non-LaTeX, classic GMT mode, script (in x y text format).

Although you’ve taught me how to create a c with a caron, I’m not sure how to adapt my script to read this list of items and translate the č characters that appear in the list to something GMT can print on a map/graphic.

Have you tried to just update the 3rd column ?

I think all text in latex is italic. Maybe some \normal{\check{c}} could modify the style?

Yes, Gus, that is what I’m trying to do. I was successful with the \check{c}, but it came out as italic, which didn’t look good in the middle or end of a person’s name.

I even went as far as trying to use the over-strike escape sequence (@!) but was only able to get the caron next to the letter c.

Using this entry (from my list):

   168.8    77.2 Milankovi@[\normal{\check{c}}@[

yielded this output:

Screenshot 2024-05-06 at 11.41.48 AM

ugly but seems working; nobody will probably like it.
the character code comes from ISO/IEC 8859-2 - Wikipedia

gmt basemap -R-200/200/0/2 -JX5c/0c -Bxaf+l"Milankovi\350" -png char --PS_CHAR_ENCODING=ISO-8859-2

char

Thanks, mkono, I think that is the answer. Just need to get the s and r with the carons. I’ll study the character codes.

That \check{c} is in math-mode, so I guess that @[ ... @[ syntax is for TeX math mode (and that explains the italic). In that case \text{\Milankovi\v{c}} might work but would be in the TeX font, probably not what you want – using the ISO8850-2 code codes does sound a better bet …

Hm. I just looked how this can be accomplished in PyGMT and at least for me, @! works to combine any letter with a v on top (\237):

import pygmt

size = 5

fig = pygmt.Figure()
fig.basemap(
    region=[-size, size, -size, size],
    projection=f"X{size}c",
    frame="x+l@!s\\237  @!r\\237  @!c\\237",  # two \ needed in PyGMT / Python
)
fig.text(position="MC", text="@!s\\237  @!r\\237  @!c\\237")
fig.colorbar(cmap="batlow", position="jTC", frame="x+l@!s\\237  @!r\\237  @!c\\237")
fig.show()

somewhat nicer solution, using iconv to convert text labels into ISO-8859-2:

cat <<EOF | iconv -f utf8 -t iso8859-2 | gmt text -JX5c -R0/3/0/3 -F+jMC -png chars -Bxa -Bya -BWSen --PS_CHAR_ENCODING=ISO-8859-2
1    1 Milošević
2    2 Milankovič
EOF

I can imagine running iconv on the whole gmt shell script so all the utf text strings get converted into ISO-8859-2, including axis labels, titles that could not be specified in a separate text file. Could not quickly imagine a practical way of doing the same to a pygmt script.

Quite an annoying thing.

That’s cool Yvonne. Glad you posted that so that future users will hopefully find it.

Earlier, I tried something like that but had the letter following the escaped octal code. Additionally, I failed to double slash the octal code. No wonder my initial attempt didn’t really work. Your approach works beautifully.

Your example is terrific if you’re typing these characters directly into your code. I was reading a rather large file that already had special characters embedded in it.

I wound up using the solution offered by mkononets, by literally editing my input file to swap all those kinds of characters (including the umlaut letters) with their equivalent octal codes. I feed the file to pstext while specifying:
--PS_CHAR_ENCODING=ISO-8859-2.

The file isn’t used for anything outside of GMT, so I don’t care how ugly it looks! I could just as easily revert back to Latin1+ and use your method.

I just have to mention this in this post: It is really cool to see how many people posted ideas and approaches to accomplish writing this letter :eyes:! It’s great to see and have such a supportive community :smiley:!

1 Like

just realized that extra escaping for the backslash chars can be avoided using Python’s r'' strings notation: frame=r'x+l@!s\237 @!r\237 @!c\237' etc

Actually, in PyGMT, you can use non-ASCII characters directly, rather than using \237 or \\237:

import pygmt

size = 5

fig = pygmt.Figure()
fig.basemap(
    region=[-size, size, -size, size],
    projection=f"X{size}c",
    frame="x+l@!sˇ  @!rˇ  @!cˇ", 
)
fig.text(position="MC", text="@!sˇ  @!rˇ  @!cˇ")
fig.colorbar(cmap="batlow", position="jTC", frame="x+l@!sˇ  @!rˇ  @!cˇ")
fig.show()

Currently, PyGMT supports all non-ASCII characters in the Adobe Symbols, Adobe ZapfDingbats and ISOLatin1+ charsets. We also plan to support more charsets like ISO-8859-2 in WIP + POC: Improved support of non-ASCII characters by seisman · Pull Request #3206 · GenericMappingTools/pygmt · GitHub, but it’s still WIP. After charsets like ISO-8859-2 are supported, you should be able to use č directly in PyGMT!

Sounds great! Using characters outside ISOLatin1+ in gmt has been a really annoying thing for a very log time.