Smashoperator Analogue

I am wondering how I can achieve something like smashoperator in LaTeX. For example, is the code

$
  g(t) dot limits(integral)_(a+b+c+d)^(x+y+z) f(t) dif t
$

produces the following
image

As you can see, g(t) and f(t) are affected by the limits. Is it possible to make them unaffected by the limits?

One somewhat hacky way of fixing this is to use negative values with #h():

$
  g(t) dot #h(-0.5cm) limits(integral)_(a+b+c+d)^(x+y+z) #h(-0.4cm) f(t) dif t
$

There might be a cleaner solution though.

Hi @mich_ephr, thanks for your question!. Could you maybe try to revise your post’s title to be a complete question as per the question guidelines:

Good titles are questions you would ask your friend about Typst.

We hope by adhering to this, we make the information in this forum easy to find in the future. In addition, the latex-migration tag would be a good fit for your question. Thanks!

If your use case for a smash function is limited to subscripts and superscripts in math, you can define a function like this

#let smash(body, side: center) = math.display(
  box(width: 0pt, align(
    side.inv(),
    box(width: float.inf * 1pt, $ script(body) $))
  )
)

To add some notes about why I did it exactly like this:

  • The zero-width box is the main component responsible for the smashing, as it prevents the body from expanding to the side.
  • The inner box with infinite width is required so that the body isn’t split into multiple lines.
  • The alignment is optional in case you want all the different behaviors you can get in LaTeX with \mathclap, \mathrlap and \mathllap.
  • The display and script functions are necessary for keeping the font style and size of the subscript or superscript content, as that information would otherwise be lost as soon as a box is introduced.
  • The script(body) has to be in a block equation so that the bounds of the content are calculated correctly, which is necessary for proper positioning.

You can then use this as in

$ g(t) dot limits(integral)_smash(a+b+c+d)^smash(x+y+z) f(t) dif t $

image

2 Likes