summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/crefthe
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-02-26 03:00:59 +0000
committerNorbert Preining <norbert@preining.info>2024-02-26 03:00:59 +0000
commit8dfcb0935597571483db587639fb662c93d775b1 (patch)
tree39d596fbdcc693a0d3ececb8aa099edfbd93f898 /macros/latex/contrib/crefthe
parent7520174d338ca031769f8e67d69b9a6a00f1626b (diff)
CTAN sync 202402260300
Diffstat (limited to 'macros/latex/contrib/crefthe')
-rw-r--r--macros/latex/contrib/crefthe/README.md6
-rw-r--r--macros/latex/contrib/crefthe/crefthe-doc.pdfbin66538 -> 71860 bytes
-rw-r--r--macros/latex/contrib/crefthe/crefthe-doc.tex19
-rw-r--r--macros/latex/contrib/crefthe/crefthe.sty83
4 files changed, 94 insertions, 14 deletions
diff --git a/macros/latex/contrib/crefthe/README.md b/macros/latex/contrib/crefthe/README.md
index 745432cfbc..3fff1e4ecf 100644
--- a/macros/latex/contrib/crefthe/README.md
+++ b/macros/latex/contrib/crefthe/README.md
@@ -1,12 +1,12 @@
<!-- Copyright (C) 2021-2024 by Jinwen XU -->
-# crefthe - cross referencing with proper definite articles
+# crefthe — cross referencing with proper definite articles and declensions
-"crefthe" is a LaTeX package aimed at helping `\cref` addressing the definite articles properly (especially for the article contractions in many European languages).
+"crefthe" is a LaTeX package aimed at helping `\cref` to handle the definite articles and declensions properly (especially for the phenomenon of article contractions in many European languages, such as French and German).
## Motivation
-By default, when using cleveref's `\cref` to reference theorem-like environments, the names do not contain definite articles. This may be acceptable for English, but certainly not good enough for languages such as French, Italian, Portuguese, Spanish, etc. -- in these cases there shall be grammatical errors and would give you a strong feeling that it is machine-generated.
+By default, when using cleveref's `\cref` to reference theorem-like environments, the names do not contain definite articles. This may be acceptable for English, but certainly not good enough for languages such as French, Italian, Portuguese, Spanish, etc. — in these cases there shall be grammatical errors and would give you a strong feeling that it is machine-generated.
As an example, if we define the French names to be:
```latex
diff --git a/macros/latex/contrib/crefthe/crefthe-doc.pdf b/macros/latex/contrib/crefthe/crefthe-doc.pdf
index be4864d533..967c29d78f 100644
--- a/macros/latex/contrib/crefthe/crefthe-doc.pdf
+++ b/macros/latex/contrib/crefthe/crefthe-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/crefthe/crefthe-doc.tex b/macros/latex/contrib/crefthe/crefthe-doc.tex
index 81a11edab9..35f98e753e 100644
--- a/macros/latex/contrib/crefthe/crefthe-doc.tex
+++ b/macros/latex/contrib/crefthe/crefthe-doc.tex
@@ -5,6 +5,8 @@
\usepackage{ProjLib}
+\setmonofont[Scale=.9]{Iosevka}
+
%%================================
%% For typesetting code
%%================================
@@ -26,7 +28,7 @@
breaklines = true,
frame = lines,
backgroundcolor = \color{code-background},
- flexiblecolumns = true,
+ basewidth = .5em,
escapeinside = {(*}{*)},
alsoletter = {_,:},
% numbers = left,
@@ -69,8 +71,8 @@
\lstnewenvironment{code}{\setstretch{1.05}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
\lstnewenvironment{code*}{\setstretch{1.05}\lstset{numbers=left}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
-\newcommand{\packageoption}[1]{\texttt{\textcolor{code-option}{#1}}}
-\newcommand{\commandoption}[1]{\texttt{\textcolor{code-keys}{#1}}}
+\newcommand{\packageoption}[1]{\textcolor{code-option}{\texttt{#1}}}
+\newcommand{\commandoption}[1]{\textcolor{code-keys}{\texttt{#1}}}
%%================================
%% tip
@@ -120,19 +122,19 @@
\begin{document}
-\def\PackageVersion{2024/02/24}
+\def\PackageVersion{2024/02/25}
\def\PackageSubVersion{}
-\title{\crefthepackage{}\\\smallskip\itshape Cross referencing with proper definite articles}
+\title{\crefthepackage{}\\\smallskip\itshape Cross referencing with proper definite articles and declensions}
\author{Jinwen XU}
-\thanks{Corresponding to: \texttt{\crefthepackage{} \PackageVersion\PackageSubVersion}}
+\thanks{Corresponding to: \texttt{\crefthepackage{} \PackageVersion\PackageSubVersion}.}
\date{\TheDate{\PackageVersion}[only-year-month], in Paris}
\maketitle
\begin{abstract}
\raggedleft
- The package \crefthepackage{} provides a command \lstinline|\crefthe| parallel to \textsf{cleveref}'s \lstinline|\cref| for handling definite articles properly (especially for the article contractions in some European languages).
+ The package \crefthepackage{} provides a command \lstinline|\crefthe| parallel to \textsf{cleveref}'s \lstinline|\cref| for handling definite articles and declensions properly (especially for the phenomenon of article contractions in some European languages, such as French and German).
\end{abstract}
\section{The motivation}
@@ -224,6 +226,7 @@ Then you can use the command \lstinline|\crefthe| as follows:
% \end{code}
+\enlargethispage*{\baselineskip}
\section{Example}
Let us come back to the example at the beginning, now you can do this:
@@ -310,7 +313,7 @@ Then, when referencing, you can use the command option \commandoption{abbr.} to
\section{Regarding the upper and lower cases}
-As in \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|,\linebreak \lstinline|\Crefthe|, \lstinline|\nameCrefthe|, \lstinline|\nameCrefsthe| and \lstinline|\Cpagerefthe|, similar to \lstinline|\Crefname|,\linebreak \lstinline|\Cref|, \lstinline|\nameCref|, \lstinline|\nameCrefs| and \lstinline|\Cpageref|, reserved for using at the beginning of a sentence. Their usage is essentially the same as the corresponding lowercase version.
+As with \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|, \lstinline|\Crefthe|, \lstinline|\nameCrefthe|, \lstinline|\nameCrefsthe| and \lstinline|\Cpagerefthe|, similar to \lstinline|\Crefname|, \lstinline|\Cref|, \lstinline|\nameCref|, \lstinline|\nameCrefs| and \lstinline|\Cpageref|, reserved for using at the beginning of a sentence. Their usage is essentially the same as the corresponding lowercase version.
For languages with declensions, such as German, there is also a \lstinline|\Crefthevariantname| (or equivalently, \lstinline|\setCrefname|), corresponding to the above \lstinline|\crefthevariantname|.
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
{