diff options
author | Chloe Brown <chloe.brown.00@outlook.com> | 2025-04-23 16:37:39 +0100 |
---|---|---|
committer | Chloe Brown <chloe.brown.00@outlook.com> | 2025-04-23 17:06:26 +0100 |
commit | 4459595f44adb15a1e88e63ee7e97e574fbb3a79 (patch) | |
tree | 6b7bdedbc4b5ab5ada4fe49760276a3fb7c78538 /main.tex | |
parent | c45750588a01f532a38c01d108cde8865e612243 (diff) |
Improve multiline let formatting.
Diffstat (limited to 'main.tex')
-rw-r--r-- | main.tex | 42 |
1 files changed, 34 insertions, 8 deletions
@@ -171,21 +171,47 @@ \newcommand\letkw{\ensuremath{\mathsf{let}}} \newcommand\lettm[3]{\letkw~{#2} \coloneq {#1}~\mathsf{in}~{#3}} \ExplSyntaxOn -\NewDocumentCommand \squid_letpart {m m} - { \letkw & {#1} = \cr - & {#2} \cr - \mathsf{in} & +%% args: +%% 1. Do I need a & on the first line? +%% 2. Binder name +%% 3. Is value multiline? +%% 4. Value +\NewDocumentCommand \squid_letpart {m m m m} + { \IfBooleanTF{#3} + { \letkw \IfBooleanTF{#1}{&}{\nobreakspace} {#2} = \cr + & {#4} \cr + \mathsf{in} + } + { \letkw \IfBooleanTF{#1}{&}{\nobreakspace} {#2} = {#4} \nobreakspace \mathsf{in} + } } -\NewDocumentCommand \squid_contlet {> {\SplitArgument{1}{=}} m} - { \squid_letpart #1 \squid_checklet [\cr] +%% args: +%% 1. Do I need a & on the first line? +%% 2. Binder name +%% 3. Is value multiline? +%% 4. Value +%% ... further processing +\NewDocumentCommand \squid_contlet {m m s m} + { \squid_letpart {#1} {#2} {#3} {#4} + \IfBooleanTF{#3} + { \squid_checklet [\BooleanFalse] } + { \squid_checklet [\BooleanTrue] } } +%% args: +%% 1. If something, do I need a new line? +%% 2. Is the next arg not a binder? +%% ... further processing \NewDocumentCommand \squid_checklet {o s m} { \IfBooleanTF{#2} - { \IfNoValueF{#1}{#1} & {#3} + { \IfNoValueF{#1}{\IfBooleanT{#1}{\cr}} & {#3} \end{array} \wlog{End~let} } - { \IfNoValueF{#1}{#1} \squid_contlet {#3} + { \IfNoValueTF{#1} + { \squid_contlet \BooleanTrue {#3} } + { \IfBooleanTF{#1}{\cr}{&} + \squid_contlet {#1} {#3} + } } } \NewDocumentCommand \dolet {O{t}} |