texlive[61876] Master/texmf-dist: crefthe (4feb22)

commits+karl at tug.org commits+karl at tug.org
Fri Feb 4 23:20:00 CET 2022


Revision: 61876
          http://tug.org/svn/texlive?view=revision&revision=61876
Author:   karl
Date:     2022-02-04 23:19:59 +0100 (Fri, 04 Feb 2022)
Log Message:
-----------
crefthe (4feb22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/crefthe/README.md
    trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf
    trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex
    trunk/Master/texmf-dist/tex/latex/crefthe/crefthe.sty

Modified: trunk/Master/texmf-dist/doc/latex/crefthe/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/crefthe/README.md	2022-02-04 22:19:45 UTC (rev 61875)
+++ trunk/Master/texmf-dist/doc/latex/crefthe/README.md	2022-02-04 22:19:59 UTC (rev 61876)
@@ -1,4 +1,4 @@
-<!-- Copyright (C) 2021 by Jinwen XU -->
+<!-- Copyright (C) 2021-2022 by Jinwen XU -->
 
 # crefthe - cross referencing with proper definite articles
 
@@ -28,7 +28,7 @@
 ## The solution
 
 Thus, it would be better to have a new command `\crefthe[<prep>]{<labels>}`, and to use it like
-```
+```latex
 \crefthe[de]{thm1,thm2,prop3}
 ```
 in order to get "*des théorèmes 1 et 2 et de la proposition 3*".
@@ -35,13 +35,18 @@
 
 # Usage
 
-Just load the package with
+Simply load the package with:
 ```latex
 \usepackage{crefthe}
 ```
 > "crefthe" uses "cleveref" internally, thus it should usually be placed at the last of your preamble.
 
-And then you can use the command `\crefthe` as follows:
+Before everything, you need to define the names, which can be done with `\crefthename`. Its syntax is similar to `\crefname`, but now you can specify the definite articles, for example:
+```latex
+\crefthename{theorem}[le]{théorème}[les]{théorèmes}
+```
+
+Then you can use the command `\crefthe` as follows:
 - `\crefthe[<prep>]{<labels>}`
    - This will pass the preposition `<prep>` to the definite articles that follows. Its behavior depends on the current language (for example, in Spanish, `<prep>` is passed only to the first definite article, while in French it is passed to everyone).
 - `\crefthe-[<prep>]{<labels>}` and `\crefthe+[<prep>]{<labels>}`
@@ -49,12 +54,8 @@
 
 > There is also a stared version `\crefthe*` for generating the same text but without hyperlinks.
 
-However, before using it, you should first define the `\crefname`s carefully. The definite article in `\crefname`s needs to be marked manually using `\crefthemark`, for example:
-```latex
-\crefname{theorem}{\crefthemark{le} théorème}{\crefthemark{les} théorèmes}
-```
+*For more information, please refer to its documentation.*
 
-
 # License
 
 This work is released under the LaTeX Project Public License, v1.3c or later.

Modified: trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex	2022-02-04 22:19:45 UTC (rev 61875)
+++ trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex	2022-02-04 22:19:59 UTC (rev 61876)
@@ -89,8 +89,8 @@
 
 \title{\crefthepackage{} - cross referencing with proper definite articles}
 \author{Jinwen XU}
-\thanks{Corresponding to: \texttt{\crefthepackage{} 2022/01/29}}
-\date{January 2022, in Paris}
+\thanks{Corresponding to: \texttt{\crefthepackage{} 2022/02/04}}
+\date{February 2022, in Paris}
 
 \maketitle
 
@@ -226,15 +226,17 @@
 
 \crefthepackage{} loads \textsf{cleveref} automatically and pass all the options to it. All its commands, used without optional arguments, degenerate to those in \textsf{cleveref}. For example, \lstinline|\crefthe{...}| is the same as \lstinline|\cref{...}|, and \lstinline|\crefthename| is the same as \lstinline|\crefname| if the definite articles are not specified. That said, you can safely use the command \lstinline|\crefthe| everywhere in your document without causing extra trouble.
 
+With the option \texttt{overwrite}, user commands in \textsf{cleveref} will be replaced by those offered here, thus you can simply write \lstinline|\cref| for \lstinline|\crefthe| -- and similarly for \lstinline|\Cref|, \lstinline|\crefname| and \lstinline|\Crefname|.
+
 \section{For multi-language documents}
 
-To place hyperlinks at the right place, \lstinline|\crefthename| touches the corresponding \lstinline|\crefformat| internally, which makes it language-dependent. If you are writing multi-language documents, you may like to consider putting \lstinline|\crefthename| inside your language configuration so as to reset it each time you select a new language.
+To place hyperlinks at the right place, \lstinline|\crefthename| touches the corresponding \lstinline|\crefformat| internally, which makes the format language-dependent. If you are writing multi-language documents, you may consider putting \lstinline|\crefthename| inside your language configuration so as to reset it each time you select a new language.
 
 \section{Known issues}
 \begin{itemize}
-    \item \crefthepackage{} currently only works for French, Italian, Portuguese (European and Brazilian) and Spanish, certainly more would be added to this list.
-    \item The current mechanism does not work for German. However, the author has planed to adopt a more refined approach in later versions in order to support the various situations in German.
-    \item For now, the automatic case changing mechanism only works properly under Unicode based engines. If you are using pdf\LaTeX{} or typing accented letters with text commands, \lstinline|\Crefthe| will not work as expected.
+    \item \crefthepackage{} currently works for French, Italian, Portuguese (European and Brazilian) and Spanish, certainly more would be added to this list.
+    \item The current mechanism does not work for German. The author plans to adopt a more refined approach in later versions in order to support the various situations in German.
+    \item For now, the automatic case changing mechanism only works properly under Unicode based engines. If you are using pdf\LaTeX{} or typing accented letters with text commands, \lstinline|\Crefthe| may not work as expected.
     % \item In case that the initial letter of \meta{prep} is capitalized, \crefthepackage{} cannot yet handle the case changes automatically. However, this should be a rare occurrence.
     \item The names of theorem-like environments are not provided --- for the moment you need to define them all by yourself. However, users are encouraged to use the \ProjLib{} toolkit, which already handles everything for you.
 \end{itemize}

Modified: trunk/Master/texmf-dist/tex/latex/crefthe/crefthe.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/crefthe/crefthe.sty	2022-02-04 22:19:45 UTC (rev 61875)
+++ trunk/Master/texmf-dist/tex/latex/crefthe/crefthe.sty	2022-02-04 22:19:59 UTC (rev 61876)
@@ -10,281 +10,327 @@
 %%    http://www.latex-project.org/lppl.txt
 %%
 \NeedsTeXFormat{LaTeX2e}[2020-10-01]
+\RequirePackage{l3keys2e}
 \ProvidesExplPackage
   {crefthe}
-  {2022/01/29}
-  {}
+  {2022/02/04} {}
   {Cross referencing with proper definite articles}
-\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{cleveref}}
-\ProcessOptions\relax
+
+\keys_define:nn {crefthe}
+  {
+    , overwrite .bool_set:N = \l__crefthe_overwrite_bool
+    , overwrite .initial:n = { false }
+    , unknown .code:n =
+        {
+          \PassOptionsToPackage { \CurrentOption } {cleveref}
+        }
+  }
+\ProcessKeysOptions{crefthe}
+
 \RequirePackage{cleveref}
 
-\tl_gset:Nn \g_crefthe_prepf_tl {}
-\tl_gset:Nn \g_crefthe_prep_tl {}
-\tl_gset:Nn \g_crefthe_sep_tl {}
-\cs_new:Nn \crefthe_case:n {#1}
-\cs_new:Nn \crefthe_nochange:n {#1}
-\cs_new:Nn \crefthe_atbegindocument:n {#1}
+\cs_set_eq:cc {crefthe_cref_original:n} {cref}
+\cs_set_eq:cc {crefthe_Cref_original:n} {Cref}
+\cs_set_eq:cc {crefthe_crefname_original:n} {crefname}
+\cs_set_eq:cc {crefthe_Crefname_original:n} {Crefname}
 
-\cs_new:Nn \crefthe_set_status_atbegindocument: {
-    \cs_if_eq:NNTF \@onlypreamble \@notprerr {
-        \cs_gset_eq:NN \crefthe_atbegindocument:n \crefthe_nochange:n
-    }{
-        \cs_gset_eq:NN \crefthe_atbegindocument:n \AtBeginDocument
-    }
-}
+\bool_if:NT \l__crefthe_overwrite_bool
+  {
+    \hook_gput_next_code:nn {package/crefthe/after}
+      {
+        \cs_set_eq:cc {cref} {crefthe}
+        \cs_set_eq:cc {Cref} {Crefthe}
+        \cs_set_eq:cc {crefname} {crefthename}
+        \cs_set_eq:cc {Crefname} {Crefthename}
+      }
+  }
 
-\NewDocumentCommand{\crefthe}{st-t+O{}m}{
-    \IfBooleanTF{ #2 }{
-        \tl_gset:Nn \g_crefthe_prepf_tl { #4 }
-    }{
-        \IfBooleanTF{ #3 }{
-            \tl_gset:Nn \g_crefthe_prep_tl { #4 }
-        }{
-            \str_case_e:nn { \crefthe_prep_mode:nn } {
-                { - } { \tl_gset:Nn \g_crefthe_prepf_tl { #4 } }
-                { + } { \tl_gset:Nn \g_crefthe_prep_tl  { #4 } }
-            }
-        }
-    }
-    \IfBooleanTF{ #1 } { \cref*{#5} } { \cref{#5} }
-    \tl_gset:Nn \g_crefthe_prep_tl {}
-}
+\tl_new:N \g__crefthe_prep_once_tl
+\tl_new:N \g__crefthe_prep_each_tl
 
-\NewDocumentCommand{\Crefthe}{st-t+O{}m}{
-    \cs_gset_eq:NN \crefthe_case:n \text_titlecase:n
-    \IfBooleanTF{ #2 }{
-        \tl_gset:Nn \g_crefthe_prepf_tl { #4 }
-    }{
-        \IfBooleanTF{ #3 }{
-            \tl_gset:Nn \g_crefthe_prep_tl { #4 }
-        }{
-            \str_case_e:nn { \crefthe_prep_mode:nn } {
-                { - } { \tl_gset:Nn \g_crefthe_prepf_tl { #4 } }
-                { + } { \tl_gset:Nn \g_crefthe_prep_tl  { #4 } }
-            }
-        }
-    }
-    \IfBooleanTF{ #1 } { \Cref*{#5} } { \Cref{#5} }
-    \tl_gset:Nn \g_crefthe_prep_tl {}
-}
+\tl_new:N \l__crefthe_prep_mode_tl
 
-\NewDocumentCommand{\crefthename}{mO{}mO{}m}{
-    \str_if_eq:eeTF {#2} {} {
-        \crefname{#1}{#3}{#5}
-        \cs_set:cn {cref_#1_format:nnn} {##2#3~##1##3}
-        \cs_set:cn {cref_#1_format_first:nnn} {##2#5~##1##3}
-    }{
-        \crefname{#1}{\crefthemark{#2} \g_crefthe_sep_tl #3}{\crefthemark{#4} \g_crefthe_sep_tl #5}
-        \cs_set:cn {cref_#1_format:nnn} {\crefthemark{#2} \g_crefthe_sep_tl ##2#3~##1##3}
-        \cs_set:cn {cref_#1_format_first:nnn} {\crefthemark{#4} \g_crefthe_sep_tl ##2#5~##1##3}
-    }
-    \crefthe_set_status_atbegindocument:
-    \crefthe_atbegindocument:n {
-        \cs_set_eq:cc {cref@#1 at format} {cref_#1_format:nnn}
-        \cs_set_eq:cc {cref@#1 at format@first} {cref_#1_format_first:nnn}
-    }
-}
+\cs_new:Nn \crefthe_case:n { #1 }
+\cs_new:Nn \crefthe_nochange:n { #1 }
 
-\NewDocumentCommand{\Crefthename}{mO{}mO{}m}{
-    \str_if_eq:eeTF {#2} {} {
-        \Crefname{#1}{#3}{#5}
-        \cs_set:cn {Cref_#1_format:nnn} {##2#3~##1##3}
-        \cs_set:cn {Cref_#1_format_first:nnn} {##2#5~##1##3}
-    }{
-        \Crefname{#1}{\crefthemark{#2} \g_crefthe_sep_tl #3}{\crefthemark{#4} \g_crefthe_sep_tl #5}
-        \cs_set:cn {Cref_#1_format:nnn} {\crefthemark{#2} \g_crefthe_sep_tl ##2#3~##1##3}
-        \cs_set:cn {Cref_#1_format_first:nnn} {\crefthemark{#4} \g_crefthe_sep_tl ##2#5~##1##3}
-    }
-    \crefthe_set_status_atbegindocument:
-    \crefthe_atbegindocument:n {
-        \cs_set_eq:cc {Cref@#1 at format} {Cref_#1_format:nnn}
-        \cs_set_eq:cc {Cref@#1 at format@first} {Cref_#1_format_first:nnn}
-    }
-}
+\NewDocumentCommand \crefthe { s t- t+ O{} m }
+  {
+    \bool_if:nTF { #2 }
+      {
+        \tl_gset:Nn \g__crefthe_prep_once_tl { #4 }
+      }
+      {
+        \bool_if:nTF { #3 }
+          {
+            \tl_gset:Nn \g__crefthe_prep_each_tl { #4 }
+          }
+          {
+            \exp_args:Nx \str_case:nn \l__crefthe_prep_mode_tl
+              {
+                { - } { \tl_gset:Nn \g__crefthe_prep_once_tl { #4 } }
+                { + } { \tl_gset:Nn \g__crefthe_prep_each_tl  { #4 } }
+              }
+          }
+      }
+    \bool_if:nTF { #1 } { \crefthe_cref_original:n * { #5 } } { \crefthe_cref_original:n { #5 } }
+    \tl_gset:Nn \g__crefthe_prep_each_tl {}
+  }
 
-\NewDocumentCommand{\crefthemark}{m}{
-    \crefthe_contraction:nn { \crefthe_case:n \g_crefthe_prep_tl }{
-        \crefthe_contraction:nn { \crefthe_case:n \g_crefthe_prepf_tl }{#1}
-    }
-    \tl_gset:Nn \g_crefthe_prepf_tl {}
-    \tl_gset:Nx \g_crefthe_prep_tl { \text_lowercase:n \g_crefthe_prep_tl }
-    \str_case_e:nnF {\str_tail:n {#1}} {
-        {'} { \tl_gset:Nn \g_crefthe_sep_tl {} }
-    }
-    { \tl_gset:Nn \g_crefthe_sep_tl {~} }
-    \cs_gset_eq:NN \crefthe_case:n \crefthe_nochange:n
-    % \cs_gset_eq:NN \crefthe_case:n \text_lowercase:n
-}
+\NewDocumentCommand \Crefthe { s t- t+ O{} m }
+  {
+    \cs_gset:Npn \crefthe_case:n ##1 { \text_titlecase:n {##1} }
+    \bool_if:nTF { #2 }
+      {
+        \tl_gset:Nn \g__crefthe_prep_once_tl { #4 }
+      }
+      {
+        \bool_if:nTF { #3 }
+          {
+            \tl_gset:Nn \g__crefthe_prep_each_tl { #4 }
+          }
+          {
+            \exp_args:Nx \str_case:nn \l__crefthe_prep_mode_tl
+              {
+                { - } { \tl_gset:Nn \g__crefthe_prep_once_tl { #4 } }
+                { + } { \tl_gset:Nn \g__crefthe_prep_each_tl  { #4 } }
+              }
+          }
+      }
+    \bool_if:nTF { #1 } { \crefthe_Cref_original:n * { #5 } } { \crefthe_Cref_original:n { #5 } }
+    \tl_gset:Nn \g__crefthe_prep_each_tl {}
+  }
 
-\cs_set:Npn \crefthe_prep_mode:nn {
-    \str_case_e:nn { \languagename }
+\NewDocumentCommand \crefthename { m O{} m O{} m }
+  {
+    \tl_if_blank:eTF { #2 }
+      {
+        \crefthe_crefname_original:n { #1 } { #3 } { #5 }
+        \cs_set:cn { cref_#1_format:nnn } { ##2 #3 ~ ##1 ##3 }
+        \cs_set:cn { cref_#1_format_first:nnn } { ##2 #5 ~ ##1 ##3 }
+      }
+      {
+        \crefthe_crefname_original:n { #1 } { \crefthemark{ #2 } #3 } { \crefthemark{ #4 } #5 }
+        \cs_set:cn { cref_#1_format:nnn } { \crefthemark { #2 } ##2 #3 ~ ##1 ##3 }
+        \cs_set:cn { cref_#1_format_first:nnn } { \crefthemark { #4 } ##2 #5 ~ ##1 ##3 }
+      }
+    \hook_gput_next_code:nn { begindocument }
+      {
+        \cs_set_eq:cc { cref@ #1 @format } { cref_#1_format:nnn }
+        \cs_set_eq:cc { cref@ #1 @format at first } { cref_#1_format_first:nnn }
+      }
+  }
+
+\NewDocumentCommand \Crefthename { m O{} m O{} m }
+  {
+    \tl_if_blank:eTF { #2 }
+      {
+        \crefthe_Crefname_original:n { #1 } { #3 } { #5 }
+        \cs_set:cn { Cref_#1_format:nnn } { ##2 #3 ~ ##1 ##3 }
+        \cs_set:cn { Cref_#1_format_first:nnn } { ##2 #5 ~ ##1 ##3 }
+      }
+      {
+        \crefthe_Crefname_original:n { #1 } { \crefthemark{ #2 } #3 }{ \crefthemark{ #4 } #5 }
+        \cs_set:cn { Cref_#1_format:nnn } { \crefthemark { #2 } ##2 #3 ~ ##1 ##3 }
+        \cs_set:cn { Cref_#1_format_first:nnn } { \crefthemark { #4 } ##2 #5 ~ ##1 ##3 }
+      }
+    \hook_gput_next_code:nn { begindocument }
+      {
+        \cs_set_eq:cc { Cref@ #1 @format } { Cref_#1_format:nnn }
+        \cs_set_eq:cc { Cref@ #1 @format at first } { Cref_#1_format_first:nnn }
+      }
+  }
+
+\NewDocumentCommand \crefthemark { m }
+  {
+    \crefthe_contraction:nn { \crefthe_case:n \g__crefthe_prep_each_tl }
+      {
+        \crefthe_contraction:nn { \crefthe_case:n \g__crefthe_prep_once_tl } { #1 }
+      }
+    \tl_gset:Nn \g__crefthe_prep_once_tl {}
+    \tl_gset:Nx \g__crefthe_prep_each_tl { \text_lowercase:n \g__crefthe_prep_each_tl }
+    \str_if_eq:eeF { \str_tail:n { #1 } } { ' } { ~ }
+    \cs_gset:Npn \crefthe_case:n ##1 { \crefthe_nochange:n {##1} }
+    % \cs_gset:Npn \crefthe_case:n ##1 { \text_lowercase:n {##1} }
+  }
+
+\tl_set:Nn \l__crefthe_prep_mode_tl {
+  \str_case_e:nn { \languagename }
     {
-        {french}        { + }
-        {italian}       { + }
-        {spanish}       { - }
-        {portuguese}    { + }
-        {brazilian}     { + }
+      {french}        { + }
+      {italian}       { + }
+      {spanish}       { - }
+      {portuguese}    { + }
+      {brazilian}     { + }
     }
 }
 
-\cs_set:Npn \crefthe_contraction:nn #1#2 {
-    \str_if_eq:eeTF {#1} {} {#2} {
-        \str_case_e:nn { \languagename }
-        {
-            {french}{
-                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
-                    {à~le}      {au}
-                    {à~les}     {aux}
-                    {de~le}     {du}
-                    {de~les}    {des}
-                    {À~le}      {Au}
-                    {À~les}     {Aux}
-                    {De~le}     {Du}
-                    {De~les}    {Des}
-                }{#1~\text_lowercase:n{#2}}
-            }
-            {italian}{
-                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
-                    {a~il}      {al}
-                    {a~lo}      {allo}
-                    {a~l'}      {all'}
-                    {a~la}      {alla}
-                    {di~il}     {del}
-                    {di~lo}     {dello}
-                    {di~l'}     {dell'}
-                    {di~la}     {della}
-                    {da~il}     {dal}
-                    {da~lo}     {dallo}
-                    {da~l'}     {dall'}
-                    {da~la}     {dalla}
-                    {in~il}     {nel}
-                    {in~lo}     {nello}
-                    {in~l'}     {nell'}
-                    {in~la}     {nella}
-                    {su~il}     {sul}
-                    {su~lo}     {sullo}
-                    {su~l'}     {sull'}
-                    {su~la}     {sulla}
-                    {a~i}       {ai}
-                    {a~gli}     {agli}
-                    {a~le}      {alle}
-                    {di~i}      {dei}
-                    {di~gli}    {degli}
-                    {di~le}     {delle}
-                    {da~i}      {dai}
-                    {da~gli}    {dagli}
-                    {da~le}     {dalle}
-                    {in~i}      {nei}
-                    {in~gli}    {negli}
-                    {in~le}     {nelle}
-                    {su~i}      {sui}
-                    {su~gli}    {sugli}
-                    {su~le}     {sulle}
-                    {A~il}      {Al}
-                    {A~lo}      {Allo}
-                    {A~l'}      {All'}
-                    {A~la}      {Alla}
-                    {Di~il}     {Del}
-                    {Di~lo}     {Dello}
-                    {Di~l'}     {Dell'}
-                    {Di~la}     {Della}
-                    {Da~il}     {Dal}
-                    {Da~lo}     {Dallo}
-                    {Da~l'}     {Dall'}
-                    {Da~la}     {Dalla}
-                    {In~il}     {Nel}
-                    {In~lo}     {Nello}
-                    {In~l'}     {Nell'}
-                    {In~la}     {Nella}
-                    {Su~il}     {Sul}
-                    {Su~lo}     {Sullo}
-                    {Su~l'}     {Sull'}
-                    {Su~la}     {Sulla}
-                    {A~i}       {Ai}
-                    {A~gli}     {Agli}
-                    {A~le}      {Alle}
-                    {Di~i}      {Dei}
-                    {Di~gli}    {Degli}
-                    {Di~le}     {Delle}
-                    {Da~i}      {Dai}
-                    {Da~gli}    {Dagli}
-                    {Da~le}     {Dalle}
-                    {In~i}      {Nei}
-                    {In~gli}    {Negli}
-                    {In~le}     {Nelle}
-                    {Su~i}      {Sui}
-                    {Su~gli}    {Sugli}
-                    {Su~le}     {Sulle}
-                }{#1~\text_lowercase:n{#2}}
-            }
-            {portuguese}{
-                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
-                    {a~o}       {ao}
-                    {a~a}       {à}
-                    {a~os}      {aos}
-                    {a~as}      {às}
-                    {de~o}      {do}
-                    {de~a}      {da}
-                    {de~os}     {dos}
-                    {de~as}     {das}
-                    {em~o}      {no}
-                    {em~a}      {na}
-                    {em~os}     {nos}
-                    {em~as}     {nas}
-                    {A~o}       {Ao}
-                    {A~a}       {À}
-                    {A~os}      {Aos}
-                    {A~as}      {Às}
-                    {De~o}      {Do}
-                    {De~a}      {Da}
-                    {De~os}     {Dos}
-                    {De~as}     {Das}
-                    {Em~o}      {No}
-                    {Em~a}      {Na}
-                    {Em~os}     {Nos}
-                    {Em~as}     {Nas}
-                }{#1~\text_lowercase:n{#2}}
-            }
-            {brazilian}{
-                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
-                    {a~o}       {ao}
-                    {a~a}       {à}
-                    {a~os}      {aos}
-                    {a~as}      {às}
-                    {de~o}      {do}
-                    {de~a}      {da}
-                    {de~os}     {dos}
-                    {de~as}     {das}
-                    {em~o}      {no}
-                    {em~a}      {na}
-                    {em~os}     {nos}
-                    {em~as}     {nas}
-                    {A~o}       {Ao}
-                    {A~a}       {À}
-                    {A~os}      {Aos}
-                    {A~as}      {Às}
-                    {De~o}      {Do}
-                    {De~a}      {Da}
-                    {De~os}     {Dos}
-                    {De~as}     {Das}
-                    {Em~o}      {No}
-                    {Em~a}      {Na}
-                    {Em~os}     {Nos}
-                    {Em~as}     {Nas}
-                }{#1~\text_lowercase:n{#2}}
-            }
-            {spanish}{
-                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
-                    {a~el}      {al}
-                    {de~el}     {del}
-                    {A~el}      {Al}
-                    {De~el}     {Del}
-                }{#1~\text_lowercase:n{#2}}
-            }
-        }
-    }
-}
+\cs_new:Npn \crefthe_contraction:nn #1#2
+  {
+    \tl_if_blank:eTF { #1 }
+      { #2 }
+      {
+        \tl_if_exist:cTF { crefthe_contraction_rule_ \languagename _tl }
+          {
+            \exp_args:Nnx \str_case_e:nnF { #1~\text_lowercase:n{ #2 } }
+              {
+                \tl_use:c { crefthe_contraction_rule_ \languagename _tl }
+              }
+              { #1~\text_lowercase:n{ #2 } }
+          }
+          { #1 ~ #2 }
+      }
+  }
+
+\tl_gset:Nn \crefthe_contraction_rule_french_tl
+  {
+    { à~le }      { au }
+    { à~les }     { aux }
+    { de~le }     { du }
+    { de~les }    { des }
+    { À~le }      { Au }
+    { À~les }     { Aux }
+    { De~le }     { Du }
+    { De~les }    { Des }
+  }
+
+\tl_gset:Nn \crefthe_contraction_rule_italian_tl
+  {
+    { a~il }      { al }
+    { a~lo }      { allo }
+    { a~l' }      { all' }
+    { a~la }      { alla }
+    { di~il }     { del }
+    { di~lo }     { dello }
+    { di~l' }     { dell' }
+    { di~la }     { della }
+    { da~il }     { dal }
+    { da~lo }     { dallo }
+    { da~l' }     { dall' }
+    { da~la }     { dalla }
+    { in~il }     { nel }
+    { in~lo }     { nello }
+    { in~l' }     { nell' }
+    { in~la }     { nella }
+    { su~il }     { sul }
+    { su~lo }     { sullo }
+    { su~l' }     { sull' }
+    { su~la }     { sulla }
+    { a~i }       { ai }
+    { a~gli }     { agli }
+    { a~le }      { alle }
+    { di~i }      { dei }
+    { di~gli }    { degli }
+    { di~le }     { delle }
+    { da~i }      { dai }
+    { da~gli }    { dagli }
+    { da~le }     { dalle }
+    { in~i }      { nei }
+    { in~gli }    { negli }
+    { in~le }     { nelle }
+    { su~i }      { sui }
+    { su~gli }    { sugli }
+    { su~le }     { sulle }
+    { A~il }      { Al }
+    { A~lo }      { Allo }
+    { A~l' }      { All' }
+    { A~la }      { Alla }
+    { Di~il }     { Del }
+    { Di~lo }     { Dello }
+    { Di~l' }     { Dell' }
+    { Di~la }     { Della }
+    { Da~il }     { Dal }
+    { Da~lo }     { Dallo }
+    { Da~l' }     { Dall' }
+    { Da~la }     { Dalla }
+    { In~il }     { Nel }
+    { In~lo }     { Nello }
+    { In~l' }     { Nell' }
+    { In~la }     { Nella }
+    { Su~il }     { Sul }
+    { Su~lo }     { Sullo }
+    { Su~l' }     { Sull' }
+    { Su~la }     { Sulla }
+    { A~i }       { Ai }
+    { A~gli }     { Agli }
+    { A~le }      { Alle }
+    { Di~i }      { Dei }
+    { Di~gli }    { Degli }
+    { Di~le }     { Delle }
+    { Da~i }      { Dai }
+    { Da~gli }    { Dagli }
+    { Da~le }     { Dalle }
+    { In~i }      { Nei }
+    { In~gli }    { Negli }
+    { In~le }     { Nelle }
+    { Su~i }      { Sui }
+    { Su~gli }    { Sugli }
+    { Su~le }     { Sulle }
+  }
+
+\tl_gset:Nn \crefthe_contraction_rule_spanish_tl
+  {
+    { a~el }      { al }
+    { de~el }     { del }
+    { A~el }      { Al }
+    { De~el }     { Del }
+  }
+
+\tl_gset:Nn \crefthe_contraction_rule_portuguese_tl
+  {
+    { a~o }       { ao }
+    { a~a }       { à }
+    { a~os }      { aos }
+    { a~as }      { às }
+    { de~o }      { do }
+    { de~a }      { da }
+    { de~os }     { dos }
+    { de~as }     { das }
+    { em~o }      { no }
+    { em~a }      { na }
+    { em~os }     { nos }
+    { em~as }     { nas }
+    { A~o }       { Ao }
+    { A~a }       { À }
+    { A~os }      { Aos }
+    { A~as }      { Às }
+    { De~o }      { Do }
+    { De~a }      { Da }
+    { De~os }     { Dos }
+    { De~as }     { Das }
+    { Em~o }      { No }
+    { Em~a }      { Na }
+    { Em~os }     { Nos }
+    { Em~as }     { Nas }
+  }
+
+\tl_gset:Nn \crefthe_contraction_rule_brazilian_tl
+  {
+    { a~o }       { ao }
+    { a~a }       { à }
+    { a~os }      { aos }
+    { a~as }      { às }
+    { de~o }      { do }
+    { de~a }      { da }
+    { de~os }     { dos }
+    { de~as }     { das }
+    { em~o }      { no }
+    { em~a }      { na }
+    { em~os }     { nos }
+    { em~as }     { nas }
+    { A~o }       { Ao }
+    { A~a }       { À }
+    { A~os }      { Aos }
+    { A~as }      { Às }
+    { De~o }      { Do }
+    { De~a }      { Da }
+    { De~os }     { Dos }
+    { De~as }     { Das }
+    { Em~o }      { No }
+    { Em~a }      { Na }
+    { Em~os }     { Nos }
+    { Em~as }     { Nas }
+  }
+
 \endinput
 %%
 %% End of file `crefthe.sty'.



More information about the tex-live-commits mailing list.