Files
PrimeTeX/packages/Layout.sty
2025-08-26 17:00:31 -05:00

132 lines
3.4 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Layout}[2025-07-09]
% Suppress warning about \showhyphens being changed.
\let\CheckCommand\providecommand
% Suppress "Underfull \hbox" infos.
\hbadness=10000
% Suppress small overfull infos.
\hfuzz = 6.0pt
\vfuzz = 0.0pt
\NewDocumentCommand{\providelength}{m O{0pt}}{%
\ifdeflength{#2}{% It is already defined!
}{% Not defined, so define it!
\newlength{#1}%
}%
\setlength{#1}{#2}%
}
\RequirePackage{microtype}
% Page Layout
\RequirePackage[
letterpaper,
width = 4.75in, % 342pt,
height = 8.0in, % 576pt,
left = 1.5in, % 108pt,
top = 1.5in, % 108pt,
head = 12pt,
headsep = 24pt,
marginparwidth = 1.75in, % 126pt,
marginparsep = 12pt,
footskip = 0.5in, % 36pt,
]{geometry}
\ifthenelse{\boolean{isDraft}}{
% \geometry{showcrop}
\geometry{showframe}
}{}
\ifthenelse{\boolean{isElectronic}}{
% \geometry{}
}{
\geometry{twoside}
}
\RequirePackage{calc}
\RequirePackage[strict]{changepage}
\providelength{\marparwidth}[\marginparsep + \marginparwidth]
\providelength{\contentwidth}[\textwidth + \marparwidth]
\RequirePackage[balanced]{lua-widow-control}
\ifthenelse{\boolean{isDraft}}{
\lwcsetup{draft=false,showcolours=true}
}{}
% Paragraph formatting.
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex plus 0.5ex minus 0.5ex}
% Float Page Configuration
\renewcommand{\topfraction}{0.9} % max fraction of floats at top
\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
% Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4} % 2 may work better
\setcounter{dbltopnumber}{2} % for 2-column pages
\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07} % allow minimal text w. figs
% Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.8} % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.8} % require fuller float pages
% Line-breaking zero-width space
\NewDocumentCommand{\zws}{}{\hspace{0pt}}
% Line-breaking dot
\NewDocumentCommand{\bdot}{}{.\zws}
\newlength{\bigfloatoffset}
\setlength{\bigfloatoffset}{0.25in}
% Maximum width adjustment to fit 2 16x9 screensots on one page.
\newlength{\bigfloatoverhang}
\setlength{\bigfloatoverhang}{0.81in}
\providecommand{\adjwidthtype}{}
\makeatletter
\NewDocumentCommand{\BigFloat}{
% Overhang: the distance that the BigFloat extends into the margins.
O{\bigfloatoverhang}
% Float position: where the float may appear on the page.
O{htpb}
% Offset: the distance to offset the center of the BigFloat from the center
% of the text block.
O{\bigfloatoffset}
% Float type: figure or table.t
m
% Content: what appears in the BigFloat.
+m
}{%
\ifthenelse{\boolean{isElectronic}}{%
\@bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth}%
}{%
\@bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth*}%
}%
}
\NewDocumentCommand{\@bfloat}{
% First 5 arguments are same as \BigFloat.
m m m m +m
% Argument 6 is the adjustwidth type [adjustwidth for one-sided document,
% adjustwidth* for two-sided].
m
}{
\begin{#4}[#2]% figure/table
\begin{#6}{-#1+#3}{-#1-#3}% adjustwidth(*)
\begin{minipage}{#1 * 2 + \textwidth}%
\ifthenelse{\boolean{isDraft}}{%
\rule{\textwidth}{1pt}\zws%
}{}%
#5%
\end{minipage}%
\end{#6}%
\end{#4}%
}
\makeatother