summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/crefthe/crefthe.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/crefthe/crefthe.sty')
-rw-r--r--macros/latex/contrib/crefthe/crefthe.sty83
1 files changed, 80 insertions, 3 deletions
diff --git a/macros/latex/contrib/crefthe/crefthe.sty b/macros/latex/contrib/crefthe/crefthe.sty
index ad4f89ac32..8dca2cc77b 100644
--- a/macros/latex/contrib/crefthe/crefthe.sty
+++ b/macros/latex/contrib/crefthe/crefthe.sty
@@ -12,8 +12,8 @@
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplPackage
{crefthe}
- {2024/02/24} {}
- {Cross referencing with proper definite articles}
+ {2024/02/25} {}
+ {Cross referencing with proper definite articles and declensions}
\keys_define:nn { crefthe }
{
@@ -41,6 +41,59 @@
\RequirePackage { regexpatch }
\@namedef{ver@xpatch.sty}{}
+% Fix for cleveref in order to work with long range of pages
+% See https://tex.stackexchange.com/a/620066
+\providecommand*{\@setcpagerefrange}[3]{%
+ \@@setcpagerefrange{#1}{#2}{cref}{#3}}
+\providecommand*{\@setCpagerefrange}[3]{%
+ \@@setcpagerefrange{#1}{#2}{Cref}{#3}}
+\providecommand*{\@setlabelcpagerefrange}[3]{%
+ \@@setcpagerefrange{#1}{#2}{labelcref}{#3}}
+
+% Fix for cleveref in order to work with xr-hyper
+% See https://tex.stackexchange.com/a/708445
+\def\cref@getref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1@cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@firstoffive#2}}% <-------- five
+\def\cpageref@getref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1@cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@secondoffive#2}}% <----------- five
+\AtBeginDocument{%
+ \def\label@noarg#1{%
+ \cref@old@label{#1}%
+ \@bsphack%
+ \edef\@tempa{{page}{\the\c@page}}%
+ \setcounter{page}{1}%
+ \edef\@tempb{\thepage}%
+ \expandafter\setcounter\@tempa%
+ \cref@constructprefix{page}{\cref@result}%
+ \protected@write\@auxout{}%
+ {\string\newlabel{#1@cref}{{\cref@currentlabel}%
+ {[\@tempb][\arabic{page}][\cref@result]\thepage}{}{}{}}}% <----- five
+ \@esphack}%
+ \def\label@optarg[#1]#2{%
+ \cref@old@label{#2}%
+ \@bsphack%
+ \edef\@tempa{{page}{\the\c@page}}%
+ \setcounter{page}{1}%
+ \edef\@tempb{\thepage}%
+ \expandafter\setcounter\@tempa%
+ \cref@constructprefix{page}{\cref@result}%
+ \protected@edef\cref@currentlabel{%
+ \expandafter\cref@override@label@type%
+ \cref@currentlabel\@nil{#1}}%
+ \protected@write\@auxout{}%
+ {\string\newlabel{#2@cref}{{\cref@currentlabel}%
+ {[\@tempb][\arabic{page}][\cref@result]\thepage}{}{}{}}}% <------- five
+ \@esphack}%
+}
+
\NewCommandCopy \crefthe_cref_original:w \cref
\NewCommandCopy \crefthe_Cref_original:w \Cref
\NewCommandCopy \crefthe_crefname_original:w \crefname
@@ -109,15 +162,39 @@
\keys_define:nn { crefthe-command }
{
, noun .code:n = { \RenewDocumentCommand \crefthemark { m } {} }
+ , only-noun .meta:n = { noun }
+ , only~noun .meta:n = { noun }
+ , only noun .meta:n = { noun }
+ , no-prep .meta:n = { noun }
+ , no~prep .meta:n = { noun }
+ , no prep .meta:n = { noun }
+ , hide-prep .meta:n = { noun }
+ , hide~prep .meta:n = { noun }
+ , hide prep .meta:n = { noun }
+ , no-preposition .meta:n = { noun }
+ , no~preposition .meta:n = { noun }
+ , no preposition .meta:n = { noun }
+ , hide-preposition .meta:n = { noun }
+ , hide~preposition .meta:n = { noun }
+ , hide preposition .meta:n = { noun }
, variant .tl_set:N = \l__crefthe_variant_tl
+ , declension .tl_set:N = \l__crefthe_variant_tl
+ , D .tl_set:N = \l__crefthe_variant_tl
, abbr .bool_set:N = \l__crefthe_abbr_bool
, abbr. .bool_set:N = \l__crefthe_abbr_bool
+ , abbreviation .bool_set:N = \l__crefthe_abbr_bool
, unknown .code:n = {}
}
-\clist_const:Nn \c__crefthe_command_known_keys_clist { noun, abbr, abbr. }
+\clist_const:Nn \c__crefthe_command_known_keys_clist
+ {
+ noun, only-noun, only~noun, only noun,
+ no-prep, no~prep, no prep, no-preposition, no~preposition, no preposition,
+ hide-prep, hide~prep, hide prep, hide-preposition, hide~preposition, hide preposition,
+ abbr, abbr., abbreviation,
+ }
\cs_new:Nn \__crefthe_command_key_parser:n
{