typst-theorems icon indicating copy to clipboard operation
typst-theorems copied to clipboard

`#qedhere` misaligned in multiline equations

Open lukasjuhrich opened this issue 1 year ago • 2 comments

Repro:

#import "@preview/ctheorems:1.1.2": *
#set page(height: auto, margin: 4em)

#let proof = thmproof("proof", "Proof")
#show: thmrules.with(qed-symbol: $square$)
#proof[
  For each $a_1,…, a_k in A$, we have $
  f (α^* (a_1, …, a_k))
  &= f( (π_(α_1), …, π_(α_n)) (a_1, …, a_k))\
  &=  f( π_(α_1)(a_1, …, a_k), …, π_(α_n)(a_1, …, a_k) )\
  &=  f( a_(α_1), …, a_(α_n)) #qedhere
  $
]

image

Ideally, the #qedhere would be aligned with the last line.

lukasjuhrich avatar Mar 14 '24 15:03 lukasjuhrich

To amend that let me note that this is the only slight bug I encountered; otherwise I am thrilled with the addition of #qedhere in the latest version. It visually cleans up lots of proofs! So thanks on that front.

lukasjuhrich avatar Mar 14 '24 15:03 lukasjuhrich

My qedhere solution was too simplistic: the qed symbol is in a grid column with a vertically centered (horizon) alignment. Here's a temporary fix:

#import "@preview/ctheorems:1.1.2": *
#set page(height: auto, margin: 4em)

#let proof = thmproof("proof", "Proof")
#show: thmrules.with(qed-symbol: $square$)

#let qed-multiline(eq) = grid(
  columns: (1fr, auto, 1fr),
  [], eq, align(right + bottom)[#thm-qed-show]
)

#proof[
  For each $a_1,…, a_k in A$, we have
  #qed-multiline($
    f (α^* (a_1, …, a_k))
    &= f( (π_(α_1), …, π_(α_n)) (a_1, …, a_k))\
    &=  f( π_(α_1)(a_1, …, a_k), …, π_(α_n)(a_1, …, a_k) )\
    &=  f( a_(α_1), …, a_(α_n))
  $)
]

#proof[
  $ (x + 1/x) #qedhere $
]

test

Using a bottom alignment in general wouldn't actually work in cases like the second one (single line but taller than usual). ~I'll have to think of a better solution for v2.0.0!~

Update: I think I have a working solution in the v2.0.0 branch, although it'll take a while to release since it's a fairly big update.

sahasatvik avatar Mar 16 '24 08:03 sahasatvik