-
Notifications
You must be signed in to change notification settings - Fork 3
/
kaorefs.sty
205 lines (174 loc) · 9.21 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
\ProvidesPackage{kaorefs}
% Easily label and reference elements
% Note that \label must appear after \caption
% Load this package last
% 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{\tablenameshort}{}
\newcommand{\eqname}{}
\newcommand{\eqnameshort}{}
\newcommand{\defname}{}
\newcommand{\assumname}{}
\newcommand{\thmname}{}
\newcommand{\propname}{}
\newcommand{\lemmaname}{}
\newcommand{\remarkname}{}
\newcommand{\examplename}{}
\newcommand{\exercisename}{}
\addto\captionsdanish{%
\renewcommand{\chapternameshort}{Kap.}
\renewcommand{\sectionname}{Sektion}
\renewcommand{\sectionnameshort}{Sek.}
\renewcommand{\subsectionname}{Undersektion}
\renewcommand{\subsectionnameplural}{Undersectioner}
\renewcommand{\subsectionnameshort}{Undersek.}
\renewcommand{\figurenameshort}{Fig.}
\renewcommand{\tablenameshort}{Tab.}
\renewcommand{\eqname}{Formel}
\renewcommand{\eqnameshort}{Frml.}
\renewcommand{\defname}{Definition}
\renewcommand{\assumname}{Hypotese}
\renewcommand{\thmname}{Sætning}
\renewcommand{\propname}{Postulat}
\renewcommand{\lemmaname}{Hjælpesætning}
\renewcommand{\remarkname}{Bemærkning}
\renewcommand{\examplename}{Eksempel}
\renewcommand{\exercisename}{Øvelse}
}
\addto\captionsenglish{%
\renewcommand{\chapternameshort}{Chap.}
\renewcommand{\sectionname}{Section}
\renewcommand{\sectionnameshort}{Sec.}
\renewcommand{\subsectionname}{Subsection}
\renewcommand{\subsectionnameplural}{Subsections}
\renewcommand{\subsectionnameshort}{Subsec.}
\renewcommand{\figurenameshort}{Fig.}
\renewcommand{\tablenameshort}{Tab.}
\renewcommand{\eqname}{Equation}
\renewcommand{\eqnameshort}{Eq.}
\renewcommand{\defname}{Definition}
\renewcommand{\assumname}{Assumption}
\renewcommand{\thmname}{Theorem}
\renewcommand{\propname}{Proposition}
\renewcommand{\lemmaname}{Lemma}
\renewcommand{\remarkname}{Remark}
\renewcommand{\examplename}{Example}
\renewcommand{\exercisename}{Exercise}
}
\addto\captionsitalian{%
\renewcommand{\chapternameshort}{Cap.}
\renewcommand{\sectionname}{Sezione}
\renewcommand{\sectionnameshort}{Sez.}
\renewcommand{\subsectionname}{Sottosezione}
\renewcommand{\subsectionnameplural}{Sottosezioni}
\renewcommand{\subsectionnameshort}{Sottosezione}
\renewcommand{\figurenameshort}{Fig.}
\renewcommand{\tablenameshort}{Tab.}
\renewcommand{\eqname}{Equazione}
\renewcommand{\eqnameshort}{Eq.}
\renewcommand{\defname}{Definizione}
\renewcommand{\assumname}{Assunzione}
\renewcommand{\thmname}{Teorema}
\renewcommand{\propname}{Proposizione}
\renewcommand{\lemmaname}{Lemma}
\renewcommand{\remarkname}{Osservazione}
\renewcommand{\examplename}{Esempio}
\renewcommand{\exercisename}{Esercizio}
}
% Do you speak other languages? Please, feel free to add the captions!
% 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{\labassum}[1]{\label{assum:#1}}
\newcommand{\labprop}[1]{\label{prop:#1}}
\newcommand{\lablemma}[1]{\label{lemma:#1}}
\newcommand{\labremark}[1]{\label{remark:#1}}
\newcommand{\labexample}[1]{\label{example:#1}}
\newcommand{\labexercise}[1]{\label{exercise:#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]{Table}\xspace\ref{tab:#1}}}
\newcommand{\reftab}[1]{\hyperref[tab:#1]{\tablename}\xspace\ref{tab:#1}}
\newcommand{\vreftab}[1]{\hyperref[tab:#1]{\tablename\xspace\vref{tab:#1}}}
\newcommand{\refeqshort}[1]{\hyperref[eq:#1]\eqnameshort\xspace(\ref{eq:#1})}
\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{\refassum}[1]{\hyperref[assum:#1]\assumname\xspace\ref{assum:#1}}
\newcommand{\vrefassum}[1]{\hyperref[assum:#1]\assumname\xspace\vref{assum:#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{\reflemma}[1]{\hyperref[lemma:#1]\lemmaname\xspace\ref{lemma:#1}}
\newcommand{\vreflemma}[1]{\hyperref[lemma:#1]\lemmaname\xspace\vref{lemma:#1}}
\newcommand{\refremark}[1]{\hyperref[remark:#1]\remarkname\xspace\ref{remark:#1}}
\newcommand{\vrefremark}[1]{\hyperref[remark:#1]\remarkname\xspace\vref{remark:#1}}
\newcommand{\refexample}[1]{\hyperref[example:#1]\examplename\xspace\ref{example:#1}}
\newcommand{\vrefexample}[1]{\hyperref[example:#1]\examplename\xspace\vref{example:#1}}
\newcommand{\refexercise}[1]{\hyperref[exercise:#1]\exercisename\xspace\ref{exercise:#1}}
\newcommand{\vrefexercise}[1]{\hyperref[exercise:#1]\exercisename\xspace\vref{exercise:#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}