## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

#### View:

 Message: [ First | Previous | Next | Last ] By Topic: [ First | Previous | Next | Last ] By Author: [ First | Previous | Next | Last ] Font: Proportional Font

Subject:

Re: Rewriting polyglossia in LaTeX3

From:

Date:

Wed, 10 Nov 2010 17:45:37 +0000

Content-Type:

text/plain

Parts/Attachments:

 text/plain (109 lines)
 On 10/11/2010 17:25, Rémy Oudompheng wrote: > Hello everybody, > > I am interested in Unicode-capable TeX engines, and as such felt > that after fontspec and unicode-math, polyglossia would deserve > a rewrite for expl3. polyglossia currently uses etoolbox to > provide features much similar to what is offered by the LaTeX3 > packages, notably a lot of keyval-like features. I found benefits > in the nice syntax offered by l3keys, and the \prg_case_str > function for example. > > You may find a Git repository at > http://github.com/remyoudompheng/polyglossia > > I am looking for help in testing this, hoping that you will like it, > and I have also a question: for some reason, in polyglossia > we need to (un)capitalize words for use in csnames. > > I think I can produce somthing like this in LaTeX 3: > > \def\art{abc} > \def\func#1{\tl_to_uppercase:n{\tl_head:n{#1}}{\tl_tail:n #1}} > \def\frou#1{\exp_args:Nf\func#1} > \frou\art > > produces Abc as expected. > > The TeX code is polyglossia is like this: > > \def\xpg@uppercasefirst#1{\expandafter\xpg@@uppercasefirst #1} > \def\xpg@@uppercasefirst#1{% > \if a#1A\else > \if b#1B\else > \if c#1C\else > \if d#1D\else > ... \fi\fi\fi\fi > > I have been trying to replace it by something like > > \cs_new:Npn \polyg_uppercase_first:x{\tl_to_uppercase:n{\tl_head:n{#1}{\tl_tail:n > #1}} > > or some combination using \exp_args but the result was never > equivalent, since in polyglossia the input may be a complicated > macro and the output will be surrounded by \csname..\endcsname > > How should I do that ? > > Regards, > Rémy Oudompheng. > Hello Rémy, The issue of \tl_uppercase:n / \tl_lowercase:n is one that is on the list of things for the team to revisit and sort out properly. I guess now might be a good time to do that! For the moment, my approach to get this expandable would be to use \prg_case_str:nnn, which works nicely: \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_new_nopar:Npn \tl_upper_first:n #1 {    \prg_case_str:nnn      { \tl_head:n {#1} }      {        { a } { A }        { b } { B }        { c } { C }        { d } { D }        { e } { E }        { f } { F }        { g } { G }        { h } { H }        { i } { I }        { j } { J }        { k } { K }        { l } { L }        { m } { M }        { n } { N }        { o } { O }        { p } { P }        { q } { Q }        { r } { R }        { s } { S }        { t } { T }        { u } { U }        { v } { V }        { w } { W }        { x } { X }        { y } { Y }        { z } { Z }      }      { \tl_head:n {#1} }    \tl_tail:n {#1} } \edef\test{\tl_upper_first:n{abc}}\show\test \ExplSyntaxOff \begin{document} \end{document} This is more-or-less the same as the current implementation you have in the sense that all cases are considered. However, to my mind it's rather easier to read. The lower-case version would be done similarly but with a reversal of the input and output cases. -- Joseph Wright