Lots of stuff.

This commit is contained in:
2025-09-24 17:02:24 -05:00
parent d781100822
commit f8bae5a800
11 changed files with 206 additions and 53 deletions

View File

@@ -51,13 +51,15 @@
% Allow hyphenation in narrow margin paragraphs. % Allow hyphenation in narrow margin paragraphs.
\RequirePackage{ragged2e} \RequirePackage{ragged2e}
% Table formatting.
\RequirePackage{tabularray}
\RequirePackage[raggedright]{titlesec} \RequirePackage[raggedright]{titlesec}
\RequirePackage{readarray} \RequirePackage{readarray}
% Table formatting.
\RequirePackage{tabularray}
\RequirePackage{tikz}
\RequirePackage{wrapstuff} \RequirePackage{wrapstuff}
% Color import and definition % Color import and definition
@@ -90,6 +92,8 @@
\RequirePackage{PrimeTeX/packages/Index} \RequirePackage{PrimeTeX/packages/Index}
\RequirePackage{PrimeTeX/packages/LadderLogic}
\RequirePackage{PrimeTeX/packages/Links} \RequirePackage{PrimeTeX/packages/Links}
\RequirePackage{PrimeTeX/packages/Marginalia} \RequirePackage{PrimeTeX/packages/Marginalia}

Binary file not shown.

View File

@@ -24,19 +24,29 @@
\tl_new:N \l_Boxout_title_tl \tl_new:N \l_Boxout_title_tl
\cs_new:Nn \__Boxout_default_format: {
\justifying
\setlength{\parindent}{0pt}
\setlength{\parskip}{\medskipamount}
}
\keys_define:nn {Boxout} { \keys_define:nn {Boxout} {
innerspec .tl_set_e:N= \l_Boxout_innerspec_tl, innerspec .tl_set_e:N= \l_Boxout_innerspec_tl,
innerspec .initial:e = {\c_Boxout_innerspec_tl}, innerspec .initial:e = {\c_Boxout_innerspec_tl},
warning .bool_set:N = \l_Boxout_warning_bool, danger .code:n = {\int_set:Nn \l_Boxout_severity_int {4}},
warning .initial:e = {false},
warning .code:n = {\int_set:Nn \l_Boxout_severity_int {3}},
info .code:n = {\int_set:Nn \l_Boxout_severity_int {2}},
tip .code:n = {\int_set:Nn \l_Boxout_severity_int {1}},
severity .int_set:N = {\l_Boxout_severity_int},
severity .initial:n = {0},
format .cs_set:Np = \__Boxout_format:, format .cs_set:Np = \__Boxout_format:,
format .initial:n = { format .initial:n = {},
\justifying
\setlength{\parindent}{0pt}
\setlength{\parskip}{\medskipamount}
},
} }
\NewDocumentEnvironment{Boxout}{ \NewDocumentEnvironment{Boxout}{
@@ -50,10 +60,24 @@
+b +b
}{ \group_begin: }{ \group_begin:
\keys_set:nn{Boxout}{#1} \keys_set:nn{Boxout}{#1}
\bool_if:nT \l_Boxout_warning_bool { \int_case:nn \l_Boxout_severity_int {
{1} {
\colorlet{boxoutBGColor}{tipBGColor}
\colorlet{boxoutFGColor}{tipFGColor}
}
{2} {
\colorlet{boxoutBGColor}{infoBGColor}
\colorlet{boxoutFGColor}{infoFGColor}
}
{3} {
\colorlet{boxoutBGColor}{warningBGColor} \colorlet{boxoutBGColor}{warningBGColor}
\colorlet{boxoutFGColor}{warningFGColor} \colorlet{boxoutFGColor}{warningFGColor}
} }
{4} {
\colorlet{boxoutBGColor}{dangerBGColor}
\colorlet{boxoutFGColor}{dangerFGColor}
}
}
\color{textColor} \color{textColor}
\label{box:#2} \label{box:#2}
\tl_if_empty:nTF {#3} { \tl_if_empty:nTF {#3} {
@@ -65,7 +89,7 @@
% Yes header % Yes header
\expanded{\noexpand\begin{tblrBoxout}{\l_Boxout_innerspec_tl}} \expanded{\noexpand\begin{tblrBoxout}{\l_Boxout_innerspec_tl}}
\SetCell{halign=c, font={\sbfamily\bfseries}}{#3}\\ \SetCell{halign=c, font={\sbfamily\bfseries}}{#3}\\
\__Boxout_format:\ignorespaces#4\\ \__Boxout_default_format:\__Boxout_format:\ignorespaces#4\\
\end{tblrBoxout} \end{tblrBoxout}
} }
\group_end: }{} \group_end: }{}
@@ -88,12 +112,12 @@
\begin{BigFloat}[ \begin{BigFloat}[
type = generic, type = generic,
overhang = \l_BigFloat_overhang_dim, overhang = \l_BigFloat_overhang_dim,
placement:e = \l_Float_placement_clist, placement:V = \l_Float_placement_clist,
offset = \l_BigFloat_offset_fp, offset = \l_BigFloat_offset_fp,
] ]
\begin{Boxout}[ \begin{Boxout}[
innerspec:e = \l_Boxout_innerspec_tl, innerspec:V = \l_Boxout_innerspec_tl,
warning:e = \bool_to_str:N \l_Boxout_warning_bool, severity:V = \l_Boxout_severity_int,
]{#2}[#3] ]{#2}[#3]
#4 #4
\end{Boxout} \end{Boxout}
@@ -117,28 +141,29 @@
width .initial:e = {\c_MarginBoxout_width_dim}, width .initial:e = {\c_MarginBoxout_width_dim},
} }
\NewDocumentEnvironment{MarginBoxout}{ \NewDocumentCommand{\MarginBoxout}{
% #1: Key-value options. % #1: Key-value options.
O{} O{}
% #2: Label. % #2: Label.
>{\TrimSpaces}m >{\TrimSpaces}m
% #3: Caption % #3: Caption
O{} O{}
% #4: Body. % #4: Content.
+b +m
}{ \group_begin: }{ \group_begin:
\keys_set:nn {MarginBoxout} {#1} \keys_set:nn {MarginBoxout} {#1}
\marginalia[ \marginalia[
width = \l_MarginBoxout_width_dim, width = \l_MarginBoxout_width_dim,
]{ ]{
\begin{Boxout}[ \begin{Boxout}[
innerspec:e = \l_Boxout_innerspec_tl, innerspec:V = \l_Boxout_innerspec_tl,
warning:e = \bool_to_str:N \l_Boxout_warning_bool, severity:V = \l_Boxout_severity_int,
format = {\RaggedOutside},
]{#2}[#3] ]{#2}[#3]
#4 #4
\end{Boxout} \end{Boxout}
} }
\group_end: }{} \group_end: }
\dim_const:Nn \c_WrapBoxout_width_dim {3in} \dim_const:Nn \c_WrapBoxout_width_dim {3in}
\dim_const:Nn \c_WrapBoxout_justifywidth_dim {18em} \dim_const:Nn \c_WrapBoxout_justifywidth_dim {18em}
@@ -190,7 +215,7 @@
\l_Boxout_innerspec_tl, \l_Boxout_innerspec_tl,
columns={\dim_use:N \l_WrapBoxout_width_dim} columns={\dim_use:N \l_WrapBoxout_width_dim}
}, },
warning:e = {\bool_to_str:N \l_Boxout_warning_bool}, severity:V = \l_Boxout_severity_int,
format = \__WrapBoxout_format:, format = \__WrapBoxout_format:,
]{#2}[#3] ]{#2}[#3]
#4 #4

View File

@@ -51,7 +51,7 @@
% #2: Label % #2: Label
>{\TrimSpaces}m >{\TrimSpaces}m
% #3: Caption % #3: Caption
m >{\TrimSpaces}m
% #4: Body % #4: Body
+b +b
}{ }{

View File

@@ -141,9 +141,18 @@
\colorlet{boxoutFGColor}{PrimeLightBlue} \colorlet{boxoutFGColor}{PrimeLightBlue}
% Warning Box colors. % Warning Box colors.
\colorlet{dangerBGColor}{PrimeDarkRed}
\colorlet{dangerFGColor}{PrimeRed}
\colorlet{warningBGColor}{PrimeDarkOrange} \colorlet{warningBGColor}{PrimeDarkOrange}
\colorlet{warningFGColor}{PrimeOrange} \colorlet{warningFGColor}{PrimeOrange}
\colorlet{infoBGColor}{PrimeDarkYellow}
\colorlet{infoFGColor}{PrimeYellow}
\colorlet{tipBGColor}{PrimeDarkMint}
\colorlet{tipFGColor}{PrimeMint}
% Layout preview frame color. % Layout preview frame color.
\colorlet{layoutColor}{PrimeGray} \colorlet{layoutColor}{PrimeGray}
} { } {
@@ -165,9 +174,18 @@
\colorlet{boxoutFGColor}{PrimeBlue} \colorlet{boxoutFGColor}{PrimeBlue}
% Warning Box colors. % Warning Box colors.
\colorlet{dangerBGColor}{PrimePastelRed}
\colorlet{dangerFGColor}{PrimeBrightRed}
\colorlet{warningBGColor}{PrimePastelOrange} \colorlet{warningBGColor}{PrimePastelOrange}
\colorlet{warningFGColor}{PrimeBrightOrange} \colorlet{warningFGColor}{PrimeBrightOrange}
\colorlet{infoBGColor}{PrimePastelYellow}
\colorlet{infoFGColor}{PrimeBrightYellow}
\colorlet{tipBGColor}{PrimePastelMint}
\colorlet{tipFGColor}{PrimeBrightMint}
% Layout preview frame color. % Layout preview frame color.
\colorlet{layoutColor}{PrimePaleBlue} \colorlet{layoutColor}{PrimePaleBlue}
} }

View File

@@ -3,6 +3,11 @@
Font definitions. Font definitions.
} }
% Loading math fonts takes a long time, so skip it in draft mode.
\bool_if:NF \g_draft_bool {
\usepackage{notomath}
}
\NewDocumentCommand{\fontpath}{}{PrimeTeX/fonts} \NewDocumentCommand{\fontpath}{}{PrimeTeX/fonts}
% Main font: Roboto Serif (Light). % Main font: Roboto Serif (Light).
@@ -29,9 +34,9 @@
\setmonofont{RobotoMono}[ \setmonofont{RobotoMono}[
Path = {\fontpath/RobotoMono/}, Path = {\fontpath/RobotoMono/},
Extension = .ttf, Extension = .ttf,
UprightFont = *-Regular, UprightFont = *-Medium,
BoldFont = *-Bold, BoldFont = *-Bold,
ItalicFont = *-Italic, ItalicFont = *-MediumItalic,
BoldItalicFont = *-BoldItalic, BoldItalicFont = *-BoldItalic,
] ]
@@ -56,6 +61,11 @@
ItalicFont = NotoEmoji/NotoEmoji-Light, ItalicFont = NotoEmoji/NotoEmoji-Light,
] ]
% Box drawing font: Noto Sans Symbols 2
\newfontfamily{\bxfamily}{\fontpath/NotoSansSymbols2-regular.ttf}
\setmathrm{RobotoSerif}
\NewDocumentCommand{\serif}{m}{\textrm{#1}} \NewDocumentCommand{\serif}{m}{\textrm{#1}}
\NewDocumentCommand{\sans}{m}{\textsf{#1}} \NewDocumentCommand{\sans}{m}{\textsf{#1}}
\NewDocumentCommand{\mono}{m}{\texttt{#1}} \NewDocumentCommand{\mono}{m}{\texttt{#1}}
@@ -72,11 +82,20 @@
\newmenucolortheme{autoModeColor}{named}{pageColor}{textColor}{textColor}[pageColor][textColor][textColor] \newmenucolortheme{autoModeColor}{named}{pageColor}{textColor}{textColor}[pageColor][textColor][textColor]
\changemenucolortheme{hyphenatepaths}{autoModeColor} \changemenucolortheme{hyphenatepaths}{autoModeColor}
\changemenucolortheme{shadowedangularkeys}{autoModeColor} \changemenucolortheme{shadowedroundedkeys}{autoModeColor}
\changemenucolortheme{angularmenus}{autoModeColor} \changemenucolortheme{angularmenus}{autoModeColor}
\cs_new:Nn \__MenuKeys_path_style: {
\sffamily\color{\usemenucolor{txt}}\CurrentMenuElement
}
\changemenuelement*{hyphenatepaths}{first}{\__MenuKeys_path_style:}
\changemenuelement*{hyphenatepaths}{middle}{\__MenuKeys_path_style:}
\changemenuelement*{hyphenatepaths}{last}{\__MenuKeys_path_style:}
\changemenuelement*{hyphenatepaths}{single}{\__MenuKeys_path_style:}
\renewmenumacro{\directory}[/]{hyphenatepaths} \renewmenumacro{\directory}[/]{hyphenatepaths}
\renewmenumacro{\keys}[+]{shadowedangularkeys} \renewmenumacro{\keys}[+]{shadowedroundedkeys}
\renewmenumacro{\menu}[>]{angularmenus} \renewmenumacro{\menu}[>]{angularmenus}
\RenewDocumentCommand{\ctrlname}{}{$\wedge$} \RenewDocumentCommand{\ctrlname}{}{$\wedge$}
@@ -86,3 +105,6 @@
\NewDocumentCommand{\ShiftString}{}{Shift\,\shift} \NewDocumentCommand{\ShiftString}{}{Shift\,\shift}
\NewDocumentCommand{\AltString}{}{Alt\,\altmac} \NewDocumentCommand{\AltString}{}{Alt\,\altmac}
\NewDocumentCommand{\TabString}{}{Tab\,\tab} \NewDocumentCommand{\TabString}{}{Tab\,\tab}
% Suppress warning about obsolete font encodings because we're using Unicode.
\@tw@hyphenatepaths@warnigfalse

View File

@@ -5,14 +5,16 @@
\dim_const:Nn \c_Graphics_icon_dim {0.25in} \dim_const:Nn \c_Graphics_icon_dim {0.25in}
\dim_const:Nn \c_InlineGraphic_offset_dim {-2pt}
\NewDocumentCommand{\IconSize}{}{\c_Graphics_icon_dim} \NewDocumentCommand{\IconSize}{}{\c_Graphics_icon_dim}
\keys_define:nn{InlineGraphic}{ \keys_define:nn{InlineGraphic}{
height .dim_set:N = \l_InlineGraphic_height_dim, height .dim_set:N = \l_InlineGraphic_height_dim,
height .initial:n = {12pt}, height .initial:e = {\baselineskip},
offset .dim_set:N = \l_InlineGraphic_offset_dim, offset .dim_set:N = \l_InlineGraphic_offset_dim,
offset .initial:n = {-2pt}, offset .initial:e = {\c_InlineGraphic_offset_dim},
} }
\NewDocumentCommand{\InlineGraphic}{ \NewDocumentCommand{\InlineGraphic}{
@@ -23,9 +25,10 @@
}{ }{
\keys_set:nn{InlineGraphic}{#1} \keys_set:nn{InlineGraphic}{#1}
\raisebox{\l_InlineGraphic_offset_dim}{ \raisebox{\l_InlineGraphic_offset_dim}{
\includegraphics[ \expanded{\noexpand\includegraphics[
keepaspectratio,height=12pt keepaspectratio,
]{#2} height=\l_InlineGraphic_height_dim,
] {#2}}
} }
} }

63
packages/LadderLogic.sty Normal file
View File

@@ -0,0 +1,63 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesExplPackage{PrimeTeX/packages/LadderLogic}{2025-09-24}{1.0}{
Macros for tikz-ladder Ladder Logic diagrams.
}
\fp_const:Nn \c_LadderLogic_inline_scale_fp {0.6}
\cs_new:Nn \__LadderLogic_inline_format: {
\scriptsize\sffamily
}
\cs_new:Nn \__LadderLogic_default_format: {
\sffamily
}
\NewDocumentCommand{\LadderFormat}{O{} O{}}{
\str_case:nnF {#1} {
{default} {
\str_if_empty:nTF {#2} {
\__LadderLogic_default_format:
} {
\cs_set:Nn \__LadderLogic_default_format: {#2}
}
}
{inline} {
\str_if_empty:nTF {#2} {
\__LadderLogic_inline_format:
} {
\cs_set:Nn \__LadderLogic_inline_format: {#2}
}
}
} { % case else
\__LadderLogic_default_format:
}
}
% It seems TikZ declarations have to be in the document environment?
\AtBeginDocument{
\usetikzlibrary{circuits.plc.ladder}
\NewDocumentCommand{\LadderInlineElement}{
O{\c_LadderLogic_inline_scale_fp}
m
}{
\group_begin:
\LadderInlineRung[#1]{
\draw(0,0)
to [#2] ++(1,0);
}
\group_end:
}
\NewDocumentCommand{\LadderInlineRung}{
O{\c_LadderLogic_inline_scale_fp}
m
}{
\group_begin:
\__LadderLogic_inline_format:
\tikzset{circuit~symbol~unit=\fp_to_dim:n {#1 * \baselineskip}}
\raisebox{\c_InlineGraphic_offset_dim}{\tikz[circuit~plc~ladder,thick]{#2}}
\group_end:
}
}

View File

@@ -61,26 +61,40 @@
}% }%
} }
\NewDocumentCommand{\MarginFig}{ % Wrapper for \marginalia with some improvements.
% #1: Graphic file name. \NewDocumentCommand{\Marginalia}{
m % #1: Options passed to \marginalia.
% #2: Options passed to \includegraphics.
O{} O{}
% #3: Label. % #2: Contents.
>{\TrimSpaces}m
% #4: Caption.
+m +m
}{ }{
% This mbox ensures that the margin figure is counted as part of the % This mbox ensures that the margin paragraph is counted as part of the
% following paragraph and is vertically aligned with it. % following paragraph and is vertically aligned with it.
\mbox{ \mbox{
\marginalia{ \marginalia[#1]{
\MarginHyperSetup \MarginHyperSetup
#2
}
}
}
\NewDocumentCommand{\MarginFig}{
% #1: Options passed to \marginalia via \Marginalia.
O{}
% #2: Graphic file name.
m
% #3: Options passed to \includegraphics.
O{}
% #4: Label.
>{\TrimSpaces}m
% #5: Caption.
>{\TrimSpaces}+m
}{
\Marginalia{
\begin{MyCaption}[ \begin{MyCaption}[
format={\RaggedOutside\small\color{captionColor}} format={\RaggedOutside\small\color{captionColor}}
]{fig:#3}{#4} ]{fig:#4}{#5}
\Centering\includegraphics[keepaspectratio,#2]{#1} \Centering\includegraphics[keepaspectratio,#3]{#2}
\end{MyCaption} \end{MyCaption}
} }
} }
}

View File

@@ -30,10 +30,14 @@
hline{2} = {0.4pt}, hline{2} = {0.4pt},
} }
\NewTblrTableCommand{\midtitle}[1][pageColor]{ \NewTblrTableCommand{\midtitle}[2][pageColor]{
\SetCell[c=2]{ \SetCell[c=#2]{
c, c, m,
bg = #1, bg = #1,
font = \bfseries, font = \bfseries,
} }
} }
\newcommand{\VerticalTitle}[3][pageColor]{
\SetCell[r=#2]{c,bg=#1}{#3}%\rotatebox[origin=c]{90}{\strong{}}}
}