\NeedsTeXFormat{LaTeX2e} \ProvidesExplPackage{PrimeTeX/packages/Caption}{2025-09-10}{1.0}{ Custom Caption commands. } % \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} \NewDocumentCommand{\RaggedOutside}{}{ \ifthenelse{\boolean{isElectronic}}{% \RaggedRight% }{% \checkoddpage% \ifoddpage% \RaggedRight% \else% \RaggedLeft% \fi% }% } \cs_new:Nn \__MyCaption_format_default: {\centering\small\color{caption}} \keys_define:nn {MyCaption} { before .bool_set:N = \l_MyCaption_before_bool, before .initial:n = {false}, figure .code:n = {\str_set:Nn \l_MyCaption_type_str {figure}}, format .cs_set_protected:Np = \__MyCaption_format:, format .initial:n = {\__MyCaption_format_default:}, skip .tl_set:N = \l_MyCaption_skip_tl, skip .initial:n = {\medskipamount}, table .code:n = { \str_set:Nn \l_MyCaption_type_str {table} \bool_set:Nn \l_MyCaption_before_bool {true} }, type .choices:nn = {figure,table}{ \str_set:Ne \l_MyCaption_type_str {\l_keys_choice_tl} }, type .initial:n = {figure}, } \str_new:N \l_MyCaption_label_str \str_new:N \l_MyCaption_number_str \NewDocumentEnvironment{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} { \refstepcounter{figure} \str_set:Nn \l_MyCaption_label_str {Figure} \str_set:Ne \l_MyCaption_number_str { \arabic{chapter}.\arabic{figure} } \addcontentsline{lof}{figure}{\protect\numberline{\l_MyCaption_number_str}\protect\ignorespaces~#3} } {table} { \refstepcounter{table} \str_set:Nn \l_MyCaption_label_str {Table} \str_set:Ne \l_MyCaption_number_str { \arabic{chapter}.\arabic{table} } \addcontentsline{lot}{table}{\protect\numberline{\l_MyCaption_number_str}\protect\ignorespaces~#3} } } \bool_if:NT \l_MyCaption_before_bool { \__MyCaption_insert_caption:nn {#2} {#3} } }{ \bool_if:NF \l_MyCaption_before_bool { \__MyCaption_insert_caption:nn {#2} {#3} } \group_end: } \cs_new:Nn \__MyCaption_insert_caption:nn { \setlength{\parskip}{\l_MyCaption_skip_tl}\par \__MyCaption_format: \l_MyCaption_label_str{}~\l_MyCaption_number_str :~#2 \label{#1} \par }