Skip to content

How to transform all uppercase words into smallcaps? #3927

Answered by epsilonError
ckunte asked this question in Q&A
Discussion options

You must be logged in to vote

OpenType Features

If your font implements the OpenType features, you could use the combination of "smcp" and "c2sc" in the features parameter for text.

E.g., you could use

// turn all uppercase words (with 2 or more characters) into smallcaps
#show regex("([A-Z]{2,})+"): sc => {
  text(features: ("smcp", "c2sc",))[#sc]
}

Enabling "smcp" is what smallcaps does behinds the scenes. And "c2sc" is an OpenType feature that substitutes capital letters with small caps. If you only want uppercase letters in small caps, you could use ("c2sc",) instead of ("smcp", "c2sc",).

Regex

You might also be able to simplify your Regex string from "([A-Z]{2,})+" to "[A-Z]{2,}". I'm not particularly proficient …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ckunte
Comment options

Answer selected by ckunte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants