\NeedsTeXFormat{LaTeX2e} \ProvidesPackage{PrimeTeX/packages/Layout}[2025-07-09] % Suppress warning about \showhyphens being changed. \let\CheckCommand\providecommand \NewDocumentCommand{\ProvideLength}{m O{0pt}}{% \ifdeflength{#1}{% 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, % 1/6in headsep = 24pt, % 1/3in marginparwidth = 1.75in, % 126pt, marginparsep = 12pt, % 1/6in 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@} \renewcommand{\Gm@hrule}{\color{layout}\hrule height 0.2pt depth\z@ width\textwidth} \renewcommand{\Gm@hruled}{\color{layout}\hrule height\z@ depth0.2pt width\textwidth} % Suppress "Underfull \hbox" infos. \hbadness=10000 \ifthenelse{\boolean{isDraft}}{ \geometry{showframe} \hfuzz = 0.5pt \vfuzz = 0.0pt }{ % Suppress small overfull infos. \hfuzz = 6.0pt \vfuzz = 8.0pt } \ifthenelse{\boolean{isElectronic}}{ % \geometry{} }{ \geometry{twoside} } \RequirePackage{calc} \RequirePackage[strict]{changepage} \ProvideLength{\marparwidth}[\marginparsep + \marginparwidth] \ProvideLength{\contentwidth}[\textwidth + \marparwidth] \RequirePackage[ debug, balanced, emergencystretch = 3em, max-cost = 25000, widowpenalty = 1000, orphanpenalty = 1000, brokenpenalty = 10000, nobreak = keep, ]{lua-widow-control} \ifthenelse{\boolean{isDraft}}{ \lwcsetup{showcolours=true,} }{} % Paragraph formatting. \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 3pt minus 3pt} % 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} \NewDocumentEnvironment{SmartAdjustWidth}{O{\boolean{isElectronic}} m m +b}{% \ifthenelse{#1}{% \begin{adjustwidth}{#2}{#3}% #4% \end{adjustwidth}% }{% \begin{adjustwidth*}{#2}{#3}% #4% \end{adjustwidth*}% }% }{} \newcommand{\bigfloatoffsetratio}{2.0} % Maximum width adjustment to fit 2 16x9 screensots on one page. \ProvideLength{\bigfloatoverhang}[0.54in] \newcommand{\bigfloatplacement}{htpb} \floatstyle{plain} \newfloat{generic}{htpb}{lgf} \NewDocumentEnvironment{BigFloat}{ % #1: Float type O{generic} % #2: Overhang: the distance that the BigFloat extends into the margins. O{\bigfloatoverhang} % #3: Float position: where the float may appear on the page. O{\bigfloatplacement} % #4: Offset: the ratio between the overhangs on the inside and outside of % BigFloat. O{\bigfloatoffsetratio} % #5: Body: what appears in the BigFloat. +b }{% \begin{#1}[#3]% float environment \begin{SmartAdjustWidth}{-#2}{-#2 * \real{#4}}% adjustwidth(*) \begin{minipage}{\linewidth}%{#2 * (#4 + 1) + \textwidth}% \ifthenelse{\boolean{isDraft}}{% {\color{layout}\rule{\textwidth}{1pt}\zws}% #5% %{\color{layout}\rule{\textwidth}{1pt}}% }{% #5% }% \end{minipage}% \end{SmartAdjustWidth}% \end{#1}% }{} \AtBeginDocument{ \ifthenelse{\boolean{isElectronic}}{ \newgeometry{ inner = 0.75in, top = 66pt, % 11/12in marginratio = 2:3, } \savegeometry{smallMargin} \newgeometry{ inner = 24pt, % 1/3in top = 0.25in, marginratio = 2:3, } \savegeometry{tinyMargin} }{ \newgeometry{ twoside = true, inner = 0.75in, top = 66pt, % 11/12in marginratio = 2:3, } \savegeometry{smallMargin} \newgeometry{ twoside = true, inner = 24pt, % 1/3in top = 0.25in, marginratio = 2:3, } \savegeometry{tinyMargin} } \restoregeometry \NewDocumentEnvironment{SmallMargin}{O{0.0in} O{-0.25in}}{ \clearpage \loadgeometry{smallMargin} \setlength{\insideheaderoffset}{#1} \setlength{\outsideheaderoffset}{#2} \pagestyle{fancy} }{ \clearpage \pagestyle{fancy} \restoregeometry } }