diff options
author | Karl Berry <karl@freefriends.org> | 2023-07-24 20:21:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-07-24 20:21:58 +0000 |
commit | b0cc1f5978aadab4a408401714ccb10ca46c7766 (patch) | |
tree | 095aeea9ad2d4b0402fcb43e1ba860566ceecfd7 | |
parent | 9cdeeec9e055f8cc802324b24f135d5bcef102d2 (diff) |
crefthe (24jul23)
git-svn-id: svn://tug.org/texlive/trunk@67721 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf | bin | 65016 -> 66435 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/crefthe/crefthe.sty | 121 |
3 files changed, 74 insertions, 76 deletions
diff --git a/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf b/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf Binary files differindex 8731eb2d97f..e943eabdfc0 100644 --- a/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf +++ b/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.pdf diff --git a/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex b/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex index 904cb5eee72..36baa45df6b 100644 --- a/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex +++ b/Master/texmf-dist/doc/latex/crefthe/crefthe-doc.tex @@ -49,6 +49,7 @@ crefthe,crefthename, Crefthe,Crefthename, crefthevariantname,Crefthevariantname, + setcrefname,setCrefname, namecrefthe,namecrefsthe, nameCrefthe,nameCrefsthe, crefthemark, @@ -118,10 +119,11 @@ \begin{document} \def\PackageVersion{2023/07/23} +\def\PackageSubVersion{a} \title{\crefthepackage{}\\\smallskip\itshape Cross referencing with proper definite articles} \author{Jinwen XU} -\thanks{Corresponding to: \texttt{\crefthepackage{} \PackageVersion}} +\thanks{Corresponding to: \texttt{\crefthepackage{} \PackageVersion\PackageSubVersion}} \date{\TheDate{\PackageVersion}[only-year-month], in Beijing} \maketitle @@ -242,7 +244,7 @@ which would result in (provided that you have done \lstinline|\selectlanguage{fr Voilà ! -\section{What about German} +\section{For language with declensions} In German, there are four declensions: nominative (\texttt{Nominativ}), genitive (\texttt{Genitiv}), dative (\texttt{Dativ}) and accusative (\texttt{Akkusativ}), making the previously presented mechanism insufficient. For such situation, we introduce the command \lstinline|\crefthevariantname| to specify the referencing name for the correspond environment. Below is an example of usage: @@ -258,7 +260,10 @@ In German, there are four declensions: nominative (\texttt{Nominativ}), genitive \end{code} \begin{tip} - The first line in the configuration is the default set of names when no variant is specified. It is recommended, though not required. + \begin{itemize} + \item The first line in the configuration is the default set of names when no variant is specified. It is recommended, though not required. + \item There is also an equivalent but shorter name \lstinline|\setcrefname| for this command. + \end{itemize} \end{tip} After this, you may refer to a theorem via @@ -280,25 +285,31 @@ Article contractions are by default enabled for German, but if you don't want th \section{Using abbreviation form} -There is another usage of \lstinline|\crefthevariantname|: setting the abbreviation form. This allows you to use both the full form and the abbreviation form in the same document. For example, you may set +There is another usage of \lstinline|\crefthevariantname| (or equivalently, \lstinline|\setcrefname|): setting the abbreviation form. This allows you to use both the full form and the abbreviation form within the same document. For example, you may set \begin{code} -\crefthevariantname{theorem} +\setcrefname{theorem} { {theorem}{theorems} , abbr. = {th.}{ths.} } \end{code} -Then, when referencing, you can use the command option \commandoption{abbr.} to enable the abbreviation form: +Then, when referencing, you can use the command option \commandoption{abbr.} to enable abbreviation: \begin{code} \crefthe[(*\commandoption{abbr.}*)]{(*\meta{label}*)} \end{code} +\begin{tip}[Attention] + Please note that \commandoption{abbr.} has more priority than the option(s) for specifying declensions. This means that when \commandoption{abbr.} is enabled, the declensions are simply ignored. +\end{tip} + \section{Regarding the upper and lower cases} -As in \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|,\linebreak \lstinline|\Crefthe|, \lstinline|\nameCrefthe| and \lstinline|\nameCrefsthe|, similar to \lstinline|\Crefname|, \lstinline|\Cref|, \lstinline|\nameCref|\linebreak and \lstinline|\nameCrefs|, reserved for using at the beginning of a sentence. For languages with declensions, such as German, there is also a \lstinline|\Crefthevariantname|, whose usage is similar to the \lstinline|\crefthevariantname| introduced above. +As in \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|,\linebreak \lstinline|\Crefthe|, \lstinline|\nameCrefthe| and \lstinline|\nameCrefsthe|, similar to \lstinline|\Crefname|, \lstinline|\Cref|, \lstinline|\nameCref|\linebreak and \lstinline|\nameCrefs|, reserved for using at the beginning of a sentence. + +For languages with declensions, such as German, there is also a \lstinline|\Crefthevariantname| (or equivalently, \lstinline|\setCrefname|), corresponding to the above \lstinline|\crefthevariantname|. \lstinline|\Crefthe| (and the name-only relatives) can handle case changing automatically: for example, with \lstinline|\Crefthe[À]{thm1,thm2,prop3}|, you will get something like @@ -332,7 +343,6 @@ There is another case. For example, if you wish to say \textquote{ce théorème} But then of course you shall need to write the word \textquote{Ce/Cet/Cette} (these are all different forms of \textquote{This} in French) by yourself --- and if you later decide to change the type of the environment to which this \meta{label} refers, don't forget to change this word accordingly. -\pagebreak \section{For writing multi-language documents} To place hyperlinks at the correct place, \lstinline|\crefthename| touches the corresponding format macro \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. @@ -368,8 +378,7 @@ There are so many people I wish to express my gratitude to during the developmen \end{itemize} -% \clearpage - +\bigskip \section{Known issues} \begin{itemize} \item \crefthepackage{} currently works for French, German, Italian, Portuguese (European and Brazilian) and Spanish --- certainly more languages would be added to this list in the future. diff --git a/Master/texmf-dist/tex/latex/crefthe/crefthe.sty b/Master/texmf-dist/tex/latex/crefthe/crefthe.sty index 4097b0aefc1..4f7b382e749 100644 --- a/Master/texmf-dist/tex/latex/crefthe/crefthe.sty +++ b/Master/texmf-dist/tex/latex/crefthe/crefthe.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplPackage {crefthe} - {2023/07/23} {} + {2023/07/23a} {} {Cross referencing with proper definite articles} \keys_define:nn { crefthe } @@ -93,36 +93,53 @@ \__crefthe_cref_general:NNNnnN \c_false_bool #1 #2 { #3 } { #4 } \crefthe_nameCrefs_original:w } -\keys_define:nn { crefthe-setting } +\keys_define:nn { crefthe-command } { , noun .code:n = { \RenewDocumentCommand \crefthemark { m } {} } , variant .tl_set:N = \l__crefthe_variant_tl - % , nom .meta:n = { variant = Nominativ } - % , nom. .meta:n = { variant = Nominativ } - % , Nom .meta:n = { variant = Nominativ } - % , Nom. .meta:n = { variant = Nominativ } - % , gen .meta:n = { variant = Genitiv } - % , gen. .meta:n = { variant = Genitiv } - % , Gen .meta:n = { variant = Genitiv } - % , Gen. .meta:n = { variant = Genitiv } - % , dat .meta:n = { variant = Dativ } - % , dat. .meta:n = { variant = Dativ } - % , Dat .meta:n = { variant = Dativ } - % , Dat. .meta:n = { variant = Dativ } - % , akk .meta:n = { variant = Akkusativ } - % , akk. .meta:n = { variant = Akkusativ } - % , Akk .meta:n = { variant = Akkusativ } - % , Akk. .meta:n = { variant = Akkusativ } - - % , unknown .code:n = { - % \bool_gset_true:N \g__crefthe_has_prep_bool - % \tl_set:No \l__crefthe_prep_tl { \l_keys_key_tl } - % } + , abbr .bool_set:N = \l__crefthe_abbr_bool + , abbr. .bool_set:N = \l__crefthe_abbr_bool , unknown .code:n = {} } +\clist_const:Nn \c__crefthe_command_known_keys_clist { noun, abbr, abbr. } + +\cs_new:Nn \__crefthe_command_key_parser:n + { + \bool_set_false:N \l__crefthe_variant_matched_bool + \clist_if_in:NnF \c__crefthe_command_known_keys_clist { #1 } + { + \str_if_eq:VnT \languagename { ngerman } + { + \str_case:nnT { #1 } + { + { nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } + { nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } + { Nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } + { Nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } + { gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } + { gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } + { Gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } + { Gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } + { dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } + { dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } + { Dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } + { Dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } + { akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } + { akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } + { Akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } + { Akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } + } { \bool_set_true:N \l__crefthe_variant_matched_bool } + } + \bool_if:NF \l__crefthe_variant_matched_bool + { + \bool_gset_true:N \g__crefthe_has_prep_bool + \tl_set:Nn \l__crefthe_prep_tl { #1 } + } + } + } \bool_new:N \l__crefthe_variant_matched_bool \cs_new_protected:Nn \__crefthe_cref_general:NNNnnN @@ -136,50 +153,16 @@ \group_begin: \tl_set:Nn \l__crefthe_variant_tl {} + \bool_set_false:N \l__crefthe_abbr_bool + \bool_gset_false:N \g__crefthe_has_prep_bool \tl_set:Nn \l__crefthe_prep_tl {} - \keys_set:nn { crefthe-setting } { #4 } + \keys_set:nn { crefthe-command } { #4 } + % Below is for getting the preposition + \keyval_parse:NNn \__crefthe_command_key_parser:n \use_none:nn { #4 } - % This should actually be part of the keys parsing - \clist_map_inline:nn { #4 } - { - \bool_set_false:N \l__crefthe_variant_matched_bool - \str_if_in:nnF { ##1 } { = } - {% for keys without values - \str_case:nnT { ##1 } - { - { abbr } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } } - { abbr. } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } } - } { \bool_set_true:N \l__crefthe_variant_matched_bool } - \str_if_eq:VnT \languagename { ngerman } - { - \str_case:nnT { ##1 } - { - { nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } - { nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } - { Nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } - { Nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } } - { gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } - { gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } - { Gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } - { Gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } } - { dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } - { dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } - { Dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } - { Dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } } - { akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } - { akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } - { Akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } - { Akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } } - } { \bool_set_true:N \l__crefthe_variant_matched_bool } - } - \bool_if:NF \l__crefthe_variant_matched_bool - { - \tl_set:Nn \l__crefthe_prep_tl { ##1 } - } - } - } + \bool_if:NT \l__crefthe_abbr_bool { \tl_set:Nn \l__crefthe_variant_tl { abbr. } } \bool_if:NTF #2 { \tl_set:No \l__crefthe_prep_once_tl { \l__crefthe_prep_tl } } @@ -286,6 +269,9 @@ \crefthe_pass_variant_to:n { \Crefthename { #1 } } } +\NewCommandCopy \setcrefname \crefthevariantname +\NewCommandCopy \setCrefname \Crefthevariantname + \tl_new:N \l__crefthe_variant_noun_singular_tl \tl_new:N \l__crefthe_variant_noun_plural_tl \tl_new:N \l__crefthe_variant_article_singular_tl @@ -326,7 +312,7 @@ \cs_new_protected:Npn \__crefthe_parse_variant_default:n #1 { \bool_set_true:N \l__crefthe_variant_default_bool - \__crefthe_variant_parser:w #1 \q_stop + \__crefthe_variant_parser:w #1 {} {} \q_stop \tl_set:Nx \l__crefthe_variant_default_article_singular_tl { \tl_item:Nn \l__crefthe_parsed_tl { 1 } } \tl_set:Nx \l__crefthe_variant_default_noun_singular_tl @@ -338,7 +324,7 @@ } \cs_new_protected:Npn \__crefthe_parse_variant_value:nn #1#2 { - \__crefthe_variant_parser:w #2 \q_stop + \__crefthe_variant_parser:w #2 {} {} \q_stop \tl_put_right:Nx \l__crefthe_variant_article_singular_tl { { \tl_to_str:n { #1 } } { \tl_item:Nn \l__crefthe_parsed_tl { 1 } } } \tl_put_right:Nx \l__crefthe_variant_noun_singular_tl @@ -509,7 +495,10 @@ { De~les } { Des } } -\bool_if:NF \l__crefthe_disable_contractions_for_german_bool +\bool_if:NTF \l__crefthe_disable_contractions_for_german_bool + { + \tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl {} + } { \tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl { |