What is 'the right way' to insert an apostrophe at the start of a word?

What is ‘the right way’ to insert an apostrophe at the start of a word?
For instance, in the sentence “The year '26 just started”, or the family name of this gentleman, typst will turn the apostrophe into an opening quote.
I could insert an apostrophe, e.g., as:

#let apostrophe = "\u{2019}"
#{apostrophe}t Hooft

but this feels clunky for something that should be easy.

1 Like

That unicode character is named #sym.quote.r.single (see General Symbols – Typst Documentation).
It can be used directly in text like this:

The name #sym.quote.r.single;t Hooft starts with an apostrophe

But that’s annoying to type (note the ; between the symbol name and the t).

A more convenient way is to set up a show rule to apply this automatically:

The name 't Hooft starts with an apostrophe

#show "'t H": [#sym.quote.r.single;t H]

The name 't Hooft starts with an apostrophe

3 Likes

I’d recommend "'t Hooft", if using show rules, to prevent false positives.

Do Windows and the various flavours of Linux not have an easy was of entering it? On the Mac it is Alt+]; do the other OSes not have equivalents?

:slight_smile:
Mark

This is probably another instance of this issue: Smartquote incorrectly renders quote direction · Issue #7615 · typst/typst · GitHub

X11 and Wayland supports Compose key, but for some reason the default sequences are described in share/X11/locale/en_US.UTF-8/Compose. With compose = "${bat}/bin/bat ${xorg.libX11}/share/X11/locale/en_US.UTF-8/Compose"; alias in NixOS, I can quickly find the necessary stuff, or you can configure a custom file where you add your own compose sequences. For it’s:

<Multi_key> <greater> <apostrophe>  : "’" U2019 # RIGHT SINGLE QUOTATION MARK
<Multi_key> <apostrophe> <greater>  : "’" U2019 # RIGHT SINGLE QUOTATION MARK

So, Compose key then (' then > or > then '). Compose key is selected in the OS settings under keyboard/input.

Thanks. I was merely asking as a matter of information. I’m on Mac* so I use the Mac key-combo regularly, but was interested to know why the OP needed to ask his question and why the various much more convoluted solutions were needed.

* If Apple continues to produce bug-ridden versions of the OS like MacOS 26, I might jump ship to Linux at some point!

:slight_smile:
Mark

1 Like

Thanks everyone!
I try to use “US international with altgr deadkeys” as much as I can so is alt+9 and is alt+0. I just never needed those symbols, and they are not in my muscle memory, but this seems a good time to start doing that.

I guess I’ve seen to many computers with CP 1252 to sleep well using characters after \u{FF} in a language that wouldn’t need it per se…

For Dutch text ('m, 'n, 's and 't) and years without century, this should do the trick:

#show regex("'(\d\d|[mnst])\b"): it => {
  show "'": [#sym.quote.r.single]
  it
}

The idiomatic way would be:

#show regex("'(\\d{2}|[mnst])\\b"): it => {
  show "'": sym.quote.r.single
  it
}

Or better yet:

#show regex("'(\\d{2}|[mnst])\\b"): it => sym.quote.r.single + it.text.slice(1)

See https://typst.app/docs/reference/foundations/regex/#constructor-regex.