81 lines
1.7 KiB
TeX
81 lines
1.7 KiB
TeX
\NeedsTeXFormat{LaTeX2e}
|
|
\ProvidesPackage{PrimeTeX/packages/Caption}[2025-08-20]
|
|
|
|
\RequirePackage[
|
|
hypcap=true,
|
|
]{caption}
|
|
\captionsetup{
|
|
justification = Centering,
|
|
font = {
|
|
small,
|
|
color=caption,
|
|
},
|
|
}
|
|
|
|
% Define a justification style that is ragged on the side toward the outside of
|
|
% the page. I. e. RaggedRight on
|
|
% \RequirePackage{changepage}
|
|
|
|
\DeclareCaptionJustification{RaggedOutside}{%
|
|
\ifthenelse{\boolean{isElectronic}}{%
|
|
\RaggedRight%
|
|
}{%
|
|
\checkoddpage%
|
|
\ifoddpage%
|
|
\RaggedRight%
|
|
\else%
|
|
\RaggedLeft%
|
|
\fi%
|
|
}%
|
|
}
|
|
|
|
\ExplSyntaxOn
|
|
|
|
\keys_define:nn {MyCaption} {
|
|
figure .code:n = {\str_set:Nn \l_MyCaption_type_str {figure}},
|
|
|
|
format .tl_set:N = \l_MyCaption_format_tl,
|
|
format .initial:n = {\Centering\small\color{caption}},
|
|
|
|
table .code:n = {\str_set:Nn \l_MyCaption_type_str {table}},
|
|
|
|
type .choices:nn = {figure,table}{
|
|
\str_set:Ne \l_MyCaption_type_str {\l_keys_choice_tl}
|
|
},
|
|
type .initial:n = {figure},
|
|
}
|
|
|
|
\tl_new:N \l_MyCaption_label_tl
|
|
\tl_new:N \l_MyCaption_number_tl
|
|
|
|
\NewDocumentCommand{\MyCaption}{
|
|
% #1: Key-value options.
|
|
O{}
|
|
% #2: Label
|
|
m
|
|
% #3: Caption
|
|
m
|
|
}{ \group_begin:
|
|
\keys_set:nn {MyCaption} {#1}
|
|
\str_case:en {\l_MyCaption_type_str} {
|
|
{figure} {
|
|
\addtocounter{figure}{1}
|
|
\tl_set:Nn \l_MyCaption_label_tl {Figure}
|
|
\tl_set:Nn \l_MyCaption_number_tl {
|
|
\arabic{chapter}.\arabic{figure}
|
|
}
|
|
\addcontentsline{lof}{figure}{\l_MyCaption_number_tl\numberline#3}
|
|
}
|
|
{table} {
|
|
\addtocounter{table}{1}
|
|
\tl_set:Nn \l_MyCaption_label_tl {Table}
|
|
\tl_set:Nn \l_MyCaption_number_tl {
|
|
\arabic{chapter}.\arabic{table}
|
|
}
|
|
\addcontentsline{lot}{table}{\l_MyCaption_number_tl\numberline#3}
|
|
}
|
|
}
|
|
\l_MyCaption_format_tl
|
|
\l_MyCaption_label_tl~\l_MyCaption_number_tl :~#3
|
|
\label{#2}
|
|
\group_end: } |