#How to make boxed math equation align according to its content ?

4 messages · Page 1 of 1 (latest)

zenith sand
#

I would like to add box to every mathematical equations (like blackboard) including the inline and display ones ; here is what I have done :

#show math.equation: set text(
  size: .75em, 
  fill: white
)
#show math.equation: box.with(
  baseline: 0%,
  fill: rgb("#000000"),
  inset: (x: .3em, y: 0em),
  outset: (y: .5em),
  stroke: gray + .4pt,
  radius: .5em,
)

and the result is in the attachment screenshot : notice that the baseline of math equation is not accord to the baseline of the sentence ( red box ) .

I tried smash the math equation box like

#show math.equation: it => box(
  height: 0pt, 
  box(
    baseline: 0%,
    fill: rgb("#000000"),
    inset: (x: .3em, y: 0em),
    outset: (y: .5em),
    stroke: gray + .4pt,
    radius: .5em,
    it
  )
)

but it won't work . Do you guys have any suggestions ?

ornate stratus
#

I believe you need to style them separately.

#show math.equation.where(block: true): block.with()
#show math.equation.where(block: false): box.with()

If you can draw the end result, that would also help.

zenith sand
#

Is it possible to set the baseline of the box as the baseline of the normal text like [fghFGH] ? I do not know how to get this information . This is what I have tried :

#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: it => box(
  // height: measure([fgFGH ( ) ]).height,
  // height: measure([Hellofg]).height,
  stroke: black+.4pt,
  align(//horizon,
  box(
  baseline : box.baseline + 1em,
  fill: silver.transparentize(90%),
  inset: (x: .3em, y: 0em),
  outset: (y: 1em),
  stroke: gray + .4pt,
  radius: .5em,
  it
)))
zenith sand
#

There is an interesting discovery :

If I add #set par(leading: 2em) at the top of the code with the following settings

#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: it => box(
  baseline : 0pt,
  fill: silver.transparentize(90%),
  // fill: black,
  inset: (x: .3em, y: 0em),
  outset: (y: 1em),
  stroke: gray + .4pt,
  radius: .5em,
  it
)

then the result will look much better