texlive[62247] branches/branch2021.final/Master/texmf-dist: crefthe

commits+karl at tug.org commits+karl at tug.org
Sun Feb 27 22:32:23 CET 2022


Revision: 62247
          http://tug.org/svn/texlive?view=revision&revision=62247
Author:   karl
Date:     2022-02-27 22:32:23 +0100 (Sun, 27 Feb 2022)
Log Message:
-----------
crefthe (27feb22) (branch)

Modified Paths:
--------------
    branches/branch2021.final/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf
    branches/branch2021.final/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex
    branches/branch2021.final/Master/texmf-dist/tex/latex/crefthe/crefthe.sty

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

Modified: branches/branch2021.final/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex
===================================================================
--- branches/branch2021.final/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex	2022-02-27 21:32:15 UTC (rev 62246)
+++ branches/branch2021.final/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex	2022-02-27 21:32:23 UTC (rev 62247)
@@ -77,19 +77,23 @@
 \newenvironment{demo}{%
     \LocallyStopLineNumbers%
     \begin{tcolorbox}[enhanced jigsaw,pad at break*=1mm,breakable,
-        left=4mm,right=4mm,top=0.5mm,bottom=0mm,
+        left=2.5mm,right=3mm,top=0.5mm,bottom=0mm,
         colback=gray!5!paper,boxrule=0pt,frame hidden,
-        borderline west={1.5mm}{0mm}{gray!55!paper},arc=.7mm]%
+        borderline west={1.2mm}{0mm}{gray!55!paper},arc=.7mm]%
 }{\end{tcolorbox}\ResumeLineNumbers}
 
 
+\newcommand{\packageoption}[1]{\texttt{\textcolor{black!67!green}{#1}}}
+\newcommand{\commandoption}[1]{\texttt{\textcolor{black!67!cyan}{#1}}}
+
+
 \newcommand{\crefthepackage}{\textsf{crefthe}}
 
 \begin{document}
 
-\title{\crefthepackage{} - cross referencing with proper definite articles}
+\title{\crefthepackage{}\\\smallskip\itshape Cross referencing with proper definite articles}
 \author{Jinwen XU}
-\thanks{Corresponding to: \texttt{\crefthepackage{} 2022/02/20}}
+\thanks{Corresponding to: \texttt{\crefthepackage{} 2022/02/27}}
 \date{February 2022, in Paris}
 
 \maketitle
@@ -231,7 +235,7 @@
 
 \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 with \lstinline|\Cref|, \lstinline|\crefname| and \lstinline|\Crefname|.
+With the package option \packageoption{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 with \lstinline|\Cref|, \lstinline|\crefname| and \lstinline|\Crefname|.
 
 
 \section{Known issues}
@@ -241,5 +245,12 @@
     \item The names of theorem-like environments are not provided here, you need to define them by yourself. However, users are encouraged to use the \ProjLib{} toolkit (more specifically, the internal package \textsf{create-theorem}), which already handles everything for you.
 \end{itemize}
 
+\medskip
+If you run into any issues or have ideas for improvement, feel free to discuss on:
+\begin{center}
+    \url{https://github.com/Jinwen-XU/crefthe/issues}
+\end{center}
+or email me via \href{mailto:ProjLib at outlook.com}{\texttt{ProjLib at outlook.com}}.
 
+
 \end{document}

Modified: branches/branch2021.final/Master/texmf-dist/tex/latex/crefthe/crefthe.sty
===================================================================
--- branches/branch2021.final/Master/texmf-dist/tex/latex/crefthe/crefthe.sty	2022-02-27 21:32:15 UTC (rev 62246)
+++ branches/branch2021.final/Master/texmf-dist/tex/latex/crefthe/crefthe.sty	2022-02-27 21:32:23 UTC (rev 62247)
@@ -13,7 +13,7 @@
 \RequirePackage{l3keys2e}
 \ProvidesExplPackage
   {crefthe}
-  {2022/02/20} {}
+  {2022/02/27} {}
   {Cross referencing with proper definite articles}
 
 \keys_define:nn { crefthe }
@@ -26,6 +26,7 @@
 \ProcessKeysOptions { crefthe }
 
 \RequirePackage { cleveref }
+\RequirePackage { regexpatch }
 
 \NewCommandCopy \crefthe_cref_original:w     \cref
 \NewCommandCopy \crefthe_Cref_original:w     \Cref
@@ -41,20 +42,28 @@
 \tl_new:N \l__crefthe_prep_once_tl
 \tl_new:N \l__crefthe_prep_each_tl
 
-\bool_new:N \l__crefthe_uppercase_bool
+\bool_new:N \g__crefthe_uppercase_bool
+\bool_new:N \g__crefthe_has_prep_bool
 
 \NewDocumentCommand \crefthe { s t- t+ O{} m }
   {
-    \bool_set_false:N \l__crefthe_uppercase_bool
+    \bool_gset_false:N \g__crefthe_uppercase_bool
     \__crefthe_cref_general:NNNnnN #1 #2 #3 { #4 } { #5 } \crefthe_cref_original:w
   }
 \NewDocumentCommand \Crefthe { s t- t+ O{} m }
   {
-    \bool_set_true:N \l__crefthe_uppercase_bool
+    \bool_gset_true:N \g__crefthe_uppercase_bool
     \__crefthe_cref_general:NNNnnN #1 #2 #3 { #4 } { #5 } \crefthe_Cref_original:w
   }
-\cs_new_protected:Npn \__crefthe_cref_general:NNNnnN #1 #2 #3 #4 #5 #6
+\cs_new_protected:Nn \__crefthe_cref_general:NNNnnN
   {
+    \tl_if_blank:eTF #4
+      {
+        \bool_gset_false:N \g__crefthe_has_prep_bool
+      }
+      {
+        \bool_gset_true:N \g__crefthe_has_prep_bool
+      }
     \bool_if:NTF #2
       { \tl_set:Nn \l__crefthe_prep_once_tl { #4 } }
       {
@@ -78,7 +87,7 @@
   }
 
 % \__crefthe_prep_mode: defines the default mode for supported languages
-\cs_new:Npn \__crefthe_prep_mode:
+\cs_new:Nn \__crefthe_prep_mode:
   {
     \str_case:Vn \languagename
       {
@@ -94,31 +103,60 @@
   {
     \__crefthe_name_general:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { c }
   }
+
 \NewDocumentCommand \Crefthename { m O{} m O{} m }
   {
     \__crefthe_name_general:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { C }
   }
-\cs_new_protected:Npn \__crefthe_name_general:nnnnnn #1 #2 #3 #4 #5 #6
+
+\cs_new_protected:Nn \__crefthe_name_general:nnnnnn
   {
     % #6 is c or C
     \tl_if_blank:nTF { #2 }
       {
-        \cs:w crefthe_#6refname_original:w \cs_end: { #1 } { #3 } { #5 }
-        \cs_set:cn { #6ref_#1_format:nnn } { ##2 #3 ~ ##1 ##3 }
-        \cs_set:cn { #6ref_#1_format_first:nnn } { ##2 #5 ~ ##1 ##3 }
+        \__crefthe_name_general_do:nnnnnn { #1 } {} { #3 } {} { #5 } { #6 }
       }
       {
-        \cs:w crefthe_#6refname_original:w \cs_end: { #1 } { \crefthemark { #2 } #3 } { \crefthemark { #4 } #5 }
-        \cs_set:cn { #6ref_#1_format:nnn } { \crefthemark { #2 } ##2 #3 ~ ##1 ##3 }
-        \cs_set:cn { #6ref_#1_format_first:nnn } { \crefthemark { #4 } ##2 #5 ~ ##1 ##3 }
+        \__crefthe_name_general_do:nnnnnn { #1 } { \crefthemark { #2 } } { #3 } { \crefthemark { #4 } } { #5 } { #6 }
       }
+  }
+
+\cs_new_protected:Nn \__crefthe_name_general_do:nnnnnn
+  {
+    \use:c { crefthe_#6refname_original:w } { #1 } { #2 #3 } { #4 #5 }
     \hook_gput_code:nnn { begindocument } { crefthe }
       {
-        \cs_set_eq:cc { #6ref@ #1 @format } { #6ref_#1_format:nnn }
-        \cs_set_eq:cc { #6ref@ #1 @format at first } { #6ref_#1_format_first:nnn }
+        \crefthe_patch_format:nnnnn { 2 } { #6ref@#1 at format } { #6ref@#1 at name } { #2 } { #3 }
+        \crefthe_patch_format:nnnnn { 2 } { #6ref@#1 at format@first } { #6ref@#1 at name@plural } { #4 } { #5 }
+        \crefthe_patch_format:nnnnn { 3 } { #6refrange@#1 at format } { #6ref@#1 at name@plural } { #4 } { #5 }
+        \crefthe_patch_format:nnnnn { 3 } { #6refrange@#1 at format@first } { #6ref@#1 at name@plural } { #4 } { #5 }
       }
   }
 
+\seq_new:N \g__crefthe_already_patched_seq
+
+\cs_new_protected:Nn \crefthe_patch_format:nnnnn
+  % #1 = the # number for the beginning mark of hyperlink
+  % #2 = name of the format command
+  % #3 = name of the command after hyperlink mark
+  % #4 = new content before the mark
+  % #5 = new content after the mark
+  {
+    \seq_if_in:NnF \g__crefthe_already_patched_seq { #2 - #3 }
+      {
+        \makeatletter
+        \tl_set:Nn \l_tmpa_tl { #4 }
+        \tl_set:Nn \l_tmpb_tl { #5 }
+        \exp_args:Nc \regexpatchcmd { #2 }
+          { \cP. #1 \c{ #3 } }
+          { \u{l_tmpa_tl} \cP\# #1 \u{l_tmpb_tl} }
+          { } { \PatchFailed }
+        \makeatother
+        \seq_gput_right:Nn \g__crefthe_already_patched_seq { #2 - #3 }
+      }
+  }
+
+
 \cs_generate_variant:Nn \text_lowercase:n { V }
 \NewDocumentCommand \crefthemark { m }
   {
@@ -125,20 +163,20 @@
     \crefthe_contraction:Ve \l__crefthe_prep_each_tl
       { \crefthe_contraction:Vn \l__crefthe_prep_once_tl { #1 } }
     \tl_gclear:N \l__crefthe_prep_once_tl
-    \tl_set:Nx \l__crefthe_prep_each_tl
+    \tl_gset:Nx \l__crefthe_prep_each_tl
       { \text_lowercase:V \l__crefthe_prep_each_tl }
     \str_if_eq:eeF { \str_tail:n { #1 } } { ' } { ~ }
-    \bool_set_false:N \l__crefthe_uppercase_bool
+    \bool_gset_false:N \g__crefthe_uppercase_bool
   }
 
 \prg_generate_conditional_variant:Nnn \str_case_e:nn { nv } { T, F, TF }
-\cs_new:Npn \crefthe_contraction:nn #1#2
+\cs_new:Nn \crefthe_contraction:nn
   {
     \exp_args:Ne \__crefthe_contraction:nnn
       { \text_lowercase:n { #2 } } { #1 } { #2 }
   }
 \cs_generate_variant:Nn \crefthe_contraction:nn { V, Ve }
-\cs_new:Npn \__crefthe_contraction:nnn #1 #2 #3
+\cs_new:Nn \__crefthe_contraction:nnn
   {
     % #1 is \text_lowercase:n { #3 }
     % #2 is the preposition
@@ -157,9 +195,9 @@
           { #2~#3 }
       }
   }
-\cs_new:Npn \__crefthe_conditional_uppercase:n #1
+\cs_new:Nn \__crefthe_conditional_uppercase:n
   {
-    \bool_if:NTF \l__crefthe_uppercase_bool
+    \bool_if:NTF \g__crefthe_uppercase_bool
       { \text_titlecase_first:n }
       { \use:n }
         { #1 }



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