Coders have it easy. When they want to cast a variable name between cases there are a myriad of libraries for the purpose. Writers have it harder. Each language comes with its own challenges, and most have more than one style guide. In the case of English, even the style guides can leave much up to interpretation.
This demo is interesting not because different typesetting engines handle this either the same or differently, but because one library can be used in more than one engine. Specifically the decasify project implements various prose casing functions and can be used as a native package in either SILE or Typst.
\begin[papersize=a6]{document} \font[family=Libertinus Serif] \nofolios \neverindent \use[module=packages.decasify] \begin{lua} local examples = { { "first impulse", lang = "en" }, { "FIRST IMPULSE", lang = "en" }, { "ilk ışıltı", lang = "tr" }, { "İLK IŞILTI", lang = "tr" }, } for _, case in ipairs({ "title", "lower", "upper", "sentence" }) do SILE.call("bigskip") SILE.call("font", { size = "18pt", weight = 800 }, function () SILE.call("decasify", { case = "title" }, { case .. "case" }) end) SILE.call("par") for _, s in ipairs(examples) do SILE.typesetter:typeset(("[%s] "):format(s.lang)) SILE.call("font", { language = s.lang }, function (_, _) SILE.typesetter:typeset(("%s → "):format(s[1])) SILE.call("decasify", { case = case }, s) end) SILE.call("par") end end \end{lua} \end{document}
sile -o title-case-sile.pdf title-case-sile.sil
#import "@preview/decasify:0.9.0": * #set page(paper: "a6") #let examples = ( (str: "first impulse", lang: "en"), (str: "FIRST IMPULSE", lang: "en"), (str: "ilk ışıltı", lang: "tr"), (str: "İLK IŞILTI", lang: "tr"), ) = Titlecase #for s in examples [ #set text(lang: s.lang) [#context(text.lang)] #s.str → #titlecase(s.str) \ ] = Lowercase #for s in examples [ #set text(lang: s.lang) [#context(text.lang)] #s.str → #lowercase(s.str) \ ] = Uppercase #for s in examples [ #set text(lang: s.lang) [#context(text.lang)] #s.str → #uppercase(s.str) \ ] = Sentencecase #for s in examples [ #set text(lang: s.lang) [#context(text.lang)] #s.str → #sentencecase(s.str) \ ]
typst compile title-case-typst.typ title-case-typst.pdf