From 6130aab230eccfd6c5b894ef781a5252216c5752 Mon Sep 17 00:00:00 2001 From: Silcantar Date: Wed, 3 Sep 2025 22:19:44 -0500 Subject: [PATCH] Fix bugs. --- commonincludes.def | 5 +- packages/Boxout.sty | 165 +++++++++++++++++++++++------------------- packages/Caption.sty | 2 +- packages/Floats.sty | 48 ++++++------ packages/Graphics.sty | 4 +- packages/Header.sty | 16 ++-- packages/Layout.sty | 8 +- 7 files changed, 134 insertions(+), 114 deletions(-) diff --git a/commonincludes.def b/commonincludes.def index 71b379f..ab18a87 100644 --- a/commonincludes.def +++ b/commonincludes.def @@ -1,5 +1,8 @@ \ProvidesFile{commonincludes.def}[2025-09-02 v1.0] +% A lot of other packages require Layout, so load it first. +\RequirePackage{PrimeTeX/packages/Layout} + \RequirePackage{PrimeTeX/packages/Boxout} \RequirePackage{PrimeTeX/packages/Caption} @@ -28,8 +31,6 @@ \RequirePackage{PrimeTeX/packages/Index} -\RequirePackage{PrimeTeX/packages/Layout} - \RequirePackage{PrimeTeX/packages/Links} \RequirePackage{PrimeTeX/packages/Marginalia} diff --git a/packages/Boxout.sty b/packages/Boxout.sty index 3b9885b..a0f74b2 100644 --- a/packages/Boxout.sty +++ b/packages/Boxout.sty @@ -1,5 +1,7 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{PrimeTeX/packages/Boxout}[2025-08-20] +\ProvidesExplPackage{PrimeTeX/packages/Boxout}{2025-09-03}{1.0}{ + Commands for typesetting boxouts. +} \RequirePackage{PrimeTeX/packages/Layout} \RequirePackage{PrimeTeX/packages/Color} @@ -16,107 +18,118 @@ hborder{Z} = {abovespace=\boxoutpadding}, hlines = {0pt,boxoutBG}, hline{1,Z} = {\boxoutrule,boxoutFG}, - %row{1} = {font={\bfseries\sbfamily}}, vborder{1} = {rightspace=\boxoutpadding}, vborder{Z} = {leftspace=\boxoutpadding}, vlines = {0pt,boxoutBG}, vline{1,Z} = {\boxoutrule,boxoutFG}, } -\NewDocumentEnvironment{@boxout}{ - m m +b -}{ - \label{box:#1}% - \begin{tblrBoxout}{#2}% - #3% +\str_const:Nn \c_Boxout_colspec_str {{X[l,h]}} +\bool_const:Nn \c_Boxout_warning_bool {\c_false_bool} + +\keys_define:nn{Boxout}{ + colspec .str_set_e:N= \l_Boxout_colspec_str, + colspec .initial:e = {\c_Boxout_colspec_str}, + + warning .bool_set:N = \l_Boxout_warning_bool, +} + +\NewDocumentEnvironment{Boxout}{ + % #1: Key-value options. + O{} + % #2: Label, passed to @boxout argument #1. + >{\TrimSpaces}m + % #3: Caption. + m + % #4: Body, passed to @boxout. + +b +}{% + \keys_set:nn{Boxout}{#1} + \bool_if:nT \l_Boxout_warning_bool {% + \colorlet{boxoutBG}{warningBG}% + \colorlet{boxoutFG}{warningFG}% + }% + \label{box:#2}% + \message{colspec=\str_use:N \l_Boxout_colspec_str} + \SetTblrInner{colspec:e=\l_Boxout_colspec_str} + \begin{tblrBoxout}{}% + \IfBlankF{#3}{\Centering\sbfamily\bfseries #3\\}% + \setlength{\parskip}{\medskipamount}% + #4\\% \end{tblrBoxout}% }{} -\NewDocumentEnvironment{Boxout}{ - % #1: Label, passed to @boxout argument #1. - >{\TrimSpaces}m - % #2: Tabularray colspec, passed to @boxout argument #2. - O{colspec={X[l,h]}} - % #3: Caption. - m - % #4: [Ww] for warning box. - o - % #5: Body, passed to @boxout. - +b -}{% - \ifthenelse{\equal{#4}{w}\OR\equal{#4}{W}}{% - \colorlet{boxoutBG}{warningBG}% - \colorlet{boxoutFG}{warningFG}% - }{}% - \IfBlankTF{#3}{% - \begin{@boxout}{#1}{#2}{}% - \setlength{\parskip}{\medskipamount}% - #5\\% - \end{@boxout}% - }{% - \begin{@boxout}{#1}{#2}% - {\Centering\sbfamily\bfseries #3}\\% - \setlength{\parskip}{\medskipamount}% - #5\\% - \end{@boxout}% - }% -}{} +\keys_define:nn{}{ + BigBoxout .inherit:n = BigFloat, + BigBoxout .inherit:n = Boxout, +} -\ExplSyntaxOn \NewDocumentEnvironment{BigBoxout}{ - % #1: Overhang, passed to BigFloat argument #1. - O{\c_BigFloat_overhang_dim} - % #2: Float placement, passed to BigFloat argument #2. - O{h,t,p,b} - % #3: Offset ratio, passed to BigFloat argument #3. - O{\c_BigFloat_offset_fp} - % #4: Label, passed to Boxout argument #1. + % #1: Key-value options. + O{} + % #2: Label, passed to Boxout argument #1. >{\TrimSpaces}m - % #5: Tabularray colspec, passed to Boxout argument #2. - O{X[l,h]} - % #6: Caption, passed to Boxout argument #3. + % #5: Tabularray colspec, passed to Boxout argument #2. + %O{X[l,h]} + % #3: Caption, passed to Boxout argument #3. m - % #7: [Ww] for warning box, if present passed to Boxout argument #4. - o - % #8: Body, passed to Boxout. + % #4: Body, passed to Boxout. +b }{ + \keys_set:nn{BigBoxout}{#1} \begin{BigFloat}[ type = generic, - overhang = #1, - placement = {#2}, - offset = #3, + overhang = \l_BigFloat_overhang_dim, + placement:e = \l_BigFloat_placement_clist, + offset = \l_BigFloat_offset_fp, ]% - \IfNoValueTF{#7}{% - \begin{Boxout}{#4}[#5]{#6}% - #8% - \end{Boxout}% - }{% - \begin{Boxout}{#4}[#5]{#6}[#7]% - #8% - \end{Boxout}% - }% + \begin{Boxout}[% + warning=\l_Boxout_warning_bool, + colspec=\l_Boxout_colspec_str, + ]{#2}[\l_Boxout_colspec_str]{#3}% + #4% + \end{Boxout}% \end{BigFloat}% }{} -\ExplSyntaxOff + +\str_const:Nn \c_WrapBoxout_position_str {o} +\dim_const:Nn \c_WrapBoxout_offset_dim {\marparwidth} +\dim_const:Nn \c_WrapBoxout_width_dim {3in} + +\keys_define:nn{}{ + WrapBoxout .inherit:n = Boxout, +} +\keys_define:nn{WrapBoxout}{ + position .choices:nn = {l,r,i,o}{ + \str_set:Nn \l_WrapBoxout_position_str {\l_keys_choice_tl} + }, + position .initial:e = {\c_WrapBoxout_position_str}, + + offset .dim_set:N = \l_WrapBoxout_offset_dim, + offset .initial:e = {\c_WrapBoxout_offset_dim}, + + width .dim_set:N = \l_WrapBoxout_width_dim, + width .initial:e = {\c_WrapBoxout_width_dim}, +} \NewDocumentEnvironment{WrapBoxout}{ - % position [l,r,i,o] - O{o} - % offset - O{\marparwidth} - % width - O{3in} - O{X[l,h]} + % #1: Key-value options. + O{} + % #2: Label. >{\TrimSpaces}m + % #3: Caption m - o + % #4: Body. +b }{% - \begin{wrapfigure}{#1}[#2]% - \begin{minipage}{#3}% - \begin{Boxout}[#4]{#5}{#6}[#7]% - #8% + \keys_set:nn{WrapBoxout}{#1} + \begin{wrapfigure}{\l_WrapBoxout_position_str}[\l_WrapBoxout_offset_dim]% + \begin{minipage}{\l_WrapBoxout_width_dim}% + \begin{Boxout}[ + colspec = \l_Boxout_colspec_str, + warning = \l_Boxout_warning_bool, + ]{#2}{#3}% + #4% \end{Boxout}% \end{minipage}% \end{wrapfigure}% diff --git a/packages/Caption.sty b/packages/Caption.sty index 9583653..a8812ac 100644 --- a/packages/Caption.sty +++ b/packages/Caption.sty @@ -14,7 +14,7 @@ % Define a justification style that is ragged on the side toward the outside of % the page. I. e. RaggedRight on -\RequirePackage{changepage} +% \RequirePackage{changepage} \DeclareCaptionJustification{RaggedOutside}{% \ifthenelse{\boolean{isElectronic}}{% diff --git a/packages/Floats.sty b/packages/Floats.sty index b604fee..cd0501e 100644 --- a/packages/Floats.sty +++ b/packages/Floats.sty @@ -4,6 +4,8 @@ Custom Float Environments. } +\RequirePackage{PrimeTeX/packages/Layout} + % I think this redefines how float environments evaluate the placement argument, % allowing a command in the argument to be expanded before it is used. Otherwise % it thinks we are trying to use the literal command name as the placement. @@ -12,6 +14,8 @@ } \def\@expenvopt#1#2#3{#2{#3}[#1]} +\RequirePackage{float} + \floatstyle{plain} \newfloat{generic}{htpb}{lgf} @@ -24,26 +28,26 @@ \ProvideLength{\BigFloatOverhang}[\dim_use:N \c_BigFloat_overhang_dim] \NewDocumentCommand{\BigFloatOffset}{}{\fp_use:N \c_BigFloat_offset_fp} -\str_new:N \l_BigFloat_placement_str +\clist_new:N \l_BigFloat_placement_clist \keys_define:nn{BigFloat}{ type .choices:nn = {figure,generic,table}{ \str_set:Ne \l_BigFloat_type_str {\l_keys_choice_tl} }, type .default:e = {\c_BigFloat_type_str}, -% type .initial:e = {\c_BigFloat_type_str}, + type .initial:e = {\c_BigFloat_type_str}, overhang .dim_set:N = \l_BigFloat_overhang_dim, overhang .default:e = {\c_BigFloat_overhang_dim}, -% overhang .initial:e = {\c_BigFloat_overhang_dim}, + overhang .initial:e = {\c_BigFloat_overhang_dim}, placement .multichoices:nn = {b,H,h,p,t}{ - \str_put_right:Ne \l_BigFloat_placement_str {\l_keys_choice_tl} + \clist_put_right:Ne \l_BigFloat_placement_clist {\l_keys_choice_tl} }, offset .fp_set:N = \l_BigFloat_offset_fp, offset .default:e = {\c_BigFloat_offset_fp}, -% offset .initial:e = {\c_BigFloat_offset_fp}, + offset .initial:e = {\c_BigFloat_offset_fp}, } \NewDocumentEnvironment{BigFloat}{ @@ -53,10 +57,9 @@ +b }{% \keys_set:nn{BigFloat}{#1}% - \str_if_empty:NT \l_BigFloat_placement_str { - \str_set:Ne \l_BigFloat_placement_str { - \clist_use:Nn \c_BigFloat_placement_clist {} - } + %\str_new:N \l_BigFloat_placement_str + \str_set:Ne \l_BigFloat_placement_str { + \clist_use:Nn \c_BigFloat_placement_clist {} } \ExpEnvOption% \begin{\l_BigFloat_type_str}[\l_BigFloat_placement_str]% float environment @@ -120,17 +123,18 @@ \end{figure}% } -\keys_define:nn{BigFig}{ - overhang .dim_set:N = \l_BigFig_overhang_dim, - overhang .initial:e = {\c_BigFloat_overhang_dim}, -% overhang .default:e = {\c_BigFloat_overhang_dim}, - - placement .clist_set:N= \l_BigFig_placement_clist, - - offset .fp_set:N = \l_BigFig_offset_fp, - offset .initial:e = {\c_BigFloat_offset_fp}, -% offset .default:e = {\c_BigFloat_offset_fp}, +\keys_define:nn{}{ + BigFig .inherit:n = BigFloat, } +% \keys_define:nn{BigFig}{ +% overhang .dim_set:N = \l_BigFig_overhang_dim, +% overhang .initial:e = {\c_BigFloat_overhang_dim}, + +% placement .clist_set:N= \l_BigFig_placement_clist, + +% offset .fp_set:N = \l_BigFig_offset_fp, +% offset .initial:e = {\c_BigFloat_offset_fp}, +% } \NewDocumentCommand{\BigFig}{ % Key=value options. @@ -145,9 +149,9 @@ \keys_set:nn{BigFig}{#1} \begin{BigFloat}[ type = figure, - overhang = \l_BigFig_overhang_dim, - placement:e = \l_BigFig_placement_clist, - offset = \l_BigFig_offset_fp, + overhang = \l_BigFloat_overhang_dim, + placement:e = {\clist_use:Nn \l_BigFloat_placement_clist {}}, + offset = \l_BigFloat_offset_fp, ]% \captionsetup{type=figure}% \includegraphics[keepaspectratio,width=\linewidth]{#2}% diff --git a/packages/Graphics.sty b/packages/Graphics.sty index 074e5d0..670b243 100644 --- a/packages/Graphics.sty +++ b/packages/Graphics.sty @@ -31,7 +31,9 @@ }{% \keys_set:nn{InlineGraphic}{#1} \raisebox{\l_InlineGraphic_offset_dim}{ - \includegraphics[keepaspectratio,height=\l_InlineGraphic_height_dim]{#2} + \includegraphics[% + keepaspectratio,height=12pt%\l_InlineGraphic_height_dim% + ]{#2} }% } diff --git a/packages/Header.sty b/packages/Header.sty index 6ecf64f..cf72353 100644 --- a/packages/Header.sty +++ b/packages/Header.sty @@ -5,15 +5,15 @@ \RequirePackage{PrimeTeX/packages/Layout} -\dim_new:N \g_header_insideoffset_dim -\dim_set:Nn \g_header_insideoffset_dim {\c_BigFloat_overhang_dim} -\dim_new:N \g_header_outsideoffset_dim -\dim_set:Nn \g_header_outsideoffset_dim { - \fp_to_dim:n {\c_BigFloat_overhang_dim * \c_BigFloat_offset_fp} -} +% \dim_new:N \g_header_insideoffset_dim +% \dim_set:Nn \g_header_insideoffset_dim {\c_BigFloat_overhang_dim} +% \dim_new:N \g_header_outsideoffset_dim +% \dim_set:Nn \g_header_outsideoffset_dim { +% \fp_to_dim:n {\c_BigFloat_overhang_dim * \c_BigFloat_offset_fp} +% } -\ProvideLength{\HeaderInsideOffset}[\BigFloatOverhang] -\ProvideLength{\HeaderOutsideOffset}[\BigFloatOverhang * \real{\BigFloatOffset}] +\ProvideLength{\HeaderInsideOffset}[0.54in]%[\BigFloatOverhang] +\ProvideLength{\HeaderOutsideOffset}[1.08in]%[\BigFloatOverhang * \real{\BigFloatOffset}] % Header & Footer Options \RequirePackage{fancyhdr} diff --git a/packages/Layout.sty b/packages/Layout.sty index 05cc7ce..da68243 100644 --- a/packages/Layout.sty +++ b/packages/Layout.sty @@ -1,5 +1,5 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{PrimeTeX/packages/Layout}[2025-07-09] +\ProvidesPackage{PrimeTeX/packages/Layout}%{2025-09-03}{1.0}{Layout.} % Suppress warning about \showhyphens being changed. \let\CheckCommand\providecommand @@ -28,8 +28,6 @@ footskip = 0.5in, % 36pt, ]{geometry} -\RequirePackage{float} - % Redefine the commands geometry uses to draw the page frame to customize the % color. \renewcommand{\Gm@vrule}{\color{layout}\vrule width 0.2pt height\textheight depth\z@} @@ -39,6 +37,8 @@ % Suppress "Underfull \hbox" infos. \hbadness=10000 +\RequirePackage{ifthen} + \ifthenelse{\boolean{isDraft}}{ \geometry{showframe} \hfuzz = 0.5pt @@ -139,7 +139,7 @@ } \restoregeometry - \ExplSyntaxOn + %\ExplSyntaxOn \NewDocumentEnvironment{SmallMargin}{O{0.0in} O{-0.25in}}{ \clearpage \loadgeometry{smallMargin}