Files
PrimeTeX/packages/Layout.sty
Joshua Lucas 89340afd62 - Refine boxedcolor macro.
- Tentatively replace nowidow package with lua-widow-control.
2025-08-18 16:13:23 -05:00

153 lines
3.9 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Layout}[2025-07-09]
% Suppress warning about \showhyphens being changed.
\let\CheckCommand\providecommand
\providecommand{\providelength}[2][0pt]{%
\ifdeflength{#2}{% It is already defined!
}{% Not defined, so define it!
\newlength{#2}%
}%
\setlength{#2}{#1}%
}
\RequirePackage{microtype}
\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}
% Page Layout
\ifthenelse{\boolean{isElectronic}}{
% \geometry{}
}{
\geometry{twoside}
}
\RequirePackage{calc}
\RequirePackage[strict]{changepage}
\newlength{\contentwidth}
\setlength{\contentwidth}{\textwidth + \marginparsep + \marginparwidth}
% Widow & Orphan control.
% \RequirePackage[
% defaultlines = 4,
% all,
% ]{nowidow}
\RequirePackage{lua-widow-control}
\ifthenelse{\boolean{isDraft}}{
\lwcdraft{draft}
}{}
% 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
\newcommand{\zws}{\hspace{0pt}}
% Line-breaking dot
\newcommand{\bdot}{.\hspace{0pt}}
\newlength{\bigfloatoffset}
\setlength{\bigfloatoffset}{0.25in}
% Maximum width adjustment to fit 2 16x9 screensots on one page.
\newlength{\bigfloatoverhang}
\setlength{\bigfloatoverhang}{0.81in}
\newcommand{\bigfloat}[4][\bigfloatoverhang]{%
\begin{#2}[#3]%
\ifthenelse{\boolean{isElectronic}}{
\begin{adjustwidth}{-#1+\bigfloatoffset}{-#1-\bigfloatoffset}%
\begin{minipage}{#1 * 2 + \textwidth}%
#4%
\end{minipage}%
\end{adjustwidth}%
}{
\begin{adjustwidth*}{-#1+\bigfloatoffset}{-#1-\bigfloatoffset}%
\begin{minipage}{#1 * 2 + \textwidth}%
#4%
\end{minipage}%
\end{adjustwidth*}%
}
\end{#2}%
}
% \newcommand{\bignotfloat}[2][\bigfloatoverhang]{%
% \begin{adjustwidth*}{-#1+\bigfloatoffset}{-#1-\bigfloatoffset}%
% \begin{minipage}{#1 * 2 + \textwidth}%
% #2%
% \end{minipage}%
% \end{adjustwidth*}%
% }
\newlength{\boxoutpadding}
\setlength{\boxoutpadding}{0.5em}
\newcommand{\boxoutbgcolor}{PrimePaleBlue}
\newcommand{\boxoutfgcolor}{PrimeBlue}
\newcommand{\boxout}[5][0in]{%
\begin{wrapfigure}{#2}[#1]%
\fcolorbox{\boxoutfgcolor}{\boxoutbgcolor}{%
\begin{minipage}{#3}%
\vspace{\boxoutpadding}%
{\centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#4}%
\setlength{\parskip}{\medskipamount}%
{\centering\slab{\strong{#4}}\par}%
\small{}#5%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
\end{minipage}%
}%
\end{wrapfigure}%
}
\newcommand{\bigboxout}[4][\bigfloatoverhang]{%
\bigfloat[#1]{figure}{#2}{%
\fcolorbox{\boxoutfgcolor}{\boxoutbgcolor}{%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\vspace{\boxoutpadding}%
{\centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#3}%
\setlength{\parskip}{\medskipamount}%
{\centering\slab{\strong{#3}}\par}%
\small{}#4%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
\end{minipage}%
}%
}%
}