-
Notifications
You must be signed in to change notification settings - Fork 0
/
kaorefs.sty
163 lines (134 loc) · 7.76 KB
/
kaorefs.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
\ProvidesPackage{kaorefs}
% Étiqueter et référencer facilement les éléments
% Notez que \label doit apparaître après \caption
% Chargez ce paquet en dernier
% Pass this package's options to hyperref and varioref
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{varioref}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{hyperref}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{cleveref}}
\ProcessOptions\relax
\let\thmname\relax % Workaround to get rid of an annoying error
\RequirePackage{varioref}
\RequirePackage{hyperref}
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}
% Language-specific strings
% #LANGUAGE
\newcommand{\chapternameshort}{}
\newcommand{\sectionname}{}
\newcommand{\sectionnameshort}{}
\newcommand{\subsectionname}{}
\newcommand{\subsectionnameplural}{}
\newcommand{\subsectionnameshort}{}
\newcommand{\figurenameshort}{}
\newcommand{\tableaunameshort}{}
\newcommand{\eqname}{}
\newcommand{\eqnameshort}{}
\newcommand{\defname}{}
\newcommand{\hyponame}{}
\newcommand{\thmname}{}
\newcommand{\propname}{}
\newcommand{\lemmename}{}
\newcommand{\remarquename}{}
\newcommand{\exemplename}{}
\newcommand{\exercicename}{}
\addto\captionsfrench{%
\renewcommand{\chapternameshort}{Chap.}
\renewcommand{\sectionname}{Section}
\renewcommand{\sectionnameshort}{Sec.}
\renewcommand{\subsectionname}{Sous-section}
\renewcommand{\subsectionnameplural}{Sous-sections}
\renewcommand{\subsectionnameshort}{S.-sec.}
\renewcommand{\figurenameshort}{Fig.}
\renewcommand{\tableaunameshort}{Tab.}
\renewcommand{\eqname}{Équation}
\renewcommand{\eqnameshort}{Eq.}
\renewcommand{\defname}{Définition}
\renewcommand{\hyponame}{Hypothèse}
\renewcommand{\thmname}{Théorème}
\renewcommand{\propname}{Proposition}
\renewcommand{\lemmename}{Lemme}
\renewcommand{\remarquename}{Remarque}
\renewcommand{\exemplename}{Exemple}
\renewcommand{\exercicename}{Exercice}
}
% Labelling commands
\newcommand{\labpage}[1]{\label{page:#1}}
\newcommand{\labpart}[1]{\label{part:#1}}
\newcommand{\labch}[1]{\label{ch:#1}}
\newcommand{\labsec}[1]{\label{sec:#1}}
\newcommand{\labsubsec}[1]{\label{subsec:#1}}
\newcommand{\labfig}[1]{\label{fig:#1}}
\newcommand{\labtab}[1]{\label{tab:#1}}
\newcommand{\labeq}[1]{\label{eq:#1}}
\newcommand{\labdef}[1]{\label{def:#1}}
\newcommand{\labthm}[1]{\label{thm:#1}}
\newcommand{\labhypo}[1]{\label{hypo:#1}}
\newcommand{\labprop}[1]{\label{prop:#1}}
\newcommand{\lablemme}[1]{\label{lemme:#1}}
\newcommand{\labremarque}[1]{\label{remarque:#1}}
\newcommand{\labexemple}[1]{\label{exemple:#1}}
\newcommand{\labexercice}[1]{\label{exercice:#1}}
% Referencing commands
\newcommand{\refpage}[1]{\hyperref[#1]{\pagename}\xspace\pageref{page:#1}} % Page 84
\newcommand{\vrefpage}[1]{\vpageref*{page:#1}} % on the following page, on page 84
% For unnumbered parts
\newcommand{\arefpart}[1]{\hyperref[part:#1]{\partname}\xspace`\nameref{part:#1}'} % Part `Name of the Part'
\newcommand{\avrefpart}[1]{\hyperref[part:#1]{\partname}\xspace`\nameref{part:#1}' \vpageref{part:#1}} % Part `Name of the Part' on page 84
% For numbered parts
\newcommand{\refpart}[1]{\hyperref[part:#1]{\partname}\xspace\ref{part:#1}} % Part IV
\newcommand{\vrefpart}[1]{\hyperref[part:#1]{\partname}\xspace\vref{part:#1}} % Part IV, Part IV on the following page, Part IV on page 84
\newcommand{\nrefpart}[1]{\hyperref[part:#1]{\partname}\xspace\ref{part:#1} (\nameref{part:#1})}
\newcommand{\frefpart}[1]{\hyperref[part:#1]{\partname\xspace\ref{part:#1} (\nameref{part:#1}) \vpageref{part:#1}}} % Part IV (Name of the Part), Part IV (Name of the Part) on the following page, Part IV (Name of the Part) on page 84)
%\newcommand{\refch}[1]{\hyperref[#1]{\chaptername\xspace\usekomafont{chapter}\normalsize\nameref{ch:#1}}\xspace\vpageref{ch:#1}\,}
\newcommand{\refchshort}[1]{\hyperref[ch:#1]{\chapternameshort\xspace\ref{ch:#1}}}
\newcommand{\refch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1}}}
\newcommand{\vrefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} \vpageref{ch:#1}}}
\newcommand{\nrefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} (\nameref{ch:#1})}}
\newcommand{\frefch}[1]{\hyperref[ch:#1]{\chaptername\xspace\ref{ch:#1} (\nameref{ch:#1}) \vpageref{ch:#1}}}
%\newcommand{\refsec}[1]{Section~{\usekomafont{section}\normalsize\nameref{sec:#1}}\xspace\vpageref{sec:#1}\,}
\newcommand{\refsecshort}[1]{\hyperref[sec:#1]{\sectionnameshort\xspace\ref{sec:#1}}}
\newcommand{\refsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1}}}
\newcommand{\vrefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\vref{sec:#1}}}
\newcommand{\nrefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1} \nameref{sec:#1}}}
\newcommand{\frefsec}[1]{\hyperref[sec:#1]{\sectionname\xspace\ref{sec:#1} \nameref{sec:#1} \vpageref{sec:#1}}}
\newcommand{\refsubsecshort}[1]{\hyperref[subsec:#1]{\sectionnameshort\xspace\ref{subsec:#1}}}
\newcommand{\refsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1}}}
\newcommand{\vrefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\vref{subsec:#1}}}
\newcommand{\nrefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1} (\nameref{subsec:#1})}}
\newcommand{\frefsubsec}[1]{\hyperref[subsec:#1]{\subsectionname\xspace\ref{subsec:#1} (\nameref{subsec:#1}) \vpageref{subsec:#1}}}
%\newcommand{\reffig}[1]{{\hypersetup{colorlinks=false}\usekomafont{captionlabel}\hyperref[fig:#1]{Figure}\xspace\ref{fig:#1}}}
\newcommand{\reffigshort}[1]{\hyperref[fig:#1]{\figurenameshort\xspace\ref{fig:#1}}}
\newcommand{\reffig}[1]{\hyperref[fig:#1]{\figurename}\xspace\ref{fig:#1}}
\newcommand{\vreffig}[1]{\hyperref[fig:#1]{\figurename\xspace\vref{fig:#1}}}
%\newcommand{\reftab}[1]{{\hypersetup{colorlinks=false}\usekomafont{captionlabel}\hyperref[tab:#1]{tableau}\xspace\ref{tab:#1}}}
\newcommand{\reftab}[1]{\hyperref[tab:#1]{\tableauname}\xspace\ref{tab:#1}}
\newcommand{\vreftab}[1]{\hyperref[tab:#1]{\tableauname\xspace\vref{tab:#1}}}
\newcommand{\refeqshort}[1]{\hyperref[eq:#1]\eqnameshort\xspace(\ref{eq:#1})}
%%%% Modifie par Alain car conflit avec mathtools %%%
% \newcommand{\refeq}[1]{\hyperref[eq:#1]\eqname\xspace\ref{eq:#1}}
\newcommand{\vrefeq}[1]{\hyperref[eq:#1]\eqname\xspace\vref{eq:#1}}
\newcommand{\refdef}[1]{\hyperref[def:#1]\defname\xspace\ref{def:#1}}
\newcommand{\vrefdef}[1]{\hyperref[def:#1]\defname\xspace\vref{def:#1}}
\newcommand{\refhypo}[1]{\hyperref[hypo:#1]\hyponame\xspace\ref{hypo:#1}}
\newcommand{\vrefhypo}[1]{\hyperref[hypo:#1]\hyponame\xspace\vref{hypo:#1}}
\newcommand{\refthm}[1]{\hyperref[thm:#1]\thmname\xspace\ref{thm:#1}}
\newcommand{\vrefthm}[1]{\hyperref[thm:#1]\thmname\xspace\vref{thm:#1}}
\newcommand{\refprop}[1]{\hyperref[prop:#1]\propname\xspace\ref{prop:#1}}
\newcommand{\vrefprop}[1]{\hyperref[prop:#1]\propname\xspace\vref{prop:#1}}
\newcommand{\reflemme}[1]{\hyperref[lemme:#1]\lemmename\xspace\ref{lemme:#1}}
\newcommand{\vreflemme}[1]{\hyperref[lemme:#1]\lemmename\xspace\vref{lemme:#1}}
\newcommand{\refremarque}[1]{\hyperref[remarque:#1]\remarquename\xspace\ref{remarque:#1}}
\newcommand{\vrefremarque}[1]{\hyperref[remarque:#1]\remarquename\xspace\vref{remarque:#1}}
\newcommand{\refexemple}[1]{\hyperref[exemple:#1]\exemplename\xspace\ref{exemple:#1}}
\newcommand{\vrefexemple}[1]{\hyperref[exemple:#1]\exemplename\xspace\vref{exemple:#1}}
\newcommand{\refexercice}[1]{\hyperref[exercice:#1]\exercicename\xspace\ref{exercice:#1}}
\newcommand{\vrefexercice}[1]{\hyperref[exercice:#1]\exercicename\xspace\vref{exercice:#1}}
% cleveref customisation
% Hyperlink the page reference as well
\let\oldvpageref\vpageref
\renewcommand{\vpageref}[1]{\hyperref[#1]{\oldvpageref{#1}}}
% Remove parentheses around equations
\creflabelformat{equation}{#2\textup{#1}#3}
% Set the refname for subsections
\crefname{subsection}{\subsectionname}{\subsectionnameplural}
\Crefname{subsection}{\subsectionname}{\subsectionnameplural}