diff options
author | Karl Berry <karl@freefriends.org> | 2021-11-05 22:02:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-11-05 22:02:48 +0000 |
commit | 235030c0fcd5b93534487638b23cfb7b0fcdc95b (patch) | |
tree | 7a837c4a4a8998d57648020cab74f87b5a97c0db /Master/texmf-dist/tex | |
parent | 50ab02b7ea81260bd2b6acdcbbfa322cc8b1e3ad (diff) |
crefthe (5nov21)
git-svn-id: svn://tug.org/texlive/trunk@60961 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/crefthe/crefthe.sty | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/crefthe/crefthe.sty b/Master/texmf-dist/tex/latex/crefthe/crefthe.sty new file mode 100644 index 00000000000..366b681f72f --- /dev/null +++ b/Master/texmf-dist/tex/latex/crefthe/crefthe.sty @@ -0,0 +1,156 @@ +%% +%% Copyright (C) 2021 by Jinwen XU +%% ------------------------------- +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3c of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +\NeedsTeXFormat{LaTeX2e}[2020-10-01] +\ProvidesExplPackage + {crefthe} + {2021/11/05} + {} + {Cross referencing with proper definite articles} +\RequirePackage{cleveref} + +\tl_gset:Nn \g_crefthe_prepf_tl {} +\tl_gset:Nn \g_crefthe_prep_tl {} + +\NewDocumentCommand{\crefthe}{st-t+O{}m}{ + \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{\crefthemark}{m}{ + \crefthe_contraction:nn { \tl_use:N \g_crefthe_prep_tl }{ + \crefthe_contraction:nn { \tl_use:N \g_crefthe_prepf_tl }{#1} + } + \tl_gset:Nn \g_crefthe_prepf_tl {} +} + +\cs_set:Npn \crefthe_prep_mode:nn { + \str_case_e:nn { \languagename } + { + {french} { + } + {italian} { + } + {spanish} { - } + {portuguese} { + } + {brazilian} { + } + } +} + +\cs_set:Npn \crefthe_contraction:nn #1#2 { + \str_if_eq:eeTF {#1} {} {#2} { + \str_case_e:nn { \languagename } + { + {french}{ + \str_case_e:nnF {#1~#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} + } + {italian}{ + \str_case_e:nnF {#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~#2} + } + {portuguese}{ + \str_case_e:nnF {#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~#2} + } + {brazilian}{ + \str_case_e:nnF {#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~#2} + } + {spanish}{ + \str_case_e:nnF {#1~#2} { + {a~el} {al} + {de~el} {del} + }{#1~#2} + } + } + } +} +\endinput +%% +%% End of file `crefthe.sty'. |