63 lines
1.3 KiB
TeX
63 lines
1.3 KiB
TeX
\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:
|
|
}
|
|
} |