Quantcast
Channel: Active questions tagged uppercase - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 71

Capitalize first letter of non-latin word (utf-8 two bits)

$
0
0

There is plain \uppercase macro as well as \MakeUppercase in latex3. The last one works perfectly fine with two bits utf-8 characters as long as you explicitly brace the argument

\MakeUppercase{здравей}

Now I would like to capitalize the only the first letter of a word. Of course you can make it straight \MakeUppercase{з}дравей and it will work, however in the real use-case, the word is variable and stored in a macro:

\def\footext{здравей}\expandafter\MakeUppercase\footext

And here the problem rise up that David Carlisle greatly explained under this post: latex3 — issues with cyrillic.

Basically, because of that no command could grab first letter if not specified the argument explicitly:

\def\foo#1{#1}\foo здарвей % error, the argument is only the first bit of 'з'

Is there a clever yet simple way of getting the desired result despite the text? So that it should support both one bit and two bit characters (even mixed).


Meanwhile I tried to create a bulk workaround, based on Ulrike Fischer's solution of unprotecting utf-8 character.

\documentclass{article}\usepackage[T2A]{fontenc}\makeatletter\def\expandutfvii{%  \count@"C2  \@tempcnta"F5  \def\UTFviii@tmp{\expandafter\def\expandafter~\expandafter{~}}%  \UTFviii@loop}\makeatother\begin{document}\ExplSyntaxOn\expandutfvii\tl_set:Nn \l_tmpa_tl {здравей}\exp_last_unbraced:Nx \str_uppercase:n \l_tmpa_tl\ExplSyntaxOff\end{document}

It almost works, but I couldn't evaluate the string so that it would use those commands instead of printing thementer image description here


Viewing all articles
Browse latest Browse all 71

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>