\NeedsTeXFormat{LaTeX2e}
\ProvidesExplPackage{PrimeTeX/packages/Titles}{2025-07-16}{1.0}{
	Title formatting definitions.
}

\NewExpandableDocumentCommand{\NumberWord}{O{lowercase} m}{
	\use:c {text_#1:n} {
		\int_case:nn {#2} {
			{0} {zero}
			{1} {one}
			{2} {two}
			{3} {three}
			{4} {four}
			{5} {five}
			{6} {six}
			{7} {seven}
			{8} {eight}
			{9} {nine}
			{10} {ten}
			{11} {eleven}
			{12} {twelve}
			{13} {thirteen}
			{14} {fourteen}
			{15} {fifteen}
			{16} {sixteen}
			{17} {seventeen}
			{18} {eighteen}
			{19} {nineteen}
		}
	}
}


\bool_if:NF \g_roman_bool {
	\renewcommand{\thepart}{\arabic{part}}
}

\bool_if:NT \g_number_word_bool {
	\renewcommand{\thepart}{\NumberWord[titlecase_all]{\value{part}}}
}

\titleformat{\part}[display]{
	\normalfont\sbfamily\huge
}{
	\partname{}~\thepart
}{20pt}{\Huge\raggedright}

\titleformat{\chapter}[display]{
	\normalfont\sbfamily\huge\raggedright
}{
	\chaptertitlename{}~\thechapter
}{20pt}{\Huge}

%\titlespacing{\chapter}{0pt}{48pt plus 12pt minus 12pt}{24pt plus 6pt minus 6pt}

\titleformat*{\section}{\sbfamily\Large}

%\titlespacing{\section}{0pt}{16pt plus 4pt minus 4pt}{14pt plus 3pt minus 3pt}

\titleformat*{\subsection}{\sbfamily\large}

%\titlespacing{\subsection}{0pt}{14pt plus 3pt minus 3pt}{12pt plus 3pt minus 3pt}

\titleformat*{\subsubsection}{\sbfamily}

\titleformat*{\paragraph}{\sbfamily}

\titleformat*{\subparagraph}{\sbfamily}
