Hey I’m a new typst user.

I want to redefine the math operator `/`

Is there a way to write

`$a/b$`

for `$display(a/b)$`

Another question.

Is it possible to create an inline math environment that is always in display mode.

Thank you.

Hey I’m a new typst user.

I want to redefine the math operator `/`

Is there a way to write

`$a/b$`

for `$display(a/b)$`

Another question.

Is it possible to create an inline math environment that is always in display mode.

Thank you.

This should do the trick

```
#show math.equation.where(block: false): it => math.display(it)
```

Hi, welcome to the forum, indeed you can, but I advice against it as this **almost always result in horrible line spacing**.

```
#set par(justify: true)
#show math.frac: math.display
#lorem(10)
$a/b$
#lorem(100)
```

Will result in this output:

Notice the horrible spacing of the first two lines, you also cannot turn this off so you should probably use `#[ ... ]`

to only apply this selectively in your document where you really want this.

The solution to the second question follows the same reasoning and has the same caveats:

```
#show math.equation.where(block: false): math.display
```

It produces the same output as above.

That’s a good start.

Is there a way to automize that.

Maybe an environment already in maths mode.

#display[3/4]

Or a command like

$ds 3/4$

Thank you for your help

The command is `display`

, as in `$display(3/4)$`

.

(In normal mode you write `math.display`

to refer to this function, but in math mode you can write simply `display`

.)

Why is this not working ?

```
#let fd={show math.frac: math.display}
$fd 4/3$
```

What is it doing and in what ways is that different from what you want it to do? It looks like it works to me:

```
#let fd={show math.frac: math.display}
$fd 4/3$
```

There isn’t any error.

But the fraction isn’t in display mode.

The reason why it isn’t working as you expect is that the show rule is evaluated then the result of that evaluation is stored in `fd`

. Then in the `math`

environment the value stored in `fd`

is recalled and added to your formula. But because the result of the show rule was nothing, nothing is added.

If you want to delay the evaluation of the show rule until the math environment, you can do it like this:

```
#let fd() = show math.frac: math.display
$fd() 4/3$
```

But this doesn’t compile, giving the error `Show is only allowed directly in code and content blocks`

.

The function defined here is not evaluating anything with the given show rule as no content is passed to it, a pure function with no arguments never does anything. You probably meant to write:

```
#let fd(body) = {
show math.frac: math.display
body
}
$fd(4/3)$
#[
#show: fd
$3/4$
]
```

The question is more or less answered, if you guys want to discuss useful shorthands and such a new thread in General is probably a good idea.

1 Like

Hi @Bazar, welcome and thank you for your question! I have changed your post’s title from “In-line math with display mode” to “How can I use display mode for in-line math?” as the question guidelines recommend this:

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

I also added the math tag, as it makes your question easier to find. Finally, don’t forget to tick one of the responses if you got a satisfying answer. The answer you choose should usually be the response that you found most correct/helpful/comprehensive for the question you asked.