texlive[61797] Master/texmf-dist: crefthe (29jan22)

commits+karl at tug.org commits+karl at tug.org
Sat Jan 29 22:48:04 CET 2022


Revision: 61797
          http://tug.org/svn/texlive?view=revision&revision=61797
Author:   karl
Date:     2022-01-29 22:48:04 +0100 (Sat, 29 Jan 2022)
Log Message:
-----------
crefthe (29jan22)

Modified Paths:
--------------
    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/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-01-29 21:47:48 UTC (rev 61796)
+++ trunk/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex	2022-01-29 21:48:04 UTC (rev 61797)
@@ -31,7 +31,10 @@
 \lstset{moretexcs=%
     {
         cref,crefname,
-        crefthe,ccref,crefthemark,
+        Cref,Crefname,
+        crefformat,
+        crefthe,crefthename,crefthemark,
+        Crefthe,Crefthename,
         selectlanguage,
     }
 }
@@ -86,8 +89,8 @@
 
 \title{\crefthepackage{} - cross referencing with proper definite articles}
 \author{Jinwen XU}
-\thanks{Corresponding to: \texttt{\crefthepackage{} 2021/11/05}}
-\date{November 2021, in Paris}
+\thanks{Corresponding to: \texttt{\crefthepackage{} 2022/01/29}}
+\date{January 2022, in Paris}
 
 \maketitle
 
@@ -147,6 +150,16 @@
 
 \subsection[How to use it]{How to use it\,?}
 
+Before everything, you need to define the names, which can be done with \lstinline|\crefthename|. Its syntax is similar to \lstinline|\crefname|, but now you can specify the definite articles, for example:
+
+\begin{code}
+\crefthename{theorem}[le]{théorème}[les]{théorèmes}
+\end{code}
+
+% \begin{tip}
+%     The \lstinline|\crefthename|s should be placed in your preamble.
+% \end{tip}
+
 Then you can use the command \lstinline|\crefthe| as follows:
 \begin{itemize}
     \item \lstinline|\crefthe[|\meta{prep}\lstinline|]{|\meta{labels}\lstinline|}|
@@ -162,24 +175,22 @@
 \begin{tip}
     There is also a stared version \lstinline|\crefthe*| for generating the same referencing text but without creating hyperlinks.
 \end{tip}
- 
-However, before using it, you should first define the \lstinline|\crefname|s carefully. The definite article in \lstinline|\crefname|s needs to be marked manually using \lstinline|\crefthemark|, for example:
 
-\begin{code}
-\crefname{theorem}{\crefthemark{le} théorème}
-                  {\crefthemark{les} théorèmes}
-\end{code}
+% However, before using it, you should first define the \lstinline|\crefname|s carefully. The definite article in \lstinline|\crefname|s needs to be marked manually using \lstinline|\crefthemark|, for example:
 
+% \begin{code}
+% \crefname{theorem}{\crefthemark{le} théorème}
+%                   {\crefthemark{les} théorèmes}
+% \end{code}
 
+
 \section{Example}
 
 Let us come back to the example at the beginning, now you can do this:
 
 \begin{code}
-\crefname{theorem}{\crefthemark{le} théorème}
-                  {\crefthemark{les} théorèmes}
-\crefname{proposition}{\crefthemark{la} proposition}
-                      {\crefthemark{les} propositions}
+\crefthename{theorem}[le]{théorème}[les]{théorèmes}
+\crefthename{proposition}[la]{proposition}[les]{propositions}
 \end{code}
 
 And the sentence shall be written as:
@@ -196,12 +207,35 @@
 
 Voilà !
 
+\section{Regarding the cases}
 
+The commands also have correspoding uppercased version: \lstinline|\Crefthename| and \lstinline|\Crefthe|, similar to \textsf{cleveref}'s \lstinline|\Crefname| and \lstinline|\Cref|, reserved for use at the beginning of a sentence. \lstinline|\Crefthe| can handle case changing automatically: for example, with \lstinline|\Crefthe[À]{thm1,thm2,prop3}|, you will get something like
+
+\begin{demo}
+    \textbf{Aux} théorèmes 1 et 2 et \textbf{à la} proposition 3
+\end{demo}
+
+Of course you will have to define the \lstinline|\Crefthename|s separately, for example as:
+
+\begin{code}
+\Crefthename{theorem}[Le]{théorème}[Les]{théorèmes}
+\Crefthename{proposition}[La]{proposition}[Les]{propositions}
+\end{code}
+
+\section{Relationship with \textsf{cleveref}}
+
+\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.
+
+\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.
+
 \section{Known issues}
 \begin{itemize}
-    \item \crefthepackage{} currently only works for French, Italian, Portuguese (both European and Brazilian) and Spanish, certainly more would be added to this list.
+    \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 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 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 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-01-29 21:47:48 UTC (rev 61796)
+++ trunk/Master/texmf-dist/tex/latex/crefthe/crefthe.sty	2022-01-29 21:48:04 UTC (rev 61797)
@@ -1,5 +1,5 @@
 %%
-%% Copyright (C) 2021 by Jinwen XU
+%% Copyright (C) 2021-2022 by Jinwen XU
 %% -------------------------------
 %%
 %% This file may be distributed and/or modified under the conditions of
@@ -12,14 +12,28 @@
 \NeedsTeXFormat{LaTeX2e}[2020-10-01]
 \ProvidesExplPackage
   {crefthe}
-  {2021/11/05}
+  {2022/01/29}
   {}
   {Cross referencing with proper definite articles}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{cleveref}}
+\ProcessOptions\relax
 \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_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
+    }
+}
+
 \NewDocumentCommand{\crefthe}{st-t+O{}m}{
     \IfBooleanTF{ #2 }{
         \tl_gset:Nn \g_crefthe_prepf_tl { #4 }
@@ -37,11 +51,70 @@
     \tl_gset:Nn \g_crefthe_prep_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 {}
+}
+
+\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{\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{\crefthemark}{m}{
-    \crefthe_contraction:nn { \tl_use:N \g_crefthe_prep_tl }{
-        \crefthe_contraction:nn { \tl_use:N \g_crefthe_prepf_tl }{#1}
+    \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
 }
 
 \cs_set:Npn \crefthe_prep_mode:nn {
@@ -60,19 +133,19 @@
         \str_case_e:nn { \languagename }
         {
             {french}{
-                \str_case_e:nnF {#1~#2} {
+                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
                     {à~le}      {au}
-                    {à~la}      {à~la}
-                    {à~l'}      {à~l'}
                     {à~les}     {aux}
                     {de~le}     {du}
-                    {de~la}     {de~la}
-                    {de~l'}     {de~l'}
                     {de~les}    {des}
-                }{#1~#2}
+                    {À~le}      {Au}
+                    {À~les}     {Aux}
+                    {De~le}     {Du}
+                    {De~les}    {Des}
+                }{#1~\text_lowercase:n{#2}}
             }
             {italian}{
-                \str_case_e:nnF {#1~#2} {
+                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
                     {a~il}      {al}
                     {a~lo}      {allo}
                     {a~l'}      {all'}
@@ -108,10 +181,45 @@
                     {su~i}      {sui}
                     {su~gli}    {sugli}
                     {su~le}     {sulle}
-                }{#1~#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}
+                }{#1~\text_lowercase:n{#2}}
             }
             {portuguese}{
-                \str_case_e:nnF {#1~#2} {
+                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
                     {a~o}       {ao}
                     {a~a}       {à}
                     {a~os}      {aos}
@@ -124,10 +232,22 @@
                     {em~a}      {na}
                     {em~os}     {nos}
                     {em~as}     {nas}
-                }{#1~#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}
+                }{#1~\text_lowercase:n{#2}}
             }
             {brazilian}{
-                \str_case_e:nnF {#1~#2} {
+                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
                     {a~o}       {ao}
                     {a~a}       {à}
                     {a~os}      {aos}
@@ -140,13 +260,27 @@
                     {em~a}      {na}
                     {em~os}     {nos}
                     {em~as}     {nas}
-                }{#1~#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}
+                }{#1~\text_lowercase:n{#2}}
             }
             {spanish}{
-                \str_case_e:nnF {#1~#2} {
+                \str_case_e:nnF {#1~\text_lowercase:n{#2}} {
                     {a~el}      {al}
                     {de~el}     {del}
-                }{#1~#2}
+                    {A~el}      {Al}
+                    {De~el}     {Del}
+                }{#1~\text_lowercase:n{#2}}
             }
         }
     }



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