diff --git a/Manual.cls b/Manual.cls index d5294ae..2130805 100644 --- a/Manual.cls +++ b/Manual.cls @@ -84,6 +84,7 @@ % If the argument is not empty, only chapters that are listed are included. \NewDocumentCommand{\IncludeOnlyChapters}{m}{ \str_set:Nn \l_IncludeOnly_chapters_str {#1} + \str_remove_all:Nn \l_IncludeOnly_chapters_str {~} \str_if_empty:NF \l_IncludeOnly_chapters_str { \expanded{\noexpand\includeonly{\l_IncludeOnly_chapters_str}} } diff --git a/packages/Floats.sty b/packages/Floats.sty index f05e486..b3c24f9 100644 --- a/packages/Floats.sty +++ b/packages/Floats.sty @@ -1,5 +1,4 @@ \NeedsTeXFormat{LaTeX2e} -%\ProvidesPackage{PrimeTeX/packages/Floats}[2025-09-03] \ProvidesExplPackage{PrimeTeX/packages/Floats}{2025-09-03}{1.0}{ Custom Float Environments. } diff --git a/packages/Links.sty b/packages/Links.sty index b795753..78dba37 100644 --- a/packages/Links.sty +++ b/packages/Links.sty @@ -1,5 +1,7 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{PrimeTeX/packages/Links}[2025-08-17] +\ProvidesExplPackage{PrimeTeX/packages/Links}{2025-08-17}{1.0}{ + Hyperref configuration and custom label commands. +} % Use Hyperref to automatically create links in the document \hypersetup{ @@ -28,4 +30,89 @@ \RenewDocumentCommand{\sectionautorefname}{}{Section} \RenewDocumentCommand{\subsectionautorefname}{}{Subsection} \RenewDocumentCommand{\subsubsectionautorefname}{}{Sub-subsection} -\RenewDocumentCommand{\paragraphautorefname}{}{Paragraph} \ No newline at end of file +\RenewDocumentCommand{\paragraphautorefname}{}{Paragraph} + +\bool_new:N \l_SectionLabel_success_bool + +\int_new:N \l_SectionLabel_slash_total_int +\int_new:N \l_SectionLabel_slash_count_int +\int_new:N \l_SectionLabel_char_count_int + +\str_new:N \l_SectionLabel_path_str +\str_new:N \l_SectionLabel_part_str +\str_new:N \l_SectionLabel_chapter_str +\str_new:N \l_SectionLabel_section_str +\str_new:N \l_SectionLabel_subsection_str +\str_new:N \l_SectionLabel_subsubsection_str +\str_new:N \l_SectionLabel_paragraph_str +\str_new:N \l_SectionLabel_subparagraph_str +% part:chapter:section:subsection:subsubsection:paragraph:subparagraph + +\NewDocumentCommand{\SectionLabel}{ + % #1: Section Level. -1=Part, 0=Chapter, 1=Section, 2=Subsection, + % 3=Sub-subsection, 4=Paragraph, 5=Subparagraph + O{} + % Label for the current section. + m +}{ + \str_set:Nn \l_SectionLabel_level_str {#1} + \str_set:Nn \l_SectionLabel_label_str {#2} + \str_case:Nn \l_SectionLabel_level_str { + {} {\int_set:Nn \l_SectionLabel_slash_total_int {0}} + {-1} {\int_set:Nn \l_SectionLabel_slash_total_int {0}} + {0} {\int_set:Nn \l_SectionLabel_slash_total_int {1}} + {1} {\int_set:Nn \l_SectionLabel_slash_total_int {2}} + {2} {\int_set:Nn \l_SectionLabel_slash_total_int {3}} + {3} {\int_set:Nn \l_SectionLabel_slash_total_int {4}} + {4} {\int_set:Nn \l_SectionLabel_slash_total_int {5}} + {5} {\int_set:Nn \l_SectionLabel_slash_total_int {6}} + {part} {\int_set:Nn \l_SectionLabel_slash_total_int {0}} + {chapter} {\int_set:Nn \l_SectionLabel_slash_total_int {1}} + {section} {\int_set:Nn \l_SectionLabel_slash_total_int {2}} + {subsection} {\int_set:Nn \l_SectionLabel_slash_total_int {3}} + {subsubsection} {\int_set:Nn \l_SectionLabel_slash_total_int {4}} + {paragraph} {\int_set:Nn \l_SectionLabel_slash_total_int {5}} + {subparagraph} {\int_set:Nn \l_SectionLabel_slash_total_int {6}} + } + \__SectionLabel_make: + \expandafter\label\expandafter{\l_SectionLabel_path_str} +} + +\NewDocumentCommand{\__SectionLabel_make:}{}{ + \bool_set_false:N \l_SectionLabel_success_bool + \int_set:Nn \l_SectionLabel_char_count_int {0} + \int_set:Nn \l_SectionLabel_slash_count_int {0} + + \str_map_variable:NNn \l_SectionLabel_path_str \l_tmpa_str { + %\message{{\l_tmpa_str}~slash~count:~\int_use:N \l_SectionLabel_slash_count_int\ ~slash~total:~\int_use:N \l_SectionLabel_slash_total_int^^J} + \int_compare:nNnT + {\l_SectionLabel_slash_count_int} = + {\l_SectionLabel_slash_total_int} { + \str_set:Ne \l_tmpb_str {\str_range:Nnn \l_SectionLabel_path_str {1} {\l_SectionLabel_char_count_int}} + \str_concat:NNN + \l_SectionLabel_path_str + \l_tmpb_str + \l_SectionLabel_label_str + \str_map_break:n { + \message{success} + \bool_set_true:N \l_SectionLabel_success_bool + } + } + \int_incr:N \l_SectionLabel_char_count_int + %\message{\l_tmpa_str} + \str_if_eq:VnT \l_tmpa_str {/} { + %\message{increment} + \int_incr:N \l_SectionLabel_slash_count_int + } + } + + \bool_if:NF \l_SectionLabel_success_bool { + \int_do_until:nNnn + {\l_SectionLabel_slash_count_int} = + {\l_SectionLabel_slash_total_int} { + \str_put_right:Nn \l_SectionLabel_path_str {/} + \int_incr:N \l_SectionLabel_slash_count_int + } + \str_put_right:Ne \l_SectionLabel_path_str {\l_SectionLabel_label_str} + } +} \ No newline at end of file diff --git a/packages/Marginalia.sty b/packages/Marginalia.sty index 93f39d0..f558565 100644 --- a/packages/Marginalia.sty +++ b/packages/Marginalia.sty @@ -62,24 +62,24 @@ } \NewDocumentCommand{\MarginFig}{ - % #1: Options passed to \includegraphics. - O{} - % #2: Graphic file name. + % #1: Graphic file name. m + % #2: Options passed to \includegraphics. + O{} % #3: Label. >{\TrimSpaces}m + % #4: Caption. +m }{ - % This strut ensures that the margin figure is counted as part of the + % This mbox ensures that the margin figure is counted as part of the % following paragraph and is vertically aligned with it. - %\strut {\setlength{\parskip}{0pt} \par} \strut \mbox{ \marginalia{ \MarginHyperSetup \begin{MyCaption}[ format={\RaggedOutside\small\color{captionColor}} ]{fig:#3}{#4} - \Centering\includegraphics[keepaspectratio,#1]{#2} + \Centering\includegraphics[keepaspectratio,#2]{#1} \end{MyCaption} } }