Displayed maths in +proof collapse in some cases
gfngfn opened this issue · comments
A bit context: I typeset the code below:
@require: stdjareport
@require: math
document (|
title = {あああああ};
author = {mr_konn};
date = {2022/04/23};
|) '<
+chapter{あああああ}<
+proof{
ううううううう
\eqn(${x \in \bigcup_n A_n \Longleftrightarrow \bigcup_n A_n \in \mathcal{U}});
}
>
>
which resulted in:
On the other hand, if we add extra paragraph after eqn
, the math gets done right, like this:
@require: stdjareport
@require: math
document (|
title = {あああああ};
author = {mr_konn};
date = {2022/04/23};
|) '<
+chapter{あああああ}<
+proof{
ううううううう
\eqn(${x \in \bigcup_n A_n \Longleftrightarrow \bigcup_n A_n \in \mathcal{U}});
ええええ
}
>
>
I did some experiment and noticed some points.
\eqn
usesembed-block-breakable
, followed byomit-skip-after
.+proof
putinline-fil
and some endmark character at the end of commend.
In the case where the \eqn
is the last content of +proof
command, it seems that the omit-skip-after
at the end of \eqn
command absorbs the inline-fil
before the endmark character and it causes line breaking problem.
Here is a simplified reproduction of the original problem and some workarounds.
@require: stdjareport
let-block ctx +add-endmark it =
let ib-box = read-inline ctx {▪} in
line-break true true ctx
(read-inline ctx it ++ inline-fil ++ ib-box)
% guard (null inline-frame)
let guard =
let pads = (0pt,0pt,0pt,0pt) in
let dc _ _ _ _ = [] in
inline-frame-inner pads dc inline-nil
let-inline ctx \guard = guard
let-block ctx +add-endmark-with-guard it =
let ib-box = read-inline ctx {▪} in
line-break true true ctx
(read-inline ctx it ++ guard ++ inline-fil ++ ib-box) % put guard before inline-fil
let-inline ctx \embed-block it =
let ib = read-inline ctx it in
let bb = line-break true true ctx (inline-fil ++ ib ++ inline-fil) in
inline-fil ++ embed-block-breakable ctx bb ++ omit-skip-after
let-inline ctx \embed-block-with-no-omit-skip it =
let ib = read-inline ctx it in
let bb = line-break true true ctx (inline-fil ++ ib ++ inline-fil) in
inline-fil ++ embed-block-breakable ctx bb
in
document (|
title = {\#326: Displayed math in \+proof collapse};
author = {mr_konn};
|) '<
+chapter {Simplified reproduction} <
+section {Case 1 (no sentence after embed-block)} <
+add-endmark {
First sentence.
\embed-block {collapsed}
}
>
+section {Case 2 (extra sentence after embed-block)} <
+add-endmark {
First sentence.
\embed-block {not collapsed}
Second sentence.
}
>
+section {Case 3 (remove omit-skip)} <
+add-endmark {
First sentence.
\embed-block-with-no-omit-skip {manual guard after block}
}
>
+section {Case 4 (manual guard)} <
+add-endmark {
First sentence.
\embed-block {manual guard after block}
\guard;
}
>
+section {Case 5 (modify \+proof command)} <
+add-endmark-with-guard {
First sentence.
\embed-block {guarded command}
}
>
>
>
The first workaround (Case 3) is to remove omit-skip-after
.
Another workaround (Case 4,5) is to add some guard before inline-fil
and the endmark.
It seems that the inline-frame-inner
with no content effectively works as guard for preventing omit-skip-after
to absorb inline-fil
.
I don't know the details about line-breaking implentation and do not know best solution for this problem, but I hope this workaround give some insight.
Good catch! And thank you for making a detailed comparison.
The second workaround looks better in my opinion; the following exemplifies why omit-skip-after
is needed:
@require: stdjareport
let-inline ctx \display-with-skip-omission it =
let ib = read-inline ctx it in
let bb = line-break true true ctx (inline-fil ++ ib ++ inline-fil) in
inline-fil ++ embed-block-breakable ctx bb ++ omit-skip-after
let-inline ctx \display-without-skip-omission it =
let ib = read-inline ctx it in
let bb = line-break true true ctx (inline-fil ++ ib ++ inline-fil) in
inline-fil ++ embed-block-breakable ctx bb
let text =
{
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
}
in
document (|
title = {Need for `omit-skip-after`};
author = {`@gfngfn`};
|) '<
+p{
#text;
\display-with-skip-omission{
Texts in the embedded block
}
#text;
}
+p{
#text;
\display-without-skip-omission{
Texts in the embedded block
}
#text;
}
+p{
Take a careful look at the indentations after the embedded blocks above!
You can nonetheless prevent indentations from being inserted simply by adding `%`:
}
+p{
#text;
\display-without-skip-omission{
Texts in the embedded block
}%
#text;
}
>