diff --git a/Manual.cls b/Manual.cls index 8fbd743..0848f0f 100644 --- a/Manual.cls +++ b/Manual.cls @@ -104,4 +104,4 @@ \str_if_empty:NF \l_IncludeOnly_chapters_str { \expanded{\noexpand\includeonly{\l_IncludeOnly_chapters_str}} } -} +} \ No newline at end of file diff --git a/commonincludes.def b/commonincludes.def index 6daedae..ba826c0 100644 --- a/commonincludes.def +++ b/commonincludes.def @@ -51,13 +51,15 @@ % Allow hyphenation in narrow margin paragraphs. \RequirePackage{ragged2e} -% Table formatting. -\RequirePackage{tabularray} - \RequirePackage[raggedright]{titlesec} \RequirePackage{readarray} +% Table formatting. +\RequirePackage{tabularray} + +\RequirePackage{tikz} + \RequirePackage{wrapstuff} % Color import and definition @@ -90,6 +92,8 @@ \RequirePackage{PrimeTeX/packages/Index} +\RequirePackage{PrimeTeX/packages/LadderLogic} + \RequirePackage{PrimeTeX/packages/Links} \RequirePackage{PrimeTeX/packages/Marginalia} diff --git a/fonts/NotoSansSymbols2-Regular.ttf b/fonts/NotoSansSymbols2-Regular.ttf new file mode 100644 index 0000000..7816268 Binary files /dev/null and b/fonts/NotoSansSymbols2-Regular.ttf differ diff --git a/packages/Boxout.sty b/packages/Boxout.sty index 0b382b4..de5675c 100644 --- a/packages/Boxout.sty +++ b/packages/Boxout.sty @@ -24,19 +24,29 @@ \tl_new:N \l_Boxout_title_tl +\cs_new:Nn \__Boxout_default_format: { + \justifying + \setlength{\parindent}{0pt} + \setlength{\parskip}{\medskipamount} +} + \keys_define:nn {Boxout} { innerspec .tl_set_e:N= \l_Boxout_innerspec_tl, innerspec .initial:e = {\c_Boxout_innerspec_tl}, - warning .bool_set:N = \l_Boxout_warning_bool, - warning .initial:e = {false}, + danger .code:n = {\int_set:Nn \l_Boxout_severity_int {4}}, + + 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 .initial:n = { - \justifying - \setlength{\parindent}{0pt} - \setlength{\parskip}{\medskipamount} - }, + format .initial:n = {}, } \NewDocumentEnvironment{Boxout}{ @@ -50,9 +60,23 @@ +b }{ \group_begin: \keys_set:nn{Boxout}{#1} - \bool_if:nT \l_Boxout_warning_bool { - \colorlet{boxoutBGColor}{warningBGColor} - \colorlet{boxoutFGColor}{warningFGColor} + \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{boxoutFGColor}{warningFGColor} + } + {4} { + \colorlet{boxoutBGColor}{dangerBGColor} + \colorlet{boxoutFGColor}{dangerFGColor} + } } \color{textColor} \label{box:#2} @@ -65,7 +89,7 @@ % Yes header \expanded{\noexpand\begin{tblrBoxout}{\l_Boxout_innerspec_tl}} \SetCell{halign=c, font={\sbfamily\bfseries}}{#3}\\ - \__Boxout_format:\ignorespaces#4\\ + \__Boxout_default_format:\__Boxout_format:\ignorespaces#4\\ \end{tblrBoxout} } \group_end: }{} @@ -88,12 +112,12 @@ \begin{BigFloat}[ type = generic, overhang = \l_BigFloat_overhang_dim, - placement:e = \l_Float_placement_clist, + placement:V = \l_Float_placement_clist, offset = \l_BigFloat_offset_fp, ] \begin{Boxout}[ - innerspec:e = \l_Boxout_innerspec_tl, - warning:e = \bool_to_str:N \l_Boxout_warning_bool, + innerspec:V = \l_Boxout_innerspec_tl, + severity:V = \l_Boxout_severity_int, ]{#2}[#3] #4 \end{Boxout} @@ -117,28 +141,29 @@ width .initial:e = {\c_MarginBoxout_width_dim}, } -\NewDocumentEnvironment{MarginBoxout}{ +\NewDocumentCommand{\MarginBoxout}{ % #1: Key-value options. O{} % #2: Label. >{\TrimSpaces}m % #3: Caption O{} - % #4: Body. - +b + % #4: Content. + +m }{ \group_begin: \keys_set:nn {MarginBoxout} {#1} \marginalia[ width = \l_MarginBoxout_width_dim, ]{ \begin{Boxout}[ - innerspec:e = \l_Boxout_innerspec_tl, - warning:e = \bool_to_str:N \l_Boxout_warning_bool, + innerspec:V = \l_Boxout_innerspec_tl, + severity:V = \l_Boxout_severity_int, + format = {\RaggedOutside}, ]{#2}[#3] #4 \end{Boxout} } -\group_end: }{} +\group_end: } \dim_const:Nn \c_WrapBoxout_width_dim {3in} \dim_const:Nn \c_WrapBoxout_justifywidth_dim {18em} @@ -190,7 +215,7 @@ \l_Boxout_innerspec_tl, 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:, ]{#2}[#3] #4 diff --git a/packages/Caption.sty b/packages/Caption.sty index 9e256b7..f419a0f 100644 --- a/packages/Caption.sty +++ b/packages/Caption.sty @@ -51,7 +51,7 @@ % #2: Label >{\TrimSpaces}m % #3: Caption - m + >{\TrimSpaces}m % #4: Body +b }{ diff --git a/packages/Color.sty b/packages/Color.sty index dde501c..07076be 100644 --- a/packages/Color.sty +++ b/packages/Color.sty @@ -141,9 +141,18 @@ \colorlet{boxoutFGColor}{PrimeLightBlue} % Warning Box colors. + \colorlet{dangerBGColor}{PrimeDarkRed} + \colorlet{dangerFGColor}{PrimeRed} + \colorlet{warningBGColor}{PrimeDarkOrange} \colorlet{warningFGColor}{PrimeOrange} + \colorlet{infoBGColor}{PrimeDarkYellow} + \colorlet{infoFGColor}{PrimeYellow} + + \colorlet{tipBGColor}{PrimeDarkMint} + \colorlet{tipFGColor}{PrimeMint} + % Layout preview frame color. \colorlet{layoutColor}{PrimeGray} } { @@ -165,9 +174,18 @@ \colorlet{boxoutFGColor}{PrimeBlue} % Warning Box colors. + \colorlet{dangerBGColor}{PrimePastelRed} + \colorlet{dangerFGColor}{PrimeBrightRed} + \colorlet{warningBGColor}{PrimePastelOrange} \colorlet{warningFGColor}{PrimeBrightOrange} + \colorlet{infoBGColor}{PrimePastelYellow} + \colorlet{infoFGColor}{PrimeBrightYellow} + + \colorlet{tipBGColor}{PrimePastelMint} + \colorlet{tipFGColor}{PrimeBrightMint} + % Layout preview frame color. \colorlet{layoutColor}{PrimePaleBlue} } diff --git a/packages/Fonts.sty b/packages/Fonts.sty index 3ecb764..ac343de 100644 --- a/packages/Fonts.sty +++ b/packages/Fonts.sty @@ -3,6 +3,11 @@ 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} % Main font: Roboto Serif (Light). @@ -29,9 +34,9 @@ \setmonofont{RobotoMono}[ Path = {\fontpath/RobotoMono/}, Extension = .ttf, - UprightFont = *-Regular, + UprightFont = *-Medium, BoldFont = *-Bold, - ItalicFont = *-Italic, + ItalicFont = *-MediumItalic, BoldItalicFont = *-BoldItalic, ] @@ -56,6 +61,11 @@ 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{\sans}{m}{\textsf{#1}} \NewDocumentCommand{\mono}{m}{\texttt{#1}} @@ -72,11 +82,20 @@ \newmenucolortheme{autoModeColor}{named}{pageColor}{textColor}{textColor}[pageColor][textColor][textColor] \changemenucolortheme{hyphenatepaths}{autoModeColor} -\changemenucolortheme{shadowedangularkeys}{autoModeColor} +\changemenucolortheme{shadowedroundedkeys}{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{\keys}[+]{shadowedangularkeys} +\renewmenumacro{\keys}[+]{shadowedroundedkeys} \renewmenumacro{\menu}[>]{angularmenus} \RenewDocumentCommand{\ctrlname}{}{$\wedge$} @@ -85,4 +104,7 @@ \NewDocumentCommand{\EnterString}{}{Enter\,\return} \NewDocumentCommand{\ShiftString}{}{Shift\,\shift} \NewDocumentCommand{\AltString}{}{Alt\,\altmac} -\NewDocumentCommand{\TabString}{}{Tab\,\tab} \ No newline at end of file +\NewDocumentCommand{\TabString}{}{Tab\,\tab} + +% Suppress warning about obsolete font encodings because we're using Unicode. +\@tw@hyphenatepaths@warnigfalse \ No newline at end of file diff --git a/packages/Graphics.sty b/packages/Graphics.sty index d7c2fbf..476d8f9 100644 --- a/packages/Graphics.sty +++ b/packages/Graphics.sty @@ -5,14 +5,16 @@ \dim_const:Nn \c_Graphics_icon_dim {0.25in} +\dim_const:Nn \c_InlineGraphic_offset_dim {-2pt} + \NewDocumentCommand{\IconSize}{}{\c_Graphics_icon_dim} \keys_define:nn{InlineGraphic}{ 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 .initial:n = {-2pt}, + offset .initial:e = {\c_InlineGraphic_offset_dim}, } \NewDocumentCommand{\InlineGraphic}{ @@ -23,9 +25,10 @@ }{ \keys_set:nn{InlineGraphic}{#1} \raisebox{\l_InlineGraphic_offset_dim}{ - \includegraphics[ - keepaspectratio,height=12pt - ]{#2} + \expanded{\noexpand\includegraphics[ + keepaspectratio, + height=\l_InlineGraphic_height_dim, + ] {#2}} } } diff --git a/packages/LadderLogic.sty b/packages/LadderLogic.sty new file mode 100644 index 0000000..e3d66c0 --- /dev/null +++ b/packages/LadderLogic.sty @@ -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: + } +} \ No newline at end of file diff --git a/packages/Marginalia.sty b/packages/Marginalia.sty index 4d9d75d..fc86ad2 100644 --- a/packages/Marginalia.sty +++ b/packages/Marginalia.sty @@ -61,26 +61,40 @@ }% } -\NewDocumentCommand{\MarginFig}{ - % #1: Graphic file name. - m - % #2: Options passed to \includegraphics. +% Wrapper for \marginalia with some improvements. +\NewDocumentCommand{\Marginalia}{ + % #1: Options passed to \marginalia. O{} - % #3: Label. - >{\TrimSpaces}m - % #4: Caption. + % #2: Contents. +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. \mbox{ - \marginalia{ + \marginalia[#1]{ \MarginHyperSetup - \begin{MyCaption}[ - format={\RaggedOutside\small\color{captionColor}} - ]{fig:#3}{#4} - \Centering\includegraphics[keepaspectratio,#2]{#1} - \end{MyCaption} + #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}[ + format={\RaggedOutside\small\color{captionColor}} + ]{fig:#4}{#5} + \Centering\includegraphics[keepaspectratio,#3]{#2} + \end{MyCaption} + } } \ No newline at end of file diff --git a/packages/Tables.sty b/packages/Tables.sty index dcbefd9..9dadebc 100644 --- a/packages/Tables.sty +++ b/packages/Tables.sty @@ -30,10 +30,14 @@ hline{2} = {0.4pt}, } -\NewTblrTableCommand{\midtitle}[1][pageColor]{ - \SetCell[c=2]{ - c, +\NewTblrTableCommand{\midtitle}[2][pageColor]{ + \SetCell[c=#2]{ + c, m, bg = #1, font = \bfseries, } +} + +\newcommand{\VerticalTitle}[3][pageColor]{ + \SetCell[r=#2]{c,bg=#1}{#3}%\rotatebox[origin=c]{90}{\strong{}}} } \ No newline at end of file