Hi,
For my lectures, I need to type many ions with physical states. In math mode, the bounding box doesn’t care for attachments.
Here is a (not so) minimal working example that shows the problem.
#import "@preview/whalogen:0.3.0" : ce as wce
#import "@preview/typsium:0.3.0": ce as tce
#set page(width: 6cm, height: auto, margin : 2mm)
#let f = "lorem lipsum"
*Direct math*
#let cu2p = $"Cu"^(2+)_"(aq)"$
#f #cu2p #f
#f #cu2p #f
#box(cu2p, stroke: red)
*Direct whalogen*
#let cu2p = wce("Cu^2+_(aq)")
#f #cu2p #f
#f #cu2p #f
#box(cu2p, stroke: red)
*Direct typsium*
#let cu2p = tce("Cu^2+_(aq)") // does not work as expected
#cu2p
*Boxing whalogen*
#let bwce(c) = box(wce(c),stroke: red, baseline: 5pt, inset: (bottom: 5pt, top: 3pt, x: 0pt))
#let cu2p = bwce("Cu^2+_(aq)")
#f #cu2p #f
#f #cu2p #f
#box(cu2p, stroke: red)
#let cu = bwce("Cu_(s)")
lorei $(#cu2p \/ #cu)$ lorem li
lorem $#cu2p + 2 #bwce("e-") -> #cu$ lor
lorem $(#bwce("SO4^2-_(aq)") ; #cu2p)$
* Super and sub *
#let cu2p = [Cu#super[2+]#sub[(aq)]]
#f #cu2p #f
#f #cu2p #f
#box(cu2p, stroke: red)
You could see that in direct methods, the bounding box is too small.
When I box the content, it seems better in the simple case (of course, it locally changes line spacing which is not very pleasant, but better than have overlapping). But, in more complex cases (like the couple, the equation and the solution composition) it seems not that good (not the difference of the position of top attachment in SO4^2- and Cu^2+).
The super and sub method is not an option since it renders not correctly.
Does anyone have a clue on how to deal with this ?