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

@@ -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}%