Fix bugs.

This commit is contained in:
Silcantar
2025-09-03 22:19:44 -05:00
parent 5178581bbb
commit 6130aab230
7 changed files with 134 additions and 114 deletions

View File

@@ -1,5 +1,8 @@
\ProvidesFile{commonincludes.def}[2025-09-02 v1.0] \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/Boxout}
\RequirePackage{PrimeTeX/packages/Caption} \RequirePackage{PrimeTeX/packages/Caption}
@@ -28,8 +31,6 @@
\RequirePackage{PrimeTeX/packages/Index} \RequirePackage{PrimeTeX/packages/Index}
\RequirePackage{PrimeTeX/packages/Layout}
\RequirePackage{PrimeTeX/packages/Links} \RequirePackage{PrimeTeX/packages/Links}
\RequirePackage{PrimeTeX/packages/Marginalia} \RequirePackage{PrimeTeX/packages/Marginalia}

View File

@@ -1,5 +1,7 @@
\NeedsTeXFormat{LaTeX2e} \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/Layout}
\RequirePackage{PrimeTeX/packages/Color} \RequirePackage{PrimeTeX/packages/Color}
@@ -16,107 +18,118 @@
hborder{Z} = {abovespace=\boxoutpadding}, hborder{Z} = {abovespace=\boxoutpadding},
hlines = {0pt,boxoutBG}, hlines = {0pt,boxoutBG},
hline{1,Z} = {\boxoutrule,boxoutFG}, hline{1,Z} = {\boxoutrule,boxoutFG},
%row{1} = {font={\bfseries\sbfamily}},
vborder{1} = {rightspace=\boxoutpadding}, vborder{1} = {rightspace=\boxoutpadding},
vborder{Z} = {leftspace=\boxoutpadding}, vborder{Z} = {leftspace=\boxoutpadding},
vlines = {0pt,boxoutBG}, vlines = {0pt,boxoutBG},
vline{1,Z} = {\boxoutrule,boxoutFG}, vline{1,Z} = {\boxoutrule,boxoutFG},
} }
\NewDocumentEnvironment{@boxout}{ \str_const:Nn \c_Boxout_colspec_str {{X[l,h]}}
m m +b \bool_const:Nn \c_Boxout_warning_bool {\c_false_bool}
}{
\label{box:#1}% \keys_define:nn{Boxout}{
\begin{tblrBoxout}{#2}% colspec .str_set_e:N= \l_Boxout_colspec_str,
#3% 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}% \end{tblrBoxout}%
}{} }{}
\NewDocumentEnvironment{Boxout}{ \keys_define:nn{}{
% #1: Label, passed to @boxout argument #1. BigBoxout .inherit:n = BigFloat,
>{\TrimSpaces}m BigBoxout .inherit:n = Boxout,
% #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}%
}%
}{}
\ExplSyntaxOn
\NewDocumentEnvironment{BigBoxout}{ \NewDocumentEnvironment{BigBoxout}{
% #1: Overhang, passed to BigFloat argument #1. % #1: Key-value options.
O{\c_BigFloat_overhang_dim} O{}
% #2: Float placement, passed to BigFloat argument #2. % #2: Label, passed to Boxout argument #1.
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.
>{\TrimSpaces}m >{\TrimSpaces}m
% #5: Tabularray colspec, passed to Boxout argument #2. % #5: Tabularray colspec, passed to Boxout argument #2.
O{X[l,h]} %O{X[l,h]}
% #6: Caption, passed to Boxout argument #3. % #3: Caption, passed to Boxout argument #3.
m m
% #7: [Ww] for warning box, if present passed to Boxout argument #4. % #4: Body, passed to Boxout.
o
% #8: Body, passed to Boxout.
+b +b
}{ }{
\keys_set:nn{BigBoxout}{#1}
\begin{BigFloat}[ \begin{BigFloat}[
type = generic, type = generic,
overhang = #1, overhang = \l_BigFloat_overhang_dim,
placement = {#2}, placement:e = \l_BigFloat_placement_clist,
offset = #3, offset = \l_BigFloat_offset_fp,
]% ]%
\IfNoValueTF{#7}{% \begin{Boxout}[%
\begin{Boxout}{#4}[#5]{#6}% warning=\l_Boxout_warning_bool,
#8% colspec=\l_Boxout_colspec_str,
\end{Boxout}% ]{#2}[\l_Boxout_colspec_str]{#3}%
}{% #4%
\begin{Boxout}{#4}[#5]{#6}[#7]% \end{Boxout}%
#8%
\end{Boxout}%
}%
\end{BigFloat}% \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}{ \NewDocumentEnvironment{WrapBoxout}{
% position [l,r,i,o] % #1: Key-value options.
O{o} O{}
% offset % #2: Label.
O{\marparwidth}
% width
O{3in}
O{X[l,h]}
>{\TrimSpaces}m >{\TrimSpaces}m
% #3: Caption
m m
o % #4: Body.
+b +b
}{% }{%
\begin{wrapfigure}{#1}[#2]% \keys_set:nn{WrapBoxout}{#1}
\begin{minipage}{#3}% \begin{wrapfigure}{\l_WrapBoxout_position_str}[\l_WrapBoxout_offset_dim]%
\begin{Boxout}[#4]{#5}{#6}[#7]% \begin{minipage}{\l_WrapBoxout_width_dim}%
#8% \begin{Boxout}[
colspec = \l_Boxout_colspec_str,
warning = \l_Boxout_warning_bool,
]{#2}{#3}%
#4%
\end{Boxout}% \end{Boxout}%
\end{minipage}% \end{minipage}%
\end{wrapfigure}% \end{wrapfigure}%

View File

@@ -14,7 +14,7 @@
% Define a justification style that is ragged on the side toward the outside of % Define a justification style that is ragged on the side toward the outside of
% the page. I. e. RaggedRight on % the page. I. e. RaggedRight on
\RequirePackage{changepage} % \RequirePackage{changepage}
\DeclareCaptionJustification{RaggedOutside}{% \DeclareCaptionJustification{RaggedOutside}{%
\ifthenelse{\boolean{isElectronic}}{% \ifthenelse{\boolean{isElectronic}}{%

View File

@@ -4,6 +4,8 @@
Custom Float Environments. Custom Float Environments.
} }
\RequirePackage{PrimeTeX/packages/Layout}
% I think this redefines how float environments evaluate the placement argument, % 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 % 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. % 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]} \def\@expenvopt#1#2#3{#2{#3}[#1]}
\RequirePackage{float}
\floatstyle{plain} \floatstyle{plain}
\newfloat{generic}{htpb}{lgf} \newfloat{generic}{htpb}{lgf}
@@ -24,26 +28,26 @@
\ProvideLength{\BigFloatOverhang}[\dim_use:N \c_BigFloat_overhang_dim] \ProvideLength{\BigFloatOverhang}[\dim_use:N \c_BigFloat_overhang_dim]
\NewDocumentCommand{\BigFloatOffset}{}{\fp_use:N \c_BigFloat_offset_fp} \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}{ \keys_define:nn{BigFloat}{
type .choices:nn = {figure,generic,table}{ type .choices:nn = {figure,generic,table}{
\str_set:Ne \l_BigFloat_type_str {\l_keys_choice_tl} \str_set:Ne \l_BigFloat_type_str {\l_keys_choice_tl}
}, },
type .default:e = {\c_BigFloat_type_str}, 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 .dim_set:N = \l_BigFloat_overhang_dim,
overhang .default:e = {\c_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}{ 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 .fp_set:N = \l_BigFloat_offset_fp,
offset .default:e = {\c_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}{ \NewDocumentEnvironment{BigFloat}{
@@ -53,10 +57,9 @@
+b +b
}{% }{%
\keys_set:nn{BigFloat}{#1}% \keys_set:nn{BigFloat}{#1}%
\str_if_empty:NT \l_BigFloat_placement_str { %\str_new:N \l_BigFloat_placement_str
\str_set:Ne \l_BigFloat_placement_str { \str_set:Ne \l_BigFloat_placement_str {
\clist_use:Nn \c_BigFloat_placement_clist {} \clist_use:Nn \c_BigFloat_placement_clist {}
}
} }
\ExpEnvOption% \ExpEnvOption%
\begin{\l_BigFloat_type_str}[\l_BigFloat_placement_str]% float environment \begin{\l_BigFloat_type_str}[\l_BigFloat_placement_str]% float environment
@@ -120,17 +123,18 @@
\end{figure}% \end{figure}%
} }
\keys_define:nn{BigFig}{ \keys_define:nn{}{
overhang .dim_set:N = \l_BigFig_overhang_dim, BigFig .inherit:n = BigFloat,
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}{
% 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}{ \NewDocumentCommand{\BigFig}{
% Key=value options. % Key=value options.
@@ -145,9 +149,9 @@
\keys_set:nn{BigFig}{#1} \keys_set:nn{BigFig}{#1}
\begin{BigFloat}[ \begin{BigFloat}[
type = figure, type = figure,
overhang = \l_BigFig_overhang_dim, overhang = \l_BigFloat_overhang_dim,
placement:e = \l_BigFig_placement_clist, placement:e = {\clist_use:Nn \l_BigFloat_placement_clist {}},
offset = \l_BigFig_offset_fp, offset = \l_BigFloat_offset_fp,
]% ]%
\captionsetup{type=figure}% \captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\linewidth]{#2}% \includegraphics[keepaspectratio,width=\linewidth]{#2}%

View File

@@ -31,7 +31,9 @@
}{% }{%
\keys_set:nn{InlineGraphic}{#1} \keys_set:nn{InlineGraphic}{#1}
\raisebox{\l_InlineGraphic_offset_dim}{ \raisebox{\l_InlineGraphic_offset_dim}{
\includegraphics[keepaspectratio,height=\l_InlineGraphic_height_dim]{#2} \includegraphics[%
keepaspectratio,height=12pt%\l_InlineGraphic_height_dim%
]{#2}
}% }%
} }

View File

@@ -5,15 +5,15 @@
\RequirePackage{PrimeTeX/packages/Layout} \RequirePackage{PrimeTeX/packages/Layout}
\dim_new:N \g_header_insideoffset_dim % \dim_new:N \g_header_insideoffset_dim
\dim_set:Nn \g_header_insideoffset_dim {\c_BigFloat_overhang_dim} % \dim_set:Nn \g_header_insideoffset_dim {\c_BigFloat_overhang_dim}
\dim_new:N \g_header_outsideoffset_dim % \dim_new:N \g_header_outsideoffset_dim
\dim_set:Nn \g_header_outsideoffset_dim { % \dim_set:Nn \g_header_outsideoffset_dim {
\fp_to_dim:n {\c_BigFloat_overhang_dim * \c_BigFloat_offset_fp} % \fp_to_dim:n {\c_BigFloat_overhang_dim * \c_BigFloat_offset_fp}
} % }
\ProvideLength{\HeaderInsideOffset}[\BigFloatOverhang] \ProvideLength{\HeaderInsideOffset}[0.54in]%[\BigFloatOverhang]
\ProvideLength{\HeaderOutsideOffset}[\BigFloatOverhang * \real{\BigFloatOffset}] \ProvideLength{\HeaderOutsideOffset}[1.08in]%[\BigFloatOverhang * \real{\BigFloatOffset}]
% Header & Footer Options % Header & Footer Options
\RequirePackage{fancyhdr} \RequirePackage{fancyhdr}

View File

@@ -1,5 +1,5 @@
\NeedsTeXFormat{LaTeX2e} \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. % Suppress warning about \showhyphens being changed.
\let\CheckCommand\providecommand \let\CheckCommand\providecommand
@@ -28,8 +28,6 @@
footskip = 0.5in, % 36pt, footskip = 0.5in, % 36pt,
]{geometry} ]{geometry}
\RequirePackage{float}
% Redefine the commands geometry uses to draw the page frame to customize the % Redefine the commands geometry uses to draw the page frame to customize the
% color. % color.
\renewcommand{\Gm@vrule}{\color{layout}\vrule width 0.2pt height\textheight depth\z@} \renewcommand{\Gm@vrule}{\color{layout}\vrule width 0.2pt height\textheight depth\z@}
@@ -39,6 +37,8 @@
% Suppress "Underfull \hbox" infos. % Suppress "Underfull \hbox" infos.
\hbadness=10000 \hbadness=10000
\RequirePackage{ifthen}
\ifthenelse{\boolean{isDraft}}{ \ifthenelse{\boolean{isDraft}}{
\geometry{showframe} \geometry{showframe}
\hfuzz = 0.5pt \hfuzz = 0.5pt
@@ -139,7 +139,7 @@
} }
\restoregeometry \restoregeometry
\ExplSyntaxOn %\ExplSyntaxOn
\NewDocumentEnvironment{SmallMargin}{O{0.0in} O{-0.25in}}{ \NewDocumentEnvironment{SmallMargin}{O{0.0in} O{-0.25in}}{
\clearpage \clearpage
\loadgeometry{smallMargin} \loadgeometry{smallMargin}